#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ decode_sss(unsigned char, unsigned char **);
int /*<<< orphan*/ opcode_adc(unsigned char *);
int /*<<< orphan*/ opcode_add(unsigned char *);
int /*<<< orphan*/ opcode_ana(unsigned char *);
int /*<<< orphan*/ opcode_cmp(unsigned char *);
int /*<<< orphan*/ opcode_ora(unsigned char *);
int /*<<< orphan*/ opcode_sbb(unsigned char *);
int /*<<< orphan*/ opcode_sub(unsigned char *);
int /*<<< orphan*/ opcode_xra(unsigned char *);
int decode_10(unsigned char instruction, int cycle_count) {
  unsigned char *lower = NULL;
  decode_sss(instruction, &lower);
  if ((instruction & 0x20) == 0x00) {
    if ((instruction & 0x10) == 0x00) {
      if ((instruction & 0x08) == 0x00) {
        opcode_add(lower);
      } else {
        opcode_adc(lower);
      }
    } else {
      if ((instruction & 0x08) == 0x00) {
        opcode_sub(lower);
      } else {
        opcode_sbb(lower);
      }
    }
  } else {
    switch (instruction & 0x18) {
    case 0x00:
      opcode_ana(lower);
      break;
    case 0x08:
      opcode_xra(lower);
      break;
    case 0x10:
      opcode_ora(lower);
      break;
    case 0x18:
      opcode_cmp(lower);
      break;
    }
  }
  if (lower) {
    return cycle_count - 4;
  } else {
    return cycle_count - 7;
  }
}


