#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_fetch_(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void stop(int opcode) {
  char func_name[(100)];
  char wait_name[(100)];
  int func_id;
  if (opcode != 0x4E72)
    return;
  sprintf(func_name, "stop_%04X", opcode);
  func_id = begin_function(func_name);
  printf("\tif (!SUPERVISOR) PRIVILEGE_EXCEPTION;\n");
  print_bus_fetch_(func_name, "", "OP", 1);
  sprintf(wait_name, "%s_inf", func_name);
  printf("\tSR = OP & M68K_FLAG_ALL;\n");
  printf("\tTIMEOUT(1<<15, %s);\n}\n\n", wait_name);
  begin_function(wait_name);
  printf("\tTIMEOUT(1<<15, %s);\n}\n\n", wait_name);
  add_opcode(func_id, opcode);
}


x86 assembly (clang, -O0):
<stop>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x4e72,-0x4(%rbp)
je     1170 <stop+0x20>
jmp    1229 <stop+0xd9>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1070 <begin_function@plt>
mov    %eax,-0xe4(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    0xe7e(%rip),%rdx
mov    $0x1,%ecx
call   1030 <print_bus_fetch_@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1070 <begin_function@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <add_opcode@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stop>:
cmp    $0x4e72,%edi
jne    1228 <stop+0xc8>
push   %rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
lea    0xe82(%rip),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4e72,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1080 <begin_function@plt>
mov    %eax,%r14d
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7c(%rip),%rsi
lea    0xe53(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%ecx
call   1030 <print_bus_fetch_@plt>
lea    0xe42(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
lea    0xe26(%rip),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1080 <begin_function@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
mov    $0x4e72,%esi
call   1060 <add_opcode@plt>
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"stop_%04X\00"
@.str.1 = [40 x i8] c"\09if (!SUPERVISOR) PRIVILEGE_EXCEPTION;\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"OP\00"
@.str.4 = [7 x i8] c"%s_inf\00"
@.str.5 = [27 x i8] c"\09SR = OP & M68K_FLAG_ALL;\0A\00"
@.str.6 = [25 x i8] c"\09TIMEOUT(1<<15, %s);\0A}\0A\0A\00"
define void @stop(i32 %0) {
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 20082
br i1 %7, label %8, label %9
8: ; preds = %1
br label %31
9: ; preds = %1
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @begin_function(i8* %13)
store i32 %14, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = call i32 @print_bus_fetch_(i8* %16, i8* getelementptr inbounds ([1 x i8], [1 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)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i32 @begin_function(i8* %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %5
%29 = load i32, i32* %2
%30 = call i32 @add_opcode(i32 %28, i32 %29)
br label %31
31: ; preds = %9, %8
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"stop_%04X\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [3 x i8] c"OP\00"
@.str.4 = [7 x i8] c"%s_inf\00"
@.str.6 = [25 x i8] c"\09TIMEOUT(1<<15, %s);\0A}\0A\0A\00"
@str = [39 x i8] c"\09if (!SUPERVISOR) PRIVILEGE_EXCEPTION;\00"
@str.7 = [26 x i8] c"\09SR = OP & M68K_FLAG_ALL;\00"
define void @stop(i32 %0) {
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %0, 20082
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 20082)
%9 = call i32 @begin_function(i8* %4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%11 = call i32 @print_bus_fetch_(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 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)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%15 = call i32 @begin_function(i8* %5)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%17 = call i32 @add_opcode(i32 %9, i32 20082)
br label %18
18: ; preds = %1, %7
ret void
}