#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 begin_function(char *);
scalar_t__ ea_address(int);
int /*<<< orphan*/ ea_alterable(int);
int ea_mode(int);
scalar_t__ get_ea(char *, int, int, int);
int invalid();
scalar_t__ print_bus_read_(char *, char *, char *, char *, int);
int /*<<< orphan*/ print_bus_wait(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char const *, ...);
int gen_move(const char *mnemonic, int opcode) {
  char func_name[(100)];
  char access_name[(100)];
  int func_id;
  int op_size;
  int op_dest;
  int sizes[4] = {3, 0, 2, 1};
  op_size = (opcode >> 12) & 3;
  op_size = sizes[op_size];
  op_dest = ((opcode >> 9) & 7) | ((opcode >> 3) & 0x38);
  if (!ea_alterable(op_dest) || op_size == 3 ||
      (ea_mode(opcode) == 1 && op_size == 0) || ea_mode(opcode) < 0)
    return invalid();
  sprintf(func_name, "%s_%04X", mnemonic, opcode);
  func_id = begin_function(func_name);
  if (get_ea(func_name, opcode, op_size, 1) < 0)
    return -1;
  if (ea_address(opcode)) {
    if (op_size)
      printf("\tif (EA&1) ADDRESS_EXCEPTION;\n");
    sprintf(func_name, "%s_common_%02X", mnemonic, (op_size << 6) | op_dest);
    if (print_bus_read_(func_name, "", "EA", "EV", op_size) < 0)
      return func_id;
  }
  printf("\t{\n\t\tuint%d_t result = EV;\n", 8 << op_size);
  if (ea_mode(op_dest) != 1) {
    printf("\t\tSET_N_FLAG%d(result);\n", 8 << op_size);
    printf("\t\tSET_Z_FLAG%d(result);\n", 8 << op_size);
    printf("\t\tSET_V_FLAG(0);\n");
    printf("\t\tSET_C_FLAG(0);\n");
  }
  if (ea_mode(op_dest) == 0) {
    printf("\t\tSET_DN_REG%d(%d, result);\n\t}\n", 8 << op_size, op_dest & 0xF);
    printf("\tFETCH_OPCODE;\n}\n\n");
  } else if (ea_mode(op_dest) == 1) {
    printf("\t\tREG_D(%d) = (uint32_t)(int%d_t)result;\n\t}\n", op_dest & 0xF,
           8 << op_size);
    printf("\tFETCH_OPCODE;\n}\n\n");
  } else {
    sprintf(access_name, "%s_dest", func_name);
    printf("\t\tEV = result;\n\t}\n");
    if (get_ea(access_name, op_dest, op_size, 0) < 0)
      return -1;
    switch (op_size) {
    case 0:
      print_bus_wait("done_wait_wb", "done_write_wb");
      break;
    case 1:
      print_bus_wait("done_wait_ww", "done_write_ww");
      break;
    case 2:
      print_bus_wait("done_wait_wl", "done_write_wl");
      break;
    }
  }
  return func_id;
}