x86 assembly (clang, -O0):
<decode_10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rsi
movzbl -0x5(%rbp),%edi
call   1090 <decode_sss@plt>
movzbl -0x5(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
jne    1233 <decode_10+0xa3>
movzbl -0x5(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
jne    1202 <decode_10+0x72>
movzbl -0x5(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    11f4 <decode_10+0x64>
mov    -0x18(%rbp),%rdi
call   10b0 <opcode_add@plt>
jmp    11fd <decode_10+0x6d>
mov    -0x18(%rbp),%rdi
call   1050 <opcode_adc@plt>
jmp    122e <decode_10+0x9e>
movzbl -0x5(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    1220 <decode_10+0x90>
mov    -0x18(%rbp),%rdi
call   10a0 <opcode_sub@plt>
jmp    1229 <decode_10+0x99>
mov    -0x18(%rbp),%rdi
call   1060 <opcode_sbb@plt>
jmp    122e <decode_10+0x9e>
jmp    1295 <decode_10+0x105>
movzbl -0x5(%rbp),%eax
and    $0x18,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x18,%eax
ja     1290 <decode_10+0x100>
mov    -0x20(%rbp),%rax
lea    0xdac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
call   1040 <opcode_ana@plt>
jmp    1290 <decode_10+0x100>
mov    -0x18(%rbp),%rdi
call   1030 <opcode_xra@plt>
jmp    1290 <decode_10+0x100>
mov    -0x18(%rbp),%rdi
call   1080 <opcode_ora@plt>
jmp    1290 <decode_10+0x100>
mov    -0x18(%rbp),%rdi
call   1070 <opcode_cmp@plt>
jmp    1295 <decode_10+0x105>
cmpq   $0x0,-0x18(%rbp)
je     12ae <decode_10+0x11e>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    12b7 <decode_10+0x127>
mov    -0xc(%rbp),%eax
sub    $0x7,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_10>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
call   1090 <decode_sss@plt>
test   $0x20,%bl
jne    11c3 <decode_10+0x33>
mov    (%rsp),%rdi
test   $0x10,%bl
jne    11e4 <decode_10+0x54>
test   $0x8,%bl
jne    11f0 <decode_10+0x60>
call   10b0 <opcode_add@plt>
jmp    121d <decode_10+0x8d>
shr    $0x3,%ebx
and    $0x3,%ebx
lea    0xe30(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    (%rsp),%rdi
call   1040 <opcode_ana@plt>
jmp    121d <decode_10+0x8d>
test   $0x8,%bl
jne    120d <decode_10+0x7d>
call   10a0 <opcode_sub@plt>
jmp    121d <decode_10+0x8d>
call   1050 <opcode_adc@plt>
jmp    121d <decode_10+0x8d>
mov    (%rsp),%rdi
call   1080 <opcode_ora@plt>
jmp    121d <decode_10+0x8d>
mov    (%rsp),%rdi
call   1070 <opcode_cmp@plt>
jmp    121d <decode_10+0x8d>
call   1060 <opcode_sbb@plt>
jmp    121d <decode_10+0x8d>
mov    (%rsp),%rdi
call   1030 <opcode_xra@plt>
xor    %eax,%eax
cmpq   $0x0,(%rsp)
setne  %al
lea    (%rax,%rax,2),%eax
add    %r14d,%eax
add    $0xfffffff9,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @decode_10(i8 zeroext %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8*
store i8 %0, i8* %4
store i32 %1, i32* %5
store i8* null, i8** %6
%7 = load i8, i8* %4
%8 = call i32 @decode_sss(i8 zeroext %7, i8** %6)
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = and i32 %10, 32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %43
13: ; preds = %2
%14 = load i8, i8* %4
%15 = zext i8 %14 to i32
%16 = and i32 %15, 16
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = and i32 %20, 8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = call i32 @opcode_add(i8* %24)
br label %29
26: ; preds = %18
%27 = load i8*, i8** %6
%28 = call i32 @opcode_adc(i8* %27)
br label %29
29: ; preds = %26, %23
br label %42
30: ; preds = %13
%31 = load i8, i8* %4
%32 = zext i8 %31 to i32
%33 = and i32 %32, 8
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i8*, i8** %6
%37 = call i32 @opcode_sub(i8* %36)
br label %41
38: ; preds = %30
%39 = load i8*, i8** %6
%40 = call i32 @opcode_sbb(i8* %39)
br label %41
41: ; preds = %38, %35
br label %42
42: ; preds = %41, %29
br label %60
43: ; preds = %2
%44 = load i8, i8* %4
%45 = zext i8 %44 to i32
%46 = and i32 %45, 24
switch i32 %46, label %59 [
i32 0, label %47
i32 8, label %50
i32 16, label %53
i32 24, label %56
]
47: ; preds = %43
%48 = load i8*, i8** %6
%49 = call i32 @opcode_ana(i8* %48)
br label %59
50: ; preds = %43
%51 = load i8*, i8** %6
%52 = call i32 @opcode_xra(i8* %51)
br label %59
53: ; preds = %43
%54 = load i8*, i8** %6
%55 = call i32 @opcode_ora(i8* %54)
br label %59
56: ; preds = %43
%57 = load i8*, i8** %6
%58 = call i32 @opcode_cmp(i8* %57)
br label %59
59: ; preds = %43, %56, %53, %50, %47
br label %60
60: ; preds = %59, %42
%61 = load i8*, i8** %6
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i32, i32* %5
%65 = sub nsw i32 %64, 4
store i32 %65, i32* %3
br label %69
66: ; preds = %60
%67 = load i32, i32* %5
%68 = sub nsw i32 %67, 7
store i32 %68, i32* %3
br label %69
69: ; preds = %66, %63
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
define i32 @decode_10(i8 zeroext %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = call i32 @decode_sss(i8 zeroext %0, i8** %3)
%6 = zext i8 %0 to i32
%7 = and i32 %6, 32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %2
%10 = and i32 %6, 16
%11 = icmp eq i32 %10, 0
%12 = and i32 %6, 8
%13 = icmp eq i32 %12, 0
%14 = load i8*, i8** %3
br i1 %11, label %15, label %20
15: ; preds = %9
br i1 %13, label %16, label %18
16: ; preds = %15
%17 = call i32 @opcode_add(i8* %14)
br label %41
18: ; preds = %15
%19 = call i32 @opcode_adc(i8* %14)
br label %41
20: ; preds = %9
br i1 %13, label %21, label %23
21: ; preds = %20
%22 = call i32 @opcode_sub(i8* %14)
br label %41
23: ; preds = %20
%24 = call i32 @opcode_sbb(i8* %14)
br label %41
25: ; preds = %2
%26 = lshr i32 %6, 3
%27 = and i32 %26, 3
switch i32 %27, label %40 [
i32 0, label %28
i32 1, label %31
i32 2, label %34
i32 3, label %37
]
28: ; preds = %25
%29 = load i8*, i8** %3
%30 = call i32 @opcode_ana(i8* %29)
br label %41
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = call i32 @opcode_xra(i8* %32)
br label %41
34: ; preds = %25
%35 = load i8*, i8** %3
%36 = call i32 @opcode_ora(i8* %35)
br label %41
37: ; preds = %25
%38 = load i8*, i8** %3
%39 = call i32 @opcode_cmp(i8* %38)
br label %41
40: ; preds = %25
unreachable
41: ; preds = %28, %31, %34, %37, %18, %16, %23, %21
%42 = load i8*, i8** %3
%43 = icmp eq i8* %42, null
%44 = select i1 %43, i32 -7, i32 -4
%45 = add nsw i32 %44, %1
ret i32 %45
}