#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 int /*<<< orphan*/ int64_t;

/* Variables and functions */
char *add_int(char *, char *, int /*<<< orphan*/, int);
char *add_string(char *, char *, char *);
char *add_pointer(char *dest, char *end, void *value) {
  if (value == NULL) {
    return add_string(dest, end, "(nil)");
  } else {
    dest = add_string(dest, end, "0x");
    return add_int(dest, end, (int64_t)value, 16);
  }
}


x86 assembly (clang, -O0):
<add_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115c <add_pointer+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xeb2(%rip),%rdx
call   1030 <add_string@plt>
mov    %rax,-0x8(%rbp)
jmp    1190 <add_pointer+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe9b(%rip),%rdx
call   1030 <add_string@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
mov    $0x10,%ecx
call   1040 <add_int@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_pointer>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdx,%rdx
je     1157 <add_pointer+0x37>
mov    %rdx,%rbx
lea    0xed0(%rip),%rdx
mov    %r14,%rsi
call   1030 <add_string@plt>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0x10,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <add_int@plt>
lea    0xea2(%rip),%rdx
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <add_string@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"(nil)\00"
@.str.1 = [3 x i8] c"0x\00"
define i8* @add_pointer(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i8* @add_string(i8* %11, i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %4
br label %23
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = call i8* @add_string(i8* %15, i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = ptrtoint i8* %20 to i32
%22 = call i8* @add_int(i8* %18, i8* %19, i32 %21, i32 16)
store i8* %22, i8** %4
br label %23
23: ; preds = %14, %10
%24 = load i8*, i8** %4
ret i8* %24
}

LLVM IR (-O2):
@.str = [6 x i8] c"(nil)\00"
@.str.1 = [3 x i8] c"0x\00"
define i8* @add_pointer(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i8* @add_string(i8* %0, i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %12
7: ; preds = %3
%8 = tail call i8* @add_string(i8* %0, i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = ptrtoint i8* %2 to i64
%10 = trunc i64 %9 to i32
%11 = tail call i8* @add_int(i8* %8, i8* %1, i32 %10, i32 16)
br label %12
12: ; preds = %7, %5
%13 = phi i8* [ %6, %5 ], [ %11, %7 ]
ret i8* %13
}