x86 assembly (clang, -O0):
<gen_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0xe47(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    0xe41(%rip),%rax
mov    %rax,-0x108(%rbp)
mov    -0x14(%rbp),%eax
sar    $0xc,%eax
and    $0x3,%eax
mov    %eax,-0xf8(%rbp)
movslq -0xf8(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%eax
mov    %eax,-0xf8(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x9,%eax
and    $0x7,%eax
mov    -0x14(%rbp),%ecx
sar    $0x3,%ecx
and    $0x38,%ecx
or     %ecx,%eax
mov    %eax,-0xfc(%rbp)
mov    -0xfc(%rbp),%edi
call   1040 <ea_alterable@plt>
cmp    $0x0,%eax
je     125b <gen_move+0xbb>
cmpl   $0x3,-0xf8(%rbp)
je     125b <gen_move+0xbb>
mov    -0x14(%rbp),%edi
call   1080 <ea_mode@plt>
cmp    $0x1,%eax
jne    124a <gen_move+0xaa>
cmpl   $0x0,-0xf8(%rbp)
je     125b <gen_move+0xbb>
mov    -0x14(%rbp),%edi
call   1080 <ea_mode@plt>
cmp    $0x0,%eax
jge    126a <gen_move+0xca>
mov    $0x0,%al
call   10a0 <invalid@plt>
mov    %eax,-0x4(%rbp)
jmp    1558 <gen_move+0x3b8>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   10c0 <begin_function@plt>
mov    %eax,-0xf4(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0xf8(%rbp),%edx
mov    $0x1,%ecx
call   1090 <get_ea@plt>
cmp    $0x0,%rax
jge    12bf <gen_move+0x11f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1558 <gen_move+0x3b8>
mov    -0x14(%rbp),%edi
call   1060 <ea_address@plt>
cmp    $0x0,%rax
je     1353 <gen_move+0x1b3>
cmpl   $0x0,-0xf8(%rbp)
je     12ec <gen_move+0x14c>
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0xf8(%rbp),%ecx
shl    $0x6,%ecx
or     -0xfc(%rbp),%ecx
lea    0xd2d(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0xf8(%rbp),%r8d
lea    0xdcd(%rip),%rsi
lea    0xd1c(%rip),%rdx
lea    0xd18(%rip),%rcx
call   1070 <print_bus_read_@plt>
cmp    $0x0,%rax
jge    134e <gen_move+0x1ae>
mov    -0xf4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1558 <gen_move+0x3b8>
jmp    1353 <gen_move+0x1b3>
mov    -0xf8(%rbp),%ecx
mov    $0x8,%esi
shl    %cl,%esi
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xfc(%rbp),%edi
call   1080 <ea_mode@plt>
cmp    $0x1,%eax
je     13d4 <gen_move+0x234>
mov    -0xf8(%rbp),%ecx
mov    $0x8,%esi
shl    %cl,%esi
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xf8(%rbp),%ecx
mov    $0x8,%esi
shl    %cl,%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xfc(%rbp),%edi
call   1080 <ea_mode@plt>
cmp    $0x0,%eax
jne    141f <gen_move+0x27f>
mov    -0xf8(%rbp),%ecx
mov    $0x8,%esi
shl    %cl,%esi
mov    -0xfc(%rbp),%edx
and    $0xf,%edx
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    154f <gen_move+0x3af>
mov    -0xfc(%rbp),%edi
call   1080 <ea_mode@plt>
cmp    $0x1,%eax
jne    146a <gen_move+0x2ca>
mov    -0xfc(%rbp),%esi
and    $0xf,%esi
mov    -0xf8(%rbp),%ecx
mov    $0x8,%edx
shl    %cl,%edx
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    154a <gen_move+0x3aa>
lea    -0xf0(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xca2(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0xfc(%rbp),%esi
mov    -0xf8(%rbp),%edx
xor    %ecx,%ecx
call   1090 <get_ea@plt>
cmp    $0x0,%rax
jge    14c1 <gen_move+0x321>
movl   $0xffffffff,-0x4(%rbp)
jmp    1558 <gen_move+0x3b8>
mov    -0xf8(%rbp),%eax
mov    %eax,-0x114(%rbp)
test   %eax,%eax
je     1502 <gen_move+0x362>
jmp    14da <gen_move+0x33a>
mov    -0x114(%rbp),%eax
sub    $0x1,%eax
je     151a <gen_move+0x37a>
jmp    14ee <gen_move+0x34e>
mov    -0x114(%rbp),%eax
sub    $0x2,%eax
je     1532 <gen_move+0x392>
jmp    1545 <gen_move+0x3a5>
lea    0xc30(%rip),%rdi
lea    0xc36(%rip),%rsi
call   1030 <print_bus_wait@plt>
jmp    1545 <gen_move+0x3a5>
lea    0xc33(%rip),%rdi
lea    0xc39(%rip),%rsi
call   1030 <print_bus_wait@plt>
jmp    1545 <gen_move+0x3a5>
lea    0xc36(%rip),%rdi
lea    0xc3c(%rip),%rsi
call   1030 <print_bus_wait@plt>
jmp    154a <gen_move+0x3aa>
jmp    154f <gen_move+0x3af>
mov    -0xf4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_move>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %esi,%ebp
mov    %rdi,%r13
mov    %esi,%r14d
shr    $0xc,%r14d
and    $0x3,%r14d
mov    %esi,%eax
shr    $0x9,%eax
and    $0x7,%eax
mov    %esi,%ebx
shr    $0x3,%ebx
and    $0x38,%ebx
or     %eax,%ebx
mov    %ebx,%edi
call   1050 <ea_alterable@plt>
test   %r14d,%r14d
je     1360 <gen_move+0x1b0>
test   %eax,%eax
je     1360 <gen_move+0x1b0>
mov    %ebp,%edi
call   1090 <ea_mode@plt>
cmp    $0x1,%r14d
jne    1211 <gen_move+0x61>
cmp    $0x1,%eax
je     1360 <gen_move+0x1b0>
mov    %ebp,%edi
call   1090 <ea_mode@plt>
test   %eax,%eax
js     1360 <gen_move+0x1b0>
lea    0xdd9(%rip),%rax
mov    (%rax,%r14,4),%r12d
lea    0xdde(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %r13,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    %r15,%rdi
call   10d0 <begin_function@plt>
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    $0x1,%ecx
call   10a0 <get_ea@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
js     139e <gen_move+0x1ee>
mov    %ebp,%edi
call   1070 <ea_address@plt>
test   %rax,%rax
je     12db <gen_move+0x12b>
cmp    $0x1,%r14d
je     1291 <gen_move+0xe1>
lea    0xedb(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%ecx
shl    $0x6,%ecx
or     %ebx,%ecx
lea    0xd78(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <sprintf@plt>
lea    0xda8(%rip),%rsi
lea    0xd67(%rip),%rdx
lea    0xd63(%rip),%rcx
mov    %rbp,%rdi
mov    %r12d,%r8d
call   1080 <print_bus_read_@plt>
test   %rax,%rax
js     1399 <gen_move+0x1e9>
mov    $0x8,%ebp
mov    %r12d,%ecx
shl    %cl,%ebp
lea    0xd41(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1090 <ea_mode@plt>
cmp    $0x1,%eax
je     1339 <gen_move+0x189>
lea    0xd41(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd4a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe22(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1090 <ea_mode@plt>
test   %eax,%eax
je     1378 <gen_move+0x1c8>
mov    %ebx,%edi
call   1090 <ea_mode@plt>
cmp    $0x1,%eax
jne    13b3 <gen_move+0x203>
and    $0xf,%ebx
lea    0xd41(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
jmp    1386 <gen_move+0x1d6>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <invalid@plt>
and    $0xf,%ebx
lea    0xcf9(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd9f(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%r15d
mov    %r15d,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd0e(%rip),%rsi
lea    0x80(%rsp),%rbp
lea    0x10(%rsp),%rdx
mov    %rbp,%rdi
xor    %eax,%eax
call   10c0 <sprintf@plt>
lea    0xd49(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
call   10a0 <get_ea@plt>
test   %rax,%rax
js     139e <gen_move+0x1ee>
cmp    $0x2,%r12d
je     141c <gen_move+0x26c>
cmp    $0x1,%r12d
je     142c <gen_move+0x27c>
test   %r12d,%r12d
mov    0xc(%rsp),%r15d
jne    139e <gen_move+0x1ee>
lea    0xcc2(%rip),%rdi
lea    0xcc8(%rip),%rsi
call   1030 <print_bus_wait@plt>
jmp    139e <gen_move+0x1ee>
lea    0xce3(%rip),%rdi
lea    0xce9(%rip),%rsi
jmp    143a <gen_move+0x28a>
lea    0xcb8(%rip),%rdi
lea    0xcbe(%rip),%rsi
call   1030 <print_bus_wait@plt>
jmp    1399 <gen_move+0x1e9>

LLVM IR (-O0):
@__const.gen_move.sizes = [4 x i32] [i32 3, i32 0, i32 2, i32 1]
@.str = [8 x i8] c"%s_%04X\00"
@.str.1 = [31 x i8] c"\09if (EA&1) ADDRESS_EXCEPTION;\0A\00"
@.str.2 = [15 x i8] c"%s_common_%02X\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [3 x i8] c"EA\00"
@.str.5 = [3 x i8] c"EV\00"
@.str.6 = [28 x i8] c"\09{\0A\09\09uint%d_t result = EV;\0A\00"
@.str.7 = [25 x i8] c"\09\09SET_N_FLAG%d(result);\0A\00"
@.str.8 = [25 x i8] c"\09\09SET_Z_FLAG%d(result);\0A\00"
@.str.9 = [18 x i8] c"\09\09SET_V_FLAG(0);\0A\00"
@.str.10 = [18 x i8] c"\09\09SET_C_FLAG(0);\0A\00"
@.str.11 = [32 x i8] c"\09\09SET_DN_REG%d(%d, result);\0A\09}\0A\00"
@.str.12 = [19 x i8] c"\09FETCH_OPCODE;\0A}\0A\0A\00"
@.str.13 = [45 x i8] c"\09\09REG_D(%d) = (uint32_t)(int%d_t)result;\0A\09}\0A\00"
@.str.14 = [8 x i8] c"%s_dest\00"
@.str.15 = [19 x i8] c"\09\09EV = result;\0A\09}\0A\00"
@.str.16 = [13 x i8] c"done_wait_wb\00"
@.str.17 = [14 x i8] c"done_write_wb\00"
@.str.18 = [13 x i8] c"done_wait_ww\00"
@.str.19 = [14 x i8] c"done_write_ww\00"
@.str.20 = [13 x i8] c"done_wait_wl\00"
@.str.21 = [14 x i8] c"done_write_wl\00"
define i32 @gen_move(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4 x i32]
store i8* %0, i8** %4
store i32 %1, i32* %5
%12 = bitcast [4 x i32]* %11 to i8*
%13 = load i32, i32* %5
%14 = ashr i32 %13, 12
%15 = and i32 %14, 3
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %11, i64 0, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %9
%20 = load i32, i32* %5
%21 = ashr i32 %20, 9
%22 = and i32 %21, 7
%23 = load i32, i32* %5
%24 = ashr i32 %23, 3
%25 = and i32 %24, 56
%26 = or i32 %22, %25
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = call i32 @ea_alterable(i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %44
30: ; preds = %2
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 3
br i1 %32, label %44, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = call i32 @ea_mode(i32 %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %9
%39 = icmp eq i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37, %33
%41 = load i32, i32* %5
%42 = call i32 @ea_mode(i32 %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40, %37, %30, %2
%45 = call i32 (...) @invalid()
store i32 %45, i32* %3
br label %144
46: ; preds = %40
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%48 = load i8*, i8** %4
%49 = load i32, i32* %5
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %48, i32 %49)
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%52 = call i32 @begin_function(i8* %51)
store i32 %52, i32* %8
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%54 = load i32, i32* %5
%55 = load i32, i32* %9
%56 = call i64 @get_ea(i8* %53, i32 %54, i32 %55, i32 1)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %46
store i32 -1, i32* %3
br label %144
59: ; preds = %46
%60 = load i32, i32* %5
%61 = call i64 @ea_address(i32 %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %83
63: ; preds = %59
%64 = load i32, i32* %9
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%70 = load i8*, i8** %4
%71 = load i32, i32* %9
%72 = shl i32 %71, 6
%73 = load i32, i32* %10
%74 = or i32 %72, %73
%75 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %70, i32 %74)
%76 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%77 = load i32, i32* %9
%78 = call i64 @print_bus_read_(i8* %76, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %68
%81 = load i32, i32* %8
store i32 %81, i32* %3
br label %144
82: ; preds = %68
br label %83
83: ; preds = %82, %59
%84 = load i32, i32* %9
%85 = shl i32 8, %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %10
%88 = call i32 @ea_mode(i32 %87)
%89 = icmp ne i32 %88, 1
br i1 %89, label %90, label %99
90: ; preds = %83
%91 = load i32, i32* %9
%92 = shl i32 8, %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %9
%95 = shl i32 8, %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %99
99: ; preds = %90, %83
%100 = load i32, i32* %10
%101 = call i32 @ea_mode(i32 %100)
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %110
103: ; preds = %99
%104 = load i32, i32* %9
%105 = shl i32 8, %104
%106 = load i32, i32* %10
%107 = and i32 %106, 15
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %105, i32 %107)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %142
110: ; preds = %99
%111 = load i32, i32* %10
%112 = call i32 @ea_mode(i32 %111)
%113 = icmp eq i32 %112, 1
br i1 %113, label %114, label %121
114: ; preds = %110
%115 = load i32, i32* %10
%116 = and i32 %115, 15
%117 = load i32, i32* %9
%118 = shl i32 8, %117
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0), i32 %116, i32 %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %141
121: ; preds = %110
%122 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%123 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%124 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %122, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* %123)
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0))
%126 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%127 = load i32, i32* %10
%128 = load i32, i32* %9
%129 = call i64 @get_ea(i8* %126, i32 %127, i32 %128, i32 0)
%130 = icmp slt i64 %129, 0
br i1 %130, label %131, label %132
131: ; preds = %121
store i32 -1, i32* %3
br label %144
132: ; preds = %121
%133 = load i32, i32* %9
switch i32 %133, label %140 [
i32 0, label %134
i32 1, label %136
i32 2, label %138
]
134: ; preds = %132
%135 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0))
br label %140
136: ; preds = %132
%137 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0))
br label %140
138: ; preds = %132
%139 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
br label %140
140: ; preds = %132, %138, %136, %134
br label %141
141: ; preds = %140, %114
br label %142
142: ; preds = %141, %103
%143 = load i32, i32* %8
store i32 %143, i32* %3
br label %144
144: ; preds = %142, %131, %80, %58, %44
%145 = load i32, i32* %3
ret i32 %145
}

LLVM IR (-O2):
@__const.gen_move.sizes = [4 x i32] [i32 3, i32 0, i32 2, i32 1]
@.str = [8 x i8] c"%s_%04X\00"
@.str.2 = [15 x i8] c"%s_common_%02X\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [3 x i8] c"EA\00"
@.str.5 = [3 x i8] c"EV\00"
@.str.6 = [28 x i8] c"\09{\0A\09\09uint%d_t result = EV;\0A\00"
@.str.7 = [25 x i8] c"\09\09SET_N_FLAG%d(result);\0A\00"
@.str.8 = [25 x i8] c"\09\09SET_Z_FLAG%d(result);\0A\00"
@.str.11 = [32 x i8] c"\09\09SET_DN_REG%d(%d, result);\0A\09}\0A\00"
@.str.13 = [45 x i8] c"\09\09REG_D(%d) = (uint32_t)(int%d_t)result;\0A\09}\0A\00"
@.str.14 = [8 x i8] c"%s_dest\00"
@.str.16 = [13 x i8] c"done_wait_wb\00"
@.str.17 = [14 x i8] c"done_write_wb\00"
@.str.18 = [13 x i8] c"done_wait_ww\00"
@.str.19 = [14 x i8] c"done_write_ww\00"
@.str.20 = [13 x i8] c"done_wait_wl\00"
@.str.21 = [14 x i8] c"done_write_wl\00"
@str = [18 x i8] c"\09\09EV = result;\0A\09}\00"
@str.23 = [18 x i8] c"\09FETCH_OPCODE;\0A}\0A\00"
@str.24 = [17 x i8] c"\09\09SET_V_FLAG(0);\00"
@str.25 = [17 x i8] c"\09\09SET_C_FLAG(0);\00"
@str.26 = [30 x i8] c"\09if (EA&1) ADDRESS_EXCEPTION;\00"
define i32 @gen_move(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = lshr i32 %1, 12
%8 = and i32 %7, 3
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds [4 x i32], [4 x i32]* @__const.gen_move.sizes, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = lshr i32 %1, 9
%13 = and i32 %12, 7
%14 = lshr i32 %1, 3
%15 = and i32 %14, 56
%16 = or i32 %13, %15
%17 = tail call i32 @ea_alterable(i32 %16)
%18 = icmp eq i32 %17, 0
%19 = icmp eq i32 %8, 0
%20 = or i1 %19, %18
br i1 %20, label %29, label %21
21: ; preds = %2
%22 = tail call i32 @ea_mode(i32 %1)
%23 = icmp eq i32 %22, 1
%24 = icmp eq i32 %8, 1
%25 = and i1 %24, %23
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = tail call i32 @ea_mode(i32 %1)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21, %26, %2
%30 = tail call i32 (...) @invalid()
br label %84
31: ; preds = %26
%32 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%33 = call i32 @begin_function(i8* %5)
%34 = call i64 @get_ea(i8* %5, i32 %1, i32 %11, i32 1)
%35 = icmp slt i64 %34, 0
br i1 %35, label %84, label %36
36: ; preds = %31
%37 = call i64 @ea_address(i32 %1)
%38 = icmp eq i64 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %36
br i1 %24, label %42, label %40
40: ; preds = %39
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.26, i64 0, i64 0))
br label %42
42: ; preds = %40, %39
%43 = shl i32 %11, 6
%44 = or i32 %43, %16
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %44)
%46 = call i64 @print_bus_read_(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%47 = icmp slt i64 %46, 0
br i1 %47, label %84, label %48
48: ; preds = %42, %36
%49 = shl i32 8, %11
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %49)
%51 = call i32 @ea_mode(i32 %16)
%52 = icmp eq i32 %51, 1
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %49)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.24, i64 0, i64 0))
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.25, i64 0, i64 0))
br label %58
58: ; preds = %53, %48
%59 = call i32 @ea_mode(i32 %16)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = and i32 %16, 15
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %49, i32 %62)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.23, i64 0, i64 0))
br label %84
65: ; preds = %58
%66 = call i32 @ea_mode(i32 %16)
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = and i32 %16, 15
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0), i32 %69, i32 %49)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.23, i64 0, i64 0))
br label %84
72: ; preds = %65
%73 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* %5)
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%75 = call i64 @get_ea(i8* %6, i32 %16, i32 %11, i32 0)
%76 = icmp slt i64 %75, 0
br i1 %76, label %84, label %77
77: ; preds = %72
switch i32 %11, label %84 [
i32 0, label %78
i32 1, label %80
i32 2, label %82
]
78: ; preds = %77
%79 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0))
br label %84
80: ; preds = %77
%81 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0))
br label %84
82: ; preds = %77
%83 = call i32 @print_bus_wait(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
br label %84
84: ; preds = %61, %78, %80, %82, %77, %68, %72, %42, %31, %29
%85 = phi i32 [ %30, %29 ], [ -1, %31 ], [ %33, %42 ], [ -1, %72 ], [ %33, %68 ], [ %33, %77 ], [ %33, %82 ], [ %33, %80 ], [ %33, %78 ], [ %33, %61 ]
ret i32 %85
}