void printxval(xlat, val, dflt) struct xlat *xlat;
int val;
char *dflt;
{
  char *str = xlookup(xlat, val);
  if (str)
    tprintf("%s", str);
  else
    tprintf("%#x /* %s */", val, dflt);
}


x86 assembly (clang, -O0):
<printxval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1030 <xlookup@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1169 <printxval+0x49>
mov    -0x20(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
jmp    117e <printxval+0x5e>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printxval>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
xor    %eax,%eax
call   1030 <xlookup@plt>
test   %eax,%eax
je     114a <printxval+0x2a>
movslq %eax,%rsi
lea    0xec3(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <tprintf@plt>
lea    0xeb2(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <tprintf@plt>

LLVM IR (-O0):
%struct.xlat = type opaque
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c"%#x /* %s */\00"
define void @printxval(%struct.xlat* %0, i32 %1, i8* %2) {
%4 = alloca %struct.xlat*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store %struct.xlat* %0, %struct.xlat** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load %struct.xlat*, %struct.xlat** %4
%9 = load i32, i32* %5
%10 = call i32 (%struct.xlat*, i32, ...) bitcast (i32 (...)* @xlookup to i32 (%struct.xlat*, i32, ...)*)(%struct.xlat* %8, i32 %9)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %22
18: ; preds = %3
%19 = load i32, i32* %5
%20 = load i8*, i8** %6
%21 = call i32 (i8*, i32, i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %20)
br label %22
22: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
%struct.xlat = type opaque
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c"%#x /* %s */\00"
define void @printxval(%struct.xlat* %0, i32 %1, i8* %2) {
%4 = tail call i32 (%struct.xlat*, i32, ...) bitcast (i32 (...)* @xlookup to i32 (%struct.xlat*, i32, ...)*)(%struct.xlat* %0, i32 %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %12
10: ; preds = %3
%11 = tail call i32 (i8*, i32, i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i32, i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2)
br label %12
12: ; preds = %10, %6
ret void
}