#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump(uint8_t *buff, size_t n, char token, char literal) {
  size_t j;
  printf(" %c ", token);
  for (j = 0; j < n; j++) {
    printf(" %02x", buff[j]);
  }
  printf(".\n");
  if (literal) {
    printf("    \"");
    for (j = 0; j < n; j++) {
      printf("%c", buff[j]);
    }
    printf("\"\n");
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
movsbl -0x11(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    117c <dump+0x6c>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <dump+0x34>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpb   $0x0,-0x12(%rbp)
je     11f0 <dump+0xe0>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11e2 <dump+0xd2>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <dump+0x9a>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r15d
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeb8(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     1177 <dump+0x47>
lea    0xea8(%rip),%r12
xor    %ebp,%ebp
nop
mov    (%r14,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <dump+0x30>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
test   %r15b,%r15b
je     11c6 <dump+0x96>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     11b2 <dump+0x82>
xor    %ebp,%ebp
nopl   (%rax)
mov    (%r14,%rbp,4),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <dump+0x70>
lea    0xe56(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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