#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 */

/* Variables and functions */
char *number(char *, char *, unsigned long, int, int, int, int);
char *string(char *, char *, char *, int, int, int);
char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width,
              int precision, int flags) {
  if (!ptr)
    return string(buf, end, "(null)", field_width, precision, flags);
  flags |= 32;
  if (field_width == -1) {
    field_width = 2 * sizeof(void *);
    flags |= 1;
  }
  return number(buf, end, (unsigned long)ptr, 16, field_width, precision,
                flags);
}


x86 assembly (clang, -O0):
<pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1176 <pointer+0x56>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    0x10(%rbp),%r9d
lea    0xe98(%rip),%rdx
call   1030 <string@plt>
mov    %rax,-0x8(%rbp)
jmp    11c1 <pointer+0xa1>
mov    0x10(%rbp),%eax
or     $0x20,%eax
mov    %eax,0x10(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1199 <pointer+0x79>
movl   $0x10,-0x2c(%rbp)
mov    0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    $0x10,%ecx
mov    %eax,(%rsp)
call   1040 <number@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer>:
push   %rax
mov    %rsi,%rdi
mov    0x10(%rsp),%r10d
test   %rcx,%rcx
je     115c <pointer+0x3c>
xor    %esi,%esi
cmp    $0xffffffff,%r8d
sete   %sil
mov    $0x10,%eax
cmove  %eax,%r8d
or     %r10d,%esi
or     $0x20,%esi
mov    %esi,(%rsp)
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    $0x10,%ecx
call   1040 <number@plt>
pop    %rcx
ret
lea    0xe9d(%rip),%rcx
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %r10d,%r9d
pop    %rax
jmp    1030 <string@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"(null)\00"
define i8* @pointer(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
%16 = load i8*, i8** %12
%17 = icmp ne i8* %16, null
br i1 %17, label %25, label %18
18: ; preds = %7
%19 = load i8*, i8** %10
%20 = load i8*, i8** %11
%21 = load i32, i32* %13
%22 = load i32, i32* %14
%23 = load i32, i32* %15
%24 = call i8* @string(i8* %19, i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
store i8* %24, i8** %8
br label %42
25: ; preds = %7
%26 = load i32, i32* %15
%27 = or i32 %26, 32
store i32 %27, i32* %15
%28 = load i32, i32* %13
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %25
store i32 16, i32* %13
%31 = load i32, i32* %15
%32 = or i32 %31, 1
store i32 %32, i32* %15
br label %33
33: ; preds = %30, %25
%34 = load i8*, i8** %10
%35 = load i8*, i8** %11
%36 = load i8*, i8** %12
%37 = ptrtoint i8* %36 to i64
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = load i32, i32* %15
%41 = call i8* @number(i8* %34, i8* %35, i64 %37, i32 16, i32 %38, i32 %39, i32 %40)
store i8* %41, i8** %8
br label %42
42: ; preds = %33, %18
%43 = load i8*, i8** %8
ret i8* %43
}

LLVM IR (-O2):
@.str = [7 x i8] c"(null)\00"
define i8* @pointer(i8* nocapture readnone %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp eq i8* %3, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i8* @string(i8* %1, i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 %6)
br label %18
11: ; preds = %7
%12 = icmp eq i32 %4, -1
%13 = select i1 %12, i32 16, i32 %4
%14 = select i1 %12, i32 33, i32 32
%15 = or i32 %14, %6
%16 = ptrtoint i8* %3 to i64
%17 = tail call i8* @number(i8* %1, i8* %2, i64 %16, i32 16, i32 %13, i32 %5, i32 %15)
br label %18
18: ; preds = %11, %9
%19 = phi i8* [ %17, %11 ], [ %10, %9 ]
ret i8* %19
}