#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*/ add_opcode(int, int);
int begin_function(char *);
int /*<<< orphan*/ print_bus_read_(char *, char *, char *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void rtr(int opcode) {
  char func_name[(100)];
  int func_id;
  if (opcode != 0x4E77)
    return;
  sprintf(func_name, "rtr_%04X", opcode);
  func_id = begin_function(func_name);
  print_bus_read_(func_name, "", "REG_A(7)", "OP", 1);
  printf("\tSET_DN_REG8(M68K_REG_SR, OP);\n");
  printf("\tSR &= M68K_FLAG_ALL;\n");
  printf("\tREG_A(7) += 2;\n");
  print_bus_read_(func_name, "_pc", "REG_A(7)", "PC", 2);
  printf("\tREG_A(7) += 4;\n");
  printf("\tFETCH_OPCODE;\n}\n\n");
  add_opcode(func_id, opcode);
}


x86 assembly (clang, -O0):
<rtr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x4e77,-0x4(%rbp)
je     1170 <rtr+0x20>
jmp    121e <rtr+0xce>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe82(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1070 <begin_function@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeed(%rip),%rsi
lea    0xe68(%rip),%rdx
lea    0xe6a(%rip),%rcx
mov    $0x1,%r8d
call   1040 <print_bus_read_@plt>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe7b(%rip),%rsi
lea    0xe20(%rip),%rdx
lea    0xe71(%rip),%rcx
mov    $0x2,%r8d
call   1040 <print_bus_read_@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x74(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <add_opcode@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtr>:
cmp    $0x4e77,%edi
jne    121c <rtr+0xcc>
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xe95(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4e77,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <begin_function@plt>
mov    %eax,%r14d
lea    0xef5(%rip),%rsi
lea    0xe75(%rip),%rbp
lea    0xe77(%rip),%rcx
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    $0x1,%r8d
call   1040 <print_bus_read_@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3e(%rip),%rsi
lea    0xe3b(%rip),%rcx
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    $0x2,%r8d
call   1040 <print_bus_read_@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
mov    $0x4e77,%esi
call   1050 <add_opcode@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"rtr_%04X\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [9 x i8] c"REG_A(7)\00"
@.str.3 = [3 x i8] c"OP\00"
@.str.4 = [32 x i8] c"\09SET_DN_REG8(M68K_REG_SR, OP);\0A\00"
@.str.5 = [23 x i8] c"\09SR &= M68K_FLAG_ALL;\0A\00"
@.str.6 = [17 x i8] c"\09REG_A(7) += 2;\0A\00"
@.str.7 = [4 x i8] c"_pc\00"
@.str.8 = [3 x i8] c"PC\00"
@.str.9 = [17 x i8] c"\09REG_A(7) += 4;\0A\00"
@.str.10 = [19 x i8] c"\09FETCH_OPCODE;\0A}\0A\0A\00"
define void @rtr(i32 %0) {
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 20087
br i1 %6, label %7, label %8
7: ; preds = %1
br label %26
8: ; preds = %1
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* %2
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @begin_function(i8* %12)
store i32 %13, i32* %4
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @print_bus_read_(i8* %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @print_bus_read_(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = call i32 @add_opcode(i32 %23, i32 %24)
br label %26
26: ; preds = %8, %7
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"rtr_%04X\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [9 x i8] c"REG_A(7)\00"
@.str.3 = [3 x i8] c"OP\00"
@.str.7 = [4 x i8] c"_pc\00"
@.str.8 = [3 x i8] c"PC\00"
@str = [31 x i8] c"\09SET_DN_REG8(M68K_REG_SR, OP);\00"
@str.11 = [22 x i8] c"\09SR &= M68K_FLAG_ALL;\00"
@str.12 = [16 x i8] c"\09REG_A(7) += 2;\00"
@str.13 = [16 x i8] c"\09REG_A(7) += 4;\00"
@str.14 = [18 x i8] c"\09FETCH_OPCODE;\0A}\0A\00"
define void @rtr(i32 %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 20087
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 20087)
%7 = call i32 @begin_function(i8* %3)
%8 = call i32 @print_bus_read_(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%12 = call i32 @print_bus_read_(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0))
%15 = call i32 @add_opcode(i32 %7, i32 20087)
br label %16
16: ; preds = %1, %5
ret void
}