Add new API and start to provide access information for instruction operands

- New API cs_regs_access() that provide registers being read & modified by instruction

- New field cs_x86_op.access provides access info (READ, WRITE) for each operand

- New field cs_x86.eflags provides EFLAGS affected by instruction

- Extend cs_detail.{regs_read, regs_write} from uint8_t to uint16_t type
diff --git a/cs.c b/cs.c
index 1cfea37..3f95468 100644
--- a/cs.c
+++ b/cs.c
@@ -157,7 +157,7 @@
 		case CS_ERR_MEM:
 			return "Out of memory (CS_ERR_MEM)";
 		case CS_ERR_ARCH:
-			return "Invalid architecture (CS_ERR_ARCH)";
+			return "Invalid/unsupported architecture(CS_ERR_ARCH)";
 		case CS_ERR_HANDLE:
 			return "Invalid handle (CS_ERR_HANDLE)";
 		case CS_ERR_CSH:
@@ -774,7 +774,19 @@
 	return handle->group_name(ud, group);
 }
 
-static bool arr_exist(unsigned char *arr, unsigned char max, unsigned int id)
+static bool arr_exist8(unsigned char *arr, unsigned char max, unsigned int id)
+{
+	int i;
+
+	for (i = 0; i < max; i++) {
+		if (arr[i] == id)
+			return true;
+	}
+
+	return false;
+}
+
+static bool arr_exist(uint16_t *arr, unsigned char max, unsigned int id)
 {
 	int i;
 
@@ -800,17 +812,17 @@
 		return false;
 	}
 
-	if(!insn->id) {
+	if (!insn->id) {
 		handle->errnum = CS_ERR_SKIPDATA;
 		return false;
 	}
 
-	if(!insn->detail) {
+	if (!insn->detail) {
 		handle->errnum = CS_ERR_DETAIL;
 		return false;
 	}
 
-	return arr_exist(insn->detail->groups, insn->detail->groups_count, group_id);
+	return arr_exist8(insn->detail->groups, insn->detail->groups_count, group_id);
 }
 
 CAPSTONE_EXPORT
@@ -827,12 +839,12 @@
 		return false;
 	}
 
-	if(!insn->id) {
+	if (!insn->id) {
 		handle->errnum = CS_ERR_SKIPDATA;
 		return false;
 	}
 
-	if(!insn->detail) {
+	if (!insn->detail) {
 		handle->errnum = CS_ERR_DETAIL;
 		return false;
 	}
@@ -854,12 +866,12 @@
 		return false;
 	}
 
-	if(!insn->id) {
+	if (!insn->id) {
 		handle->errnum = CS_ERR_SKIPDATA;
 		return false;
 	}
 
-	if(!insn->detail) {
+	if (!insn->detail) {
 		handle->errnum = CS_ERR_DETAIL;
 		return false;
 	}
@@ -882,12 +894,12 @@
 		return -1;
 	}
 
-	if(!insn->id) {
+	if (!insn->id) {
 		handle->errnum = CS_ERR_SKIPDATA;
 		return -1;
 	}
 
-	if(!insn->detail) {
+	if (!insn->detail) {
 		handle->errnum = CS_ERR_DETAIL;
 		return -1;
 	}
@@ -959,12 +971,12 @@
 		return -1;
 	}
 
-	if(!insn->id) {
+	if (!insn->id) {
 		handle->errnum = CS_ERR_SKIPDATA;
 		return -1;
 	}
 
-	if(!insn->detail) {
+	if (!insn->detail) {
 		handle->errnum = CS_ERR_DETAIL;
 		return -1;
 	}
@@ -1043,3 +1055,47 @@
 
 	return -1;
 }
+
+CAPSTONE_EXPORT
+cs_err cs_regs_access(csh ud, const cs_insn *insn,
+		cs_regs regs_read, uint8_t *regs_read_count,
+		cs_regs regs_write, uint8_t *regs_write_count)
+{
+	struct cs_struct *handle;
+
+	if (!ud)
+		return -1;
+
+	handle = (struct cs_struct *)(uintptr_t)ud;
+
+#ifdef CAPSTONE_DIET
+	// This API does not work in DIET mode
+	handle->errnum = CS_ERR_DIET;
+	return CS_ERR_DIET;
+#else
+	if (!handle->detail) {
+		handle->errnum = CS_ERR_DETAIL;
+		return CS_ERR_DETAIL;
+	}
+
+	if (!insn->id) {
+		handle->errnum = CS_ERR_SKIPDATA;
+		return CS_ERR_SKIPDATA;
+	}
+
+	if (!insn->detail) {
+		handle->errnum = CS_ERR_DETAIL;
+		return CS_ERR_DETAIL;
+	}
+
+	if (handle->reg_access) {
+		handle->reg_access(insn, regs_read, regs_read_count, regs_write, regs_write_count);
+	} else {
+		// this arch is unsupported yet
+		handle->errnum = CS_ERR_ARCH;
+		return CS_ERR_ARCH;
+	}
+
+	return CS_ERR_OK;
+#endif
+}