void printnum_int(tcp, addr, fmt) struct tcb *tcp;
long addr;
char *fmt;
{
  int num;
  if (!addr) {
    tprintf("NULL");
    return;
  }
  if (umoven((tcp), (addr), sizeof *(&num), (char *)(&num)) < 0) {
    tprintf("%#lx", addr);
    return;
  }
  tprintf("[");
  tprintf(fmt, num);
  tprintf("]");
}


x86 assembly (clang, -O0):
<printnum_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1152 <printnum_int+0x32>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
jmp    11b4 <printnum_int+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rcx
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <umoven@plt>
cmp    $0x0,%eax
jge    118a <printnum_int+0x6a>
mov    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
jmp    11b4 <printnum_int+0x94>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1040 <tprintf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printnum_int>:
test   %rsi,%rsi
je     1170 <printnum_int+0x50>
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0x4(%rsp),%rcx
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <umoven@plt>
test   %eax,%eax
js     117e <printnum_int+0x5e>
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <tprintf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <tprintf@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <tprintf@plt>
jmp    118f <printnum_int+0x6f>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
jmp    1040 <tprintf@plt>
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <tprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tcb = type opaque
@.str = [5 x i8] c"NULL\00"
@.str.1 = [5 x i8] c"%#lx\00"
@.str.2 = [2 x i8] c"[\00"
@.str.3 = [2 x i8] c"]\00"
define void @printnum_int(%struct.tcb* %0, i64 %1, i8* %2) {
%4 = alloca %struct.tcb*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store %struct.tcb* %0, %struct.tcb** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%8 = load i64, i64* %5
%9 = icmp ne i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %27
12: ; preds = %3
%13 = load %struct.tcb*, %struct.tcb** %4
%14 = load i64, i64* %5
%15 = bitcast i32* %7 to i8*
%16 = call i32 (%struct.tcb*, i64, i64, i8*, ...) bitcast (i32 (...)* @umoven to i32 (%struct.tcb*, i64, i64, i8*, ...)*)(%struct.tcb* %13, i64 %14, i64 4, i8* %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i64, i64* %5
%20 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i64, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %19)
br label %27
21: ; preds = %12
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i32, ...)*)(i8* %23, i32 %24)
%26 = call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %21, %18, %10
ret void
}

LLVM IR (-O2):
%struct.tcb = type opaque
@.str = [5 x i8] c"NULL\00"
@.str.1 = [5 x i8] c"%#lx\00"
@.str.2 = [2 x i8] c"[\00"
@.str.3 = [2 x i8] c"]\00"
define void @printnum_int(%struct.tcb* %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %3
%10 = call i32 (%struct.tcb*, i64, i64, i8*, ...) bitcast (i32 (...)* @umoven to i32 (%struct.tcb*, i64, i64, i8*, ...)*)(%struct.tcb* %0, i64 %1, i64 4, i8* %5)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i64, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %19
14: ; preds = %9
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, i32, ...)*)(i8* %2, i32 %16)
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @tprintf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %14, %12, %7
ret void
}