x86: revert the old change that check prefix location more strictly
diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c
index e13482f..590029c 100644
--- a/arch/X86/X86DisassemblerDecoder.c
+++ b/arch/X86/X86DisassemblerDecoder.c
@@ -365,11 +365,11 @@
  * @param location  - The location to query.
  * @return          - Whether the prefix is at that location.
  */
-static bool isPrefixAtLocation(struct InternalInstruction *insn, uint8_t prefix)
+static bool isPrefixAtLocation(struct InternalInstruction *insn, uint8_t prefix,
+		uint64_t location)
 {
-	//if (insn->prefixPresent[prefix] == 1 &&
-//			insn->prefixLocations[prefix] == location)
-	if (insn->prefixPresent[prefix] == 1)
+	if (insn->prefixPresent[prefix] == 1 &&
+			insn->prefixLocations[prefix] == location)
 		return true;
 	else
 		return false;
@@ -608,6 +608,7 @@
 			} else {
 				unconsumeByte(insn); /* unconsume byte1 */
 				unconsumeByte(insn); /* unconsume byte  */
+				insn->necessaryPrefixLocation = insn->readerCursor - 2;
 			}
 
 			if (insn->vectorExtensionType == TYPE_EVEX) {
@@ -652,8 +653,10 @@
 
 		if (insn->mode == MODE_64BIT || (byte1 & 0xc0) == 0xc0) {
 			insn->vectorExtensionType = TYPE_VEX_3B;
+			insn->necessaryPrefixLocation = insn->readerCursor - 1;
 		} else {
 			unconsumeByte(insn);
+			insn->necessaryPrefixLocation = insn->readerCursor - 1;
 		}
 
 		if (insn->vectorExtensionType == TYPE_VEX_3B) {
@@ -715,9 +718,10 @@
 
 		if ((byte1 & 0x38) != 0x0) { /* 0 in these 3 bits is a POP instruction. */
 			insn->vectorExtensionType = TYPE_XOP;
-		}
-		else {
+			insn->necessaryPrefixLocation = insn->readerCursor - 1;
+		} else {
 			unconsumeByte(insn);
+			insn->necessaryPrefixLocation = insn->readerCursor - 1;
 		}
 
 		if (insn->vectorExtensionType == TYPE_XOP) {
@@ -761,12 +765,15 @@
 				}
 
 				insn->rexPrefix = byte;
+				insn->necessaryPrefixLocation = insn->readerCursor - 2;
 				// dbgprintf(insn, "Found REX prefix 0x%hhx", byte);
 			} else {
 				unconsumeByte(insn);
+				insn->necessaryPrefixLocation = insn->readerCursor - 1;
 			}
 		} else {
 			unconsumeByte(insn);
+			insn->necessaryPrefixLocation = insn->readerCursor - 1;
 		}
 	}
 
@@ -1136,15 +1143,13 @@
 			return -1;
 		}
 	} else {
-		if (insn->mode != MODE_16BIT && isPrefixAtLocation(insn, 0x66)) {
-			if (insn->twoByteEscape != 0x0f)
-				attrMask |= ATTR_OPSIZE;
-		} else if (isPrefixAtLocation(insn, 0x67))
+		if (insn->mode != MODE_16BIT && isPrefixAtLocation(insn, 0x66, insn->necessaryPrefixLocation)) {
+			attrMask |= ATTR_OPSIZE;
+		} else if (isPrefixAtLocation(insn, 0x67, insn->necessaryPrefixLocation)) {
 			attrMask |= ATTR_ADSIZE;
-
-		if (isPrefixAtLocation(insn, 0xf3)) {
+		} else if (isPrefixAtLocation(insn, 0xf3, insn->necessaryPrefixLocation)) {
 			attrMask |= ATTR_XS;
-		} else if (isPrefixAtLocation(insn, 0xf2)) {
+		} else if (isPrefixAtLocation(insn, 0xf2, insn->necessaryPrefixLocation)) {
 			attrMask |= ATTR_XD;
 		}
 	}
diff --git a/arch/X86/X86DisassemblerDecoder.h b/arch/X86/X86DisassemblerDecoder.h
index b609055..cb70a93 100644
--- a/arch/X86/X86DisassemblerDecoder.h
+++ b/arch/X86/X86DisassemblerDecoder.h
@@ -614,6 +614,10 @@
   /* The type of the vector extension prefix */
   VectorExtensionType vectorExtensionType;
 
+  /* The location where a mandatory prefix would have to be (i.e., right before
+	 the opcode, or right before the REX prefix if one is present) */
+  uint64_t necessaryPrefixLocation;
+
   /* Sizes of various critical pieces of data, in bytes */
   uint8_t registerSize;
   uint8_t addressSize;