#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*/ begin_function(char *);
int ea_mode(int);
int /*<<< orphan*/ print_bus_fetch_(char const *, char *, char *, int);
int /*<<< orphan*/ print_bus_wait_(char const *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int get_ea(const char *func_name, int opcode, int op_size, int read) {
  char wait_name[(100)];
  switch (ea_mode(opcode)) {
  default:
    return -1;
  case 0:
    printf("\tEV = REG_D(%d);\n", opcode & 7);
    break;
  case 1:
    printf("\tEV = REG_A(%d);\n", opcode & 7);
    break;
  case 2:
    printf("\tEA = REG_A(%d);\n", opcode & 7);
    break;
  case 3:
    printf("\tEA = REG_A(%d);\n", opcode & 7);
    if (op_size == 0 && (opcode & 7) == 7)
      printf("\tREG_A(7) += 2;\n");
    else
      printf("\tREG_A(%d) += %d;\n", opcode & 7, 1 << op_size);
    break;
  case 4:
    if (read) {
      sprintf(wait_name, "%s_wait_pre", func_name);
      printf("\tTIMEOUT(2, %s);\n}\n\n", wait_name);
      begin_function(wait_name);
    }
    if (op_size == 0 && (opcode & 7) == 7)
      printf("\tREG_A(7) -= 2;\n");
    else
      printf("\tREG_A(%d) -= %d;\n", opcode & 7, 1 << op_size);
    printf("\tEA = REG_A(%d);\n", opcode & 7);
    break;
  case 5:
  case 9:
    print_bus_wait_(func_name, "_wait_d16", "_read_d16");
    printf("\tEA = (int16_t)READ_16(PC) + ");
    if (ea_mode(opcode) == 5)
      printf("REG_A(%d);\n", opcode & 7);
    else
      printf("PC;\n");
    printf("\tPC += 2;\n");
    break;
  case 6:
  case 10:
    print_bus_wait_(func_name, "_wait_d8", "_read_d8");
    printf("\tEA = READ_16(PC);\n");
    sprintf(wait_name, "%s_wait_d8_sum", func_name);
    printf("\tTIMEOUT(2, %s);\n}\n\n", wait_name);
    begin_function(wait_name);
    printf("	if (EA & 0x800)\n"
           "		EA = (uint32_t)(int8_t)EA\n"
           "							"
           "+m68k->reg[M68K_REG_%c%c]\n"
           "							"
           "+REG_D((EA>>12)&0xF);\n"
           "	else\n"
           "		EA = (uint32_t)(int8_t)EA\n"
           "							"
           "+m68k->reg[M68K_REG_%c%c]\n"
           "							"
           "+(int16_t)REG_D((EA>>12)&0xF);\n"
           "	PC += 2;\n",
           ea_mode(opcode) == 6 ? 'A' : 'P',
           ea_mode(opcode) == 6 ? '0' + (opcode & 7) : 'C',
           ea_mode(opcode) == 6 ? 'A' : 'P',
           ea_mode(opcode) == 6 ? '0' + (opcode & 7) : 'C');
    break;
  case 7:
    print_bus_wait_(func_name, "_wait_w", "_read_w");
    printf("\tEA = (int16_t)READ_16(PC);\n");
    printf("\tPC += 2;\n");
    break;
  case 8:
    print_bus_wait_(func_name, "_wait_l", "_read_l");
    printf("\tEA = READ_16(PC)<<16;\n");
    printf("\tPC += 2;\n");
    print_bus_wait_(func_name, "_wait_l2", "_read_l2");
    printf("\tEA |= (uint16_t)READ_16(PC);\n");
    printf("\tPC += 2;\n");
    break;
  case 11:
    print_bus_fetch_(func_name, "_imm", "EV", op_size);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_ea>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
mov    %eax,%ecx
mov    %rcx,-0x88(%rbp)
sub    $0xb,%eax
ja     11a9 <get_ea+0x49>
mov    -0x88(%rbp),%rax
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xffffffff,-0x4(%rbp)
jmp    1569 <get_ea+0x409>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1240 <get_ea+0xe0>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1240 <get_ea+0xe0>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125e <get_ea+0xfe>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
cmpl   $0x0,-0x1c(%rbp)
je     129c <get_ea+0x13c>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe0e(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1080 <begin_function@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12c8 <get_ea+0x168>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    12c8 <get_ea+0x168>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e6 <get_ea+0x186>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x10(%rbp),%rdi
lea    0xdc5(%rip),%rsi
lea    0xdc8(%rip),%rdx
call   1050 <print_bus_wait_@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
cmp    $0x5,%eax
jne    134e <get_ea+0x1ee>
mov    -0x14(%rbp),%esi
and    $0x7,%esi
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    135c <get_ea+0x1fc>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x10(%rbp),%rdi
lea    0xd8c(%rip),%rsi
lea    0xd8e(%rip),%rdx
call   1050 <print_bus_wait_@plt>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd89(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x80(%rbp),%rsi
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1080 <begin_function@plt>
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
mov    %eax,%edx
mov    $0x50,%eax
mov    $0x41,%ecx
cmp    $0x6,%edx
cmove  %ecx,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
cmp    $0x6,%eax
jne    1408 <get_ea+0x2a8>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %eax,-0x90(%rbp)
jmp    1418 <get_ea+0x2b8>
mov    $0x43,%eax
mov    %eax,-0x90(%rbp)
jmp    1418 <get_ea+0x2b8>
mov    -0x90(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
mov    %eax,%edx
mov    $0x50,%eax
mov    $0x41,%ecx
cmp    $0x6,%edx
cmove  %ecx,%eax
mov    %eax,-0x94(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <ea_mode@plt>
cmp    $0x6,%eax
jne    1469 <get_ea+0x309>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
add    $0x30,%eax
mov    %eax,-0x9c(%rbp)
jmp    1479 <get_ea+0x319>
mov    $0x43,%eax
mov    %eax,-0x9c(%rbp)
jmp    1479 <get_ea+0x319>
mov    -0x94(%rbp),%ecx
mov    -0x98(%rbp),%edx
mov    -0x8c(%rbp),%esi
mov    -0x9c(%rbp),%r8d
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x10(%rbp),%rdi
lea    0xd6a(%rip),%rsi
lea    0xd6b(%rip),%rdx
call   1050 <print_bus_wait_@plt>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x10(%rbp),%rdi
lea    0xd5f(%rip),%rsi
lea    0xd60(%rip),%rdx
call   1050 <print_bus_wait_@plt>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd54(%rip),%rsi
lea    0xd56(%rip),%rdx
call   1050 <print_bus_wait_@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1562 <get_ea+0x402>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%ecx
lea    0xd4a(%rip),%rsi
lea    0xd48(%rip),%rdx
call   1030 <print_bus_fetch_@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ea>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
mov    %esi,%edi
call   1070 <ea_mode@plt>
cmp    $0xb,%eax
ja     13ad <get_ea+0x23d>
mov    %eax,%eax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xefb(%rip),%rsi
lea    0xefe(%rip),%rdx
mov    %rbp,%rdi
call   1060 <print_bus_wait_@plt>
lea    0xef9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%edi
call   1070 <ea_mode@plt>
cmp    $0x5,%eax
jne    1430 <get_ea+0x2c0>
and    $0x7,%r12d
lea    0xe6f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    143c <get_ea+0x2cc>
lea    0xede(%rip),%rsi
lea    0xee0(%rip),%rdx
mov    %rbp,%rdi
call   1060 <print_bus_wait_@plt>
lea    0x1053(%rip),%rdi
call   1040 <puts@plt>
lea    0xece(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1080 <sprintf@plt>
lea    0xe4d(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1090 <begin_function@plt>
mov    %r12d,%edi
call   1070 <ea_mode@plt>
cmp    $0x6,%eax
mov    $0x41,%eax
mov    $0x50,%r15d
mov    $0x50,%r13d
cmove  %eax,%r13d
mov    %r12d,%edi
call   1070 <ea_mode@plt>
mov    %r12d,%ebx
and    $0x7,%ebx
or     $0x30,%ebx
cmp    $0x6,%eax
mov    $0x43,%ebp
cmove  %ebx,%ebp
mov    %r12d,%edi
call   1070 <ea_mode@plt>
cmp    $0x6,%eax
mov    $0x41,%eax
cmove  %eax,%r15d
mov    %r12d,%edi
call   1070 <ea_mode@plt>
cmp    $0x6,%eax
mov    $0x43,%eax
cmovne %eax,%ebx
lea    0xe49(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1499 <get_ea+0x329>
and    $0x7,%r12d
jmp    1485 <get_ea+0x315>
and    $0x7,%r12d
lea    0xd72(%rip),%rdi
xor    %r14d,%r14d
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jne    144d <get_ea+0x2dd>
cmp    $0x7,%r12d
jne    144d <get_ea+0x2dd>
lea    0xf92(%rip),%rdi
call   1040 <puts@plt>
jmp    1499 <get_ea+0x329>
test   %ebx,%ebx
je     1345 <get_ea+0x1d5>
lea    0xd5b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1080 <sprintf@plt>
lea    0xd52(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1090 <begin_function@plt>
and    $0x7,%r12d
test   %r15d,%r15d
jne    146a <get_ea+0x2fa>
cmp    $0x7,%r12d
jne    146a <get_ea+0x2fa>
lea    0xf28(%rip),%rdi
call   1040 <puts@plt>
jmp    1485 <get_ea+0x315>
lea    0xe6b(%rip),%rsi
lea    0xe6c(%rip),%rdx
mov    %rbp,%rdi
call   1060 <print_bus_wait_@plt>
lea    0xec4(%rip),%rdi
jmp    1437 <get_ea+0x2c7>
lea    0xe7b(%rip),%rsi
lea    0xe79(%rip),%rdx
mov    %rbp,%rdi
mov    %r15d,%ecx
call   1030 <print_bus_fetch_@plt>
jmp    1448 <get_ea+0x2d8>
mov    $0xffffffff,%r14d
jmp    1499 <get_ea+0x329>
and    $0x7,%r12d
lea    0xc6d(%rip),%rdi
jmp    148c <get_ea+0x31c>
and    $0x7,%r12d
lea    0xc6f(%rip),%rdi
jmp    148c <get_ea+0x31c>
lea    0xe10(%rip),%rsi
lea    0xe11(%rip),%rdx
mov    %rbp,%rdi
call   1060 <print_bus_wait_@plt>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xdef(%rip),%rsi
lea    0xdf1(%rip),%rdx
mov    %rbp,%rdi
call   1060 <print_bus_wait_@plt>
lea    0xe0a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
jmp    1443 <get_ea+0x2d3>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
jmp    1499 <get_ea+0x329>
mov    $0x1,%edx
mov    %r15d,%ecx
shl    %cl,%edx
lea    0xc08(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1499 <get_ea+0x329>
mov    $0x1,%edx
mov    %r15d,%ecx
shl    %cl,%edx
lea    0xc1f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbc8(%rip),%rdi
xor    %r14d,%r14d
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\09EV = REG_D(%d);\0A\00"
@.str.1 = [18 x i8] c"\09EV = REG_A(%d);\0A\00"
@.str.2 = [18 x i8] c"\09EA = REG_A(%d);\0A\00"
@.str.3 = [17 x i8] c"\09REG_A(7) += 2;\0A\00"
@.str.4 = [19 x i8] c"\09REG_A(%d) += %d;\0A\00"
@.str.5 = [12 x i8] c"%s_wait_pre\00"
@.str.6 = [21 x i8] c"\09TIMEOUT(2, %s);\0A}\0A\0A\00"
@.str.7 = [17 x i8] c"\09REG_A(7) -= 2;\0A\00"
@.str.8 = [19 x i8] c"\09REG_A(%d) -= %d;\0A\00"
@.str.9 = [10 x i8] c"_wait_d16\00"
@.str.10 = [10 x i8] c"_read_d16\00"
@.str.11 = [30 x i8] c"\09EA = (int16_t)READ_16(PC) + \00"
@.str.12 = [12 x i8] c"REG_A(%d);\0A\00"
@.str.13 = [5 x i8] c"PC;\0A\00"
@.str.14 = [11 x i8] c"\09PC += 2;\0A\00"
@.str.15 = [9 x i8] c"_wait_d8\00"
@.str.16 = [9 x i8] c"_read_d8\00"
@.str.17 = [20 x i8] c"\09EA = READ_16(PC);\0A\00"
@.str.18 = [15 x i8] c"%s_wait_d8_sum\00"
@.str.19 = [223 x i8] c"\09if (EA & 0x800)\0A\09\09EA = (uint32_t)(int8_t)EA\0A\09\09\09\09\09\09\09+m68k->reg[M68K_REG_%c%c]\0A\09\09\09\09\09\09\09+REG_D((EA>>12)&0xF);\0A\09else\0A\09\09EA = (uint32_t)(int8_t)EA\0A\09\09\09\09\09\09\09+m68k->reg[M68K_REG_%c%c]\0A\09\09\09\09\09\09\09+(int16_t)REG_D((EA>>12)&0xF);\0A\09PC += 2;\0A\00"
@.str.20 = [8 x i8] c"_wait_w\00"
@.str.21 = [8 x i8] c"_read_w\00"
@.str.22 = [29 x i8] c"\09EA = (int16_t)READ_16(PC);\0A\00"
@.str.23 = [8 x i8] c"_wait_l\00"
@.str.24 = [8 x i8] c"_read_l\00"
@.str.25 = [24 x i8] c"\09EA = READ_16(PC)<<16;\0A\00"
@.str.26 = [9 x i8] c"_wait_l2\00"
@.str.27 = [9 x i8] c"_read_l2\00"
@.str.28 = [31 x i8] c"\09EA |= (uint16_t)READ_16(PC);\0A\00"
@.str.29 = [5 x i8] c"_imm\00"
@.str.30 = [3 x i8] c"EV\00"
define i32 @get_ea(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [100 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %7
%12 = call i32 @ea_mode(i32 %11)
switch i32 %12, label %13 [
i32 0, label %14
i32 1, label %18
i32 2, label %22
i32 3, label %26
i32 4, label %45
i32 5, label %75
i32 9, label %75
i32 6, label %90
i32 10, label %90
i32 7, label %132
i32 8, label %137
i32 11, label %146
]
13: ; preds = %4
store i32 -1, i32* %5
br label %151
14: ; preds = %4
%15 = load i32, i32* %7
%16 = and i32 %15, 7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %150
18: ; preds = %4
%19 = load i32, i32* %7
%20 = and i32 %19, 7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %150
22: ; preds = %4
%23 = load i32, i32* %7
%24 = and i32 %23, 7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %150
26: ; preds = %4
%27 = load i32, i32* %7
%28 = and i32 %27, 7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i32, i32* %7
%34 = and i32 %33, 7
%35 = icmp eq i32 %34, 7
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %44
38: ; preds = %32, %26
%39 = load i32, i32* %7
%40 = and i32 %39, 7
%41 = load i32, i32* %8
%42 = shl i32 1, %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %42)
br label %44
44: ; preds = %38, %36
br label %150
45: ; preds = %4
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %56
48: ; preds = %45
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%50 = load i8*, i8** %6
%51 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%55 = call i32 @begin_function(i8* %54)
br label %56
56: ; preds = %48, %45
%57 = load i32, i32* %8
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %56
%60 = load i32, i32* %7
%61 = and i32 %60, 7
%62 = icmp eq i32 %61, 7
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %71
65: ; preds = %59, %56
%66 = load i32, i32* %7
%67 = and i32 %66, 7
%68 = load i32, i32* %8
%69 = shl i32 1, %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %67, i32 %69)
br label %71
71: ; preds = %65, %63
%72 = load i32, i32* %7
%73 = and i32 %72, 7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %73)
br label %150
75: ; preds = %4, %4
%76 = load i8*, i8** %6
%77 = call i32 @print_bus_wait_(i8* %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%79 = load i32, i32* %7
%80 = call i32 @ea_mode(i32 %79)
%81 = icmp eq i32 %80, 5
br i1 %81, label %82, label %86
82: ; preds = %75
%83 = load i32, i32* %7
%84 = and i32 %83, 7
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %84)
br label %88
86: ; preds = %75
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %88
88: ; preds = %86, %82
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %150
90: ; preds = %4, %4
%91 = load i8*, i8** %6
%92 = call i32 @print_bus_wait_(i8* %91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.17, i64 0, i64 0))
%94 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%95 = load i8*, i8** %6
%96 = call i32 @sprintf(i8* %94, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* %95)
%97 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %97)
%99 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%100 = call i32 @begin_function(i8* %99)
%101 = load i32, i32* %7
%102 = call i32 @ea_mode(i32 %101)
%103 = icmp eq i32 %102, 6
%104 = zext i1 %103 to i64
%105 = select i1 %103, i32 65, i32 80
%106 = load i32, i32* %7
%107 = call i32 @ea_mode(i32 %106)
%108 = icmp eq i32 %107, 6
br i1 %108, label %109, label %113
109: ; preds = %90
%110 = load i32, i32* %7
%111 = and i32 %110, 7
%112 = add nsw i32 48, %111
br label %114
113: ; preds = %90
br label %114
114: ; preds = %113, %109
%115 = phi i32 [ %112, %109 ], [ 67, %113 ]
%116 = load i32, i32* %7
%117 = call i32 @ea_mode(i32 %116)
%118 = icmp eq i32 %117, 6
%119 = zext i1 %118 to i64
%120 = select i1 %118, i32 65, i32 80
%121 = load i32, i32* %7
%122 = call i32 @ea_mode(i32 %121)
%123 = icmp eq i32 %122, 6
br i1 %123, label %124, label %128
124: ; preds = %114
%125 = load i32, i32* %7
%126 = and i32 %125, 7
%127 = add nsw i32 48, %126
br label %129
128: ; preds = %114
br label %129
129: ; preds = %128, %124
%130 = phi i32 [ %127, %124 ], [ 67, %128 ]
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([223 x i8], [223 x i8]* @.str.19, i64 0, i64 0), i32 %105, i32 %115, i32 %120, i32 %130)
br label %150
132: ; preds = %4
%133 = load i8*, i8** %6
%134 = call i32 @print_bus_wait_(i8* %133, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %150
137: ; preds = %4
%138 = load i8*, i8** %6
%139 = call i32 @print_bus_wait_(i8* %138, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0))
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.25, i64 0, i64 0))
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%142 = load i8*, i8** %6
%143 = call i32 @print_bus_wait_(i8* %142, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.27, i64 0, i64 0))
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.28, i64 0, i64 0))
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %150
146: ; preds = %4
%147 = load i8*, i8** %6
%148 = load i32, i32* %8
%149 = call i32 @print_bus_fetch_(i8* %147, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i64 0, i64 0), i32 %148)
br label %150
150: ; preds = %146, %137, %132, %129, %88, %71, %44, %22, %18, %14
store i32 0, i32* %5
br label %151
151: ; preds = %150, %13
%152 = load i32, i32* %5
ret i32 %152
}

LLVM IR (-O2):
@.str = [18 x i8] c"\09EV = REG_D(%d);\0A\00"
@.str.1 = [18 x i8] c"\09EV = REG_A(%d);\0A\00"
@.str.2 = [18 x i8] c"\09EA = REG_A(%d);\0A\00"
@.str.4 = [19 x i8] c"\09REG_A(%d) += %d;\0A\00"
@.str.5 = [12 x i8] c"%s_wait_pre\00"
@.str.6 = [21 x i8] c"\09TIMEOUT(2, %s);\0A}\0A\0A\00"
@.str.8 = [19 x i8] c"\09REG_A(%d) -= %d;\0A\00"
@.str.9 = [10 x i8] c"_wait_d16\00"
@.str.10 = [10 x i8] c"_read_d16\00"
@.str.11 = [30 x i8] c"\09EA = (int16_t)READ_16(PC) + \00"
@.str.12 = [12 x i8] c"REG_A(%d);\0A\00"
@.str.15 = [9 x i8] c"_wait_d8\00"
@.str.16 = [9 x i8] c"_read_d8\00"
@.str.18 = [15 x i8] c"%s_wait_d8_sum\00"
@.str.19 = [223 x i8] c"\09if (EA & 0x800)\0A\09\09EA = (uint32_t)(int8_t)EA\0A\09\09\09\09\09\09\09+m68k->reg[M68K_REG_%c%c]\0A\09\09\09\09\09\09\09+REG_D((EA>>12)&0xF);\0A\09else\0A\09\09EA = (uint32_t)(int8_t)EA\0A\09\09\09\09\09\09\09+m68k->reg[M68K_REG_%c%c]\0A\09\09\09\09\09\09\09+(int16_t)REG_D((EA>>12)&0xF);\0A\09PC += 2;\0A\00"
@.str.20 = [8 x i8] c"_wait_w\00"
@.str.21 = [8 x i8] c"_read_w\00"
@.str.23 = [8 x i8] c"_wait_l\00"
@.str.24 = [8 x i8] c"_read_l\00"
@.str.26 = [9 x i8] c"_wait_l2\00"
@.str.27 = [9 x i8] c"_read_l2\00"
@.str.29 = [5 x i8] c"_imm\00"
@.str.30 = [3 x i8] c"EV\00"
@str = [23 x i8] c"\09EA = READ_16(PC)<<16;\00"
@str.32 = [30 x i8] c"\09EA |= (uint16_t)READ_16(PC);\00"
@str.34 = [28 x i8] c"\09EA = (int16_t)READ_16(PC);\00"
@str.36 = [19 x i8] c"\09EA = READ_16(PC);\00"
@str.37 = [4 x i8] c"PC;\00"
@str.38 = [10 x i8] c"\09PC += 2;\00"
@str.39 = [16 x i8] c"\09REG_A(7) -= 2;\00"
@str.40 = [16 x i8] c"\09REG_A(7) += 2;\00"
define i32 @get_ea(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @ea_mode(i32 %1)
switch i32 %7, label %92 [
i32 0, label %8
i32 1, label %11
i32 2, label %14
i32 3, label %17
i32 4, label %28
i32 5, label %46
i32 9, label %46
i32 6, label %58
i32 10, label %58
i32 7, label %79
i32 8, label %83
i32 11, label %90
]
8: ; preds = %4
%9 = and i32 %1, 7
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %92
11: ; preds = %4
%12 = and i32 %1, 7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %92
14: ; preds = %4
%15 = and i32 %1, 7
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %92
17: ; preds = %4
%18 = and i32 %1, 7
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = icmp eq i32 %2, 0
%21 = icmp eq i32 %18, 7
%22 = and i1 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.40, i64 0, i64 0))
br label %92
25: ; preds = %17
%26 = shl nuw i32 1, %2
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %26)
br label %92
28: ; preds = %4
%29 = icmp eq i32 %3, 0
br i1 %29, label %34, label %30
30: ; preds = %28
%31 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%33 = call i32 @begin_function(i8* %6)
br label %34
34: ; preds = %30, %28
%35 = icmp eq i32 %2, 0
%36 = and i32 %1, 7
%37 = icmp eq i32 %36, 7
%38 = and i1 %35, %37
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.39, i64 0, i64 0))
br label %44
41: ; preds = %34
%42 = shl nuw i32 1, %2
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %36, i32 %42)
br label %44
44: ; preds = %41, %39
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %92
46: ; preds = %4, %4
%47 = tail call i32 @print_bus_wait_(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%49 = tail call i32 @ea_mode(i32 %1)
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = and i32 %1, 7
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %46
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.37, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.38, i64 0, i64 0))
br label %92
58: ; preds = %4, %4
%59 = tail call i32 @print_bus_wait_(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.36, i64 0, i64 0))
%61 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i8* %0)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%63 = call i32 @begin_function(i8* %6)
%64 = call i32 @ea_mode(i32 %1)
%65 = icmp eq i32 %64, 6
%66 = select i1 %65, i32 65, i32 80
%67 = call i32 @ea_mode(i32 %1)
%68 = icmp eq i32 %67, 6
%69 = and i32 %1, 7
%70 = or i32 %69, 48
%71 = select i1 %68, i32 %70, i32 67
%72 = call i32 @ea_mode(i32 %1)
%73 = icmp eq i32 %72, 6
%74 = select i1 %73, i32 65, i32 80
%75 = call i32 @ea_mode(i32 %1)
%76 = icmp eq i32 %75, 6
%77 = select i1 %76, i32 %70, i32 67
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([223 x i8], [223 x i8]* @.str.19, i64 0, i64 0), i32 %66, i32 %71, i32 %74, i32 %77)
br label %92
79: ; preds = %4
%80 = tail call i32 @print_bus_wait_(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
%81 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.34, i64 0, i64 0))
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.38, i64 0, i64 0))
br label %92
83: ; preds = %4
%84 = tail call i32 @print_bus_wait_(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0))
%85 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.38, i64 0, i64 0))
%87 = tail call i32 @print_bus_wait_(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.27, i64 0, i64 0))
%88 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.32, i64 0, i64 0))
%89 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.38, i64 0, i64 0))
br label %92
90: ; preds = %4
%91 = tail call i32 @print_bus_fetch_(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.29, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i64 0, i64 0), i32 %2)
br label %92
92: ; preds = %8, %11, %14, %44, %56, %58, %79, %83, %90, %25, %23, %4
%93 = phi i32 [ -1, %4 ], [ 0, %23 ], [ 0, %25 ], [ 0, %90 ], [ 0, %83 ], [ 0, %79 ], [ 0, %58 ], [ 0, %56 ], [ 0, %44 ], [ 0, %14 ], [ 0, %11 ], [ 0, %8 ]
ret i32 %93
}