#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 const *);
int declare_function(char const *);
int /*<<< orphan*/ printf(char *, char const *, char const *, ...);
int print_bus_wait(const char *bus_wait, const char *bus_access) {
  int bw = declare_function(bus_wait);
  printf("\tWAIT_BUS(%s, %s);\n}\n\n", bus_wait, bus_access);
  if (bw >= 0)
    printf("M68K_FUNCTION(%s) { WAIT_BUS(%s, %s); }\n\n", bus_wait, bus_wait,
           bus_access);
  return begin_function(bus_access);
}


x86 assembly (clang, -O0):
<print_bus_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <declare_function@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jl     1186 <print_bus_wait+0x56>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <begin_function@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bus_wait>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <declare_function@plt>
mov    %eax,%ebp
lea    0xeb8(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
js     1170 <print_bus_wait+0x40>
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <begin_function@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"\09WAIT_BUS(%s, %s);\0A}\0A\0A\00"
@.str.1 = [42 x i8] c"M68K_FUNCTION(%s) { WAIT_BUS(%s, %s); }\0A\0A\00"
define i32 @print_bus_wait(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @declare_function(i8* %6)
store i32 %7, i32* %5
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15, i8* %16)
br label %18
18: ; preds = %13, %2
%19 = load i8*, i8** %4
%20 = call i32 @begin_function(i8* %19)
ret i32 %20
}

LLVM IR (-O2):
@.str = [23 x i8] c"\09WAIT_BUS(%s, %s);\0A}\0A\0A\00"
@.str.1 = [42 x i8] c"M68K_FUNCTION(%s) { WAIT_BUS(%s, %s); }\0A\0A\00"
define i32 @print_bus_wait(i8* %0, i8* %1) {
%3 = tail call i32 @declare_function(i8* %0)
%4 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%5 = icmp sgt i32 %3, -1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %0, i8* %1)
br label %8
8: ; preds = %6, %2
%9 = tail call i32 @begin_function(i8* %1)
ret i32 %9
}