#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 */
struct tcb {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ tprintf(char *, unsigned long);
int /*<<< orphan*/ tprints(char *);
scalar_t__ umoven(struct tcb *, long, int, char *);
void print_off_t(struct tcb *tcp, long addr) {
  unsigned long offset;
  if (!addr) {
    tprints("NULL");
    return;
  }
  if (umoven((tcp), (addr), sizeof(*(&offset)), (char *)(&offset)) < 0)
    tprintf("%#lx", addr);
  else
    tprintf("[%lu]", offset);
}


x86 assembly (clang, -O0):
<print_off_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <print_off_t+0x2c>
lea    0xeae(%rip),%rdi
call   1050 <tprints@plt>
jmp    11a1 <print_off_t+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rcx
mov    $0x8,%edx
call   1030 <umoven@plt>
cmp    $0x0,%rax
jge    1191 <print_off_t+0x61>
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <tprintf@plt>
jmp    11a1 <print_off_t+0x71>
mov    -0x18(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1040 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_off_t>:
test   %rsi,%rsi
je     115f <print_off_t+0x2f>
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rcx
mov    $0x8,%edx
call   1030 <umoven@plt>
test   %rax,%rax
js     116b <print_off_t+0x3b>
mov    0x8(%rsp),%rsi
lea    0xead(%rip),%rdi
jmp    1175 <print_off_t+0x45>
lea    0xe9a(%rip),%rdi
jmp    1050 <tprints@plt>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1040 <tprintf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

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