#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 */
typedef char *uint32_t;
struct r4k_dis_t {
  int dummy;
};

/* Variables and functions */
int db_printf(struct r4k_dis_t *, char *, char *);
char *lookup_sym(struct r4k_dis_t *, char *);
int print_addr(struct r4k_dis_t *state, uint32_t address) {
  int len;
  char *sym;
  if ((sym = lookup_sym(state, address))) {
    len = db_printf(state, "%s", sym);
  } else {
    len = db_printf(state, "0x%08X", address);
  }
  return len;
}


x86 assembly (clang, -O0):
<print_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <lookup_sym@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1167 <print_addr+0x47>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xea6(%rip),%rsi
call   1040 <db_printf@plt>
mov    %eax,-0x14(%rbp)
jmp    117e <print_addr+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe8d(%rip),%rsi
call   1040 <db_printf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_addr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <lookup_sym@plt>
test   %rax,%rax
je     1143 <print_addr+0x23>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
jmp    1150 <print_addr+0x30>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <db_printf@plt>

LLVM IR (-O0):
%struct.r4k_dis_t = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"0x%08X\00"
define i32 @print_addr(%struct.r4k_dis_t* %0, i8* %1) {
%3 = alloca %struct.r4k_dis_t*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store %struct.r4k_dis_t* %0, %struct.r4k_dis_t** %3
store i8* %1, i8** %4
%7 = load %struct.r4k_dis_t*, %struct.r4k_dis_t** %3
%8 = load i8*, i8** %4
%9 = call i8* @lookup_sym(%struct.r4k_dis_t* %7, i8* %8)
store i8* %9, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load %struct.r4k_dis_t*, %struct.r4k_dis_t** %3
%13 = load i8*, i8** %6
%14 = call i32 @db_printf(%struct.r4k_dis_t* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 %14, i32* %5
br label %19
15: ; preds = %2
%16 = load %struct.r4k_dis_t*, %struct.r4k_dis_t** %3
%17 = load i8*, i8** %4
%18 = call i32 @db_printf(%struct.r4k_dis_t* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 %18, i32* %5
br label %19
19: ; preds = %15, %11
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
%struct.r4k_dis_t = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"0x%08X\00"
define i32 @print_addr(%struct.r4k_dis_t* %0, i8* %1) {
%3 = tail call i8* @lookup_sym(%struct.r4k_dis_t* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @db_printf(%struct.r4k_dis_t* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %9
7: ; preds = %2
%8 = tail call i32 @db_printf(%struct.r4k_dis_t* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
ret i32 %10
}