#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 *, unsigned long, int, int, int, int);
char *string(char *, char *, int, int, int);
char *pointer(const char *fmt, char *buf, void *ptr, int field_width,
              int precision, int flags) {
  if (!ptr)
    return string(buf, "(null)", field_width, precision, flags);
  flags |= 32;
  if (field_width == -1) {
    field_width = 2 * sizeof(void *);
    flags |= 1;
  }
  return number(buf, (unsigned long)ptr, 16, field_width, precision, flags);
}


x86 assembly (clang, -O0):
<pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116d <pointer+0x4d>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xea1(%rip),%rsi
call   1030 <string@plt>
mov    %rax,-0x8(%rbp)
jmp    11b1 <pointer+0x91>
mov    -0x2c(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1190 <pointer+0x70>
movl   $0x10,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    $0x10,%edx
call   1040 <number@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer>:
mov    %rsi,%rdi
test   %rdx,%rdx
je     114e <pointer+0x2e>
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    $0x10,%esi
cmove  %esi,%ecx
sete   %al
or     %r9d,%eax
or     $0x20,%eax
mov    %rdx,%rsi
mov    $0x10,%edx
mov    %eax,%r9d
jmp    1040 <number@plt>
lea    0xeab(%rip),%rsi
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %r9d,%r8d
jmp    1030 <string@plt>

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

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