#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 const *);
int /*<<< orphan*/ opcode_read();
int /*<<< orphan*/ print_bus_read_(char const *, char *, char *, char *, int);
int /*<<< orphan*/ print_bus_write_(char const *, char *, char *, char *, int);
int /*<<< orphan*/ printf(char *);
void interrupt() {
  const char *func_name = "interrupt";
  begin_function(func_name);
  printf("\tif (!SUPERVISOR) {USP = SP; SP = SSP;}\n");
  printf("\tif (SP&1) HALT;\n");
  print_bus_write_(func_name, "_pcl", "SP-2", "PC", 1);
  print_bus_write_(func_name, "_sr", "SP-6", "SR", 1);
  print_bus_write_(func_name, "_pch", "SP-4", "PC>>16", 1);
  print_bus_read_(func_name, "_vec", "OP*4", "PC", 2);
  printf("\tSR = (SR | M68K_FLAG_S_MASK) & (~M68K_FLAG_T1_MASK);\n");
  printf("\tSP -= 6;\n");
  printf("\tif (PC&1) ADDRESS_EXCEPTION;\n");
  opcode_read();
}


x86 assembly (clang, -O0):
<interrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <begin_function@plt>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rsi
lea    0xeb4(%rip),%rdx
lea    0xeb2(%rip),%rcx
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
lea    0xe9c(%rip),%rdx
lea    0xe9a(%rip),%rcx
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    0xe85(%rip),%rdx
lea    0xe83(%rip),%rcx
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    0xe72(%rip),%rdx
lea    0xe46(%rip),%rcx
mov    $0x2,%r8d
call   1060 <print_bus_read_@plt>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <opcode_read@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interrupt>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
call   1070 <begin_function@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rsi
lea    0xe86(%rip),%rdx
lea    0xe84(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rcx
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
lea    0xe6f(%rip),%rsi
lea    0xe6c(%rip),%rdx
lea    0xe6a(%rip),%rcx
mov    %rbx,%rdi
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
lea    0xe58(%rip),%rsi
lea    0xe56(%rip),%rdx
lea    0xe54(%rip),%rcx
mov    %rbx,%rdi
mov    $0x1,%r8d
call   1040 <print_bus_write_@plt>
lea    0xe46(%rip),%rsi
lea    0xe44(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
mov    $0x2,%r8d
call   1060 <print_bus_read_@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <opcode_read@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"interrupt\00"
@.str.1 = [41 x i8] c"\09if (!SUPERVISOR) {USP = SP; SP = SSP;}\0A\00"
@.str.2 = [18 x i8] c"\09if (SP&1) HALT;\0A\00"
@.str.3 = [5 x i8] c"_pcl\00"
@.str.4 = [5 x i8] c"SP-2\00"
@.str.5 = [3 x i8] c"PC\00"
@.str.6 = [4 x i8] c"_sr\00"
@.str.7 = [5 x i8] c"SP-6\00"
@.str.8 = [3 x i8] c"SR\00"
@.str.9 = [5 x i8] c"_pch\00"
@.str.10 = [5 x i8] c"SP-4\00"
@.str.11 = [7 x i8] c"PC>>16\00"
@.str.12 = [5 x i8] c"_vec\00"
@.str.13 = [5 x i8] c"OP*4\00"
@.str.14 = [55 x i8] c"\09SR = (SR | M68K_FLAG_S_MASK) & (~M68K_FLAG_T1_MASK);\0A\00"
@.str.15 = [11 x i8] c"\09SP -= 6;\0A\00"
@.str.16 = [31 x i8] c"\09if (PC&1) ADDRESS_EXCEPTION;\0A\00"
define void @interrupt() {
%1 = alloca i8*
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %1
%2 = load i8*, i8** %1
%3 = call i32 @begin_function(i8* %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = call i32 @print_bus_write_(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1)
%8 = load i8*, i8** %1
%9 = call i32 @print_bus_write_(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 1)
%10 = load i8*, i8** %1
%11 = call i32 @print_bus_write_(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 1)
%12 = load i8*, i8** %1
%13 = call i32 @print_bus_read_(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%14 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.14, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.16, i64 0, i64 0))
%17 = call i32 (...) @opcode_read()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"interrupt\00"
@.str.3 = [5 x i8] c"_pcl\00"
@.str.4 = [5 x i8] c"SP-2\00"
@.str.5 = [3 x i8] c"PC\00"
@.str.6 = [4 x i8] c"_sr\00"
@.str.7 = [5 x i8] c"SP-6\00"
@.str.8 = [3 x i8] c"SR\00"
@.str.9 = [5 x i8] c"_pch\00"
@.str.10 = [5 x i8] c"SP-4\00"
@.str.11 = [7 x i8] c"PC>>16\00"
@.str.12 = [5 x i8] c"_vec\00"
@.str.13 = [5 x i8] c"OP*4\00"
@str = [40 x i8] c"\09if (!SUPERVISOR) {USP = SP; SP = SSP;}\00"
@str.17 = [17 x i8] c"\09if (SP&1) HALT;\00"
@str.18 = [54 x i8] c"\09SR = (SR | M68K_FLAG_S_MASK) & (~M68K_FLAG_T1_MASK);\00"
@str.19 = [10 x i8] c"\09SP -= 6;\00"
@str.20 = [30 x i8] c"\09if (PC&1) ADDRESS_EXCEPTION;\00"
define void @interrupt() {
%1 = tail call i32 @begin_function(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
%4 = tail call i32 @print_bus_write_(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 1)
%5 = tail call i32 @print_bus_write_(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 1)
%6 = tail call i32 @print_bus_write_(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 1)
%7 = tail call i32 @print_bus_read_(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.18, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.19, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.20, i64 0, i64 0))
%11 = tail call i32 (...) @opcode_read()
ret void
}