#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 */
int /*<<< orphan*/ printf(char *, ...);
void dump(const unsigned char *buf) {
  const unsigned char *p = buf;
  int first = 1;
  if (!buf) {
    printf("null\n");
    return;
  }
  printf("[");
  while (*p) {
    if (first) {
      first = 0;
    } else {
      printf(" ");
    }
    printf("%02x", (int)(*p));
    p++;
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1149 <dump+0x39>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bc <dump+0xac>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ae <dump+0x9e>
cmpl   $0x0,-0x14(%rbp)
je     117a <dump+0x6a>
movl   $0x0,-0x14(%rbp)
jmp    1188 <dump+0x78>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <dump+0x47>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11a3 <dump+0x73>
mov    %rdi,%rbx
mov    $0x5b,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%esi
lea    0xeb9(%rip),%r14
test   %esi,%esi
je     11aa <dump+0x7a>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,0x1(%rbx)
je     11aa <dump+0x7a>
add    $0x2,%rbx
lea    0xe8c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
movzbl -0x1(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1180 <dump+0x50>
jmp    11aa <dump+0x7a>
lea    0xe5b(%rip),%r14
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"null\0A\00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [5 x i8] c"%02x\00"
@.str.4 = [3 x i8] c"]\0A\00"
define void @dump(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i32 1, i32* %4
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %31
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %22, %10
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %4
br label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %19
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %8
ret void
}

LLVM IR (-O2):
@.str.3 = [5 x i8] c"%02x\00"
@str = [5 x i8] c"null\00"
@str.5 = [2 x i8] c"]\00"
define void @dump(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call i32 @putchar(i32 91)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %3
%8 = zext i8 %5 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %7, %13
%14 = phi i8* [ %19, %13 ], [ %10, %7 ]
%15 = tail call i32 @putchar(i32 32)
%16 = load i8, i8* %14
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i8, i8* %14, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %13
22: ; preds = %13, %3, %7, %1
%23 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %13 ]
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret void
}