#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 *, ...);
int /*<<< orphan*/ putchar(int);
void dump(void *buf, int n) {
  int i;
  int j;
  int c;
  for (i = 0; i < n; i += 16) {
    printf("%04x: ", i);
    for (j = 0; j < 16; j++) {
      if (i + j < n)
        printf("%02x ", ((unsigned char *)buf)[i + j]);
      else
        printf("   ");
    }
    printf("  ");
    for (j = 0; j < 16; j++) {
      c = ((unsigned char *)buf)[i + j] & 0x7f;
      if (i + j >= n)
        putchar(' ');
      else if (c < ' ' || c == 0x7f)
        putchar('.');
      else
        putchar(c);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126b <dump+0x14b>
mov    -0x10(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11b8 <dump+0x98>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1197 <dump+0x77>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a5 <dump+0x85>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11aa <dump+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <dump+0x3a>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    124f <dump+0x12f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x7f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     120c <dump+0xec>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    123c <dump+0x11c>
cmpl   $0x20,-0x18(%rbp)
jl     1220 <dump+0x100>
cmpl   $0x7f,-0x18(%rbp)
jne    122f <dump+0x10f>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    1237 <dump+0x117>
mov    -0x18(%rbp),%edi
call   1030 <putchar@plt>
jmp    123c <dump+0x11c>
jmp    1241 <dump+0x121>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <dump+0xad>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <dump+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    120c <dump+0xec>
mov    %rdi,%rbx
mov    0x4(%rsp),%r12d
mov    $0x2e,%r15d
mov    $0x20,%r13d
xor    %r14d,%r14d
xchg   %ax,%ax
lea    0xea9(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    1188 <dump+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     11b0 <dump+0x90>
lea    (%r14,%rbp,1),%rax
cmp    %r12,%rax
jge    1170 <dump+0x50>
movzbl (%rbx,%rbp,1),%esi
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117e <dump+0x5e>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
movzbl (%rbx,%rbp,1),%eax
and    $0x7f,%eax
cmp    $0x7f,%al
mov    %eax,%edi
cmove  %r15d,%edi
cmp    $0x20,%al
cmovb  %r15d,%edi
lea    (%r14,%rbp,1),%rax
cmp    %r12,%rax
cmovge %r13d,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
jne    11c0 <dump+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%r14
add    $0x10,%rbx
cmp    0x4(%rsp),%r14d
jl     1150 <dump+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%04x: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %80, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %83
12: ; preds = %8
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %37, %12
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %40
18: ; preds = %15
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = add nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %15
40: ; preds = %15
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %42
42: ; preds = %75, %40
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 16
br i1 %44, label %45, label %78
45: ; preds = %42
%46 = load i8*, i8** %3
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = add nsw i32 %47, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %46, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = and i32 %53, 127
store i32 %54, i32* %7
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = add nsw i32 %55, %56
%58 = load i32, i32* %4
%59 = icmp sge i32 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %45
%61 = call i32 @putchar(i32 32)
br label %74
62: ; preds = %45
%63 = load i32, i32* %7
%64 = icmp slt i32 %63, 32
br i1 %64, label %68, label %65
65: ; preds = %62
%66 = load i32, i32* %7
%67 = icmp eq i32 %66, 127
br i1 %67, label %68, label %70
68: ; preds = %65, %62
%69 = call i32 @putchar(i32 46)
br label %73
70: ; preds = %65
%71 = load i32, i32* %7
%72 = call i32 @putchar(i32 %71)
br label %73
73: ; preds = %70, %68
br label %74
74: ; preds = %73, %60
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %42
78: ; preds = %42
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %80
80: ; preds = %78
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 16
store i32 %82, i32* %5
br label %8
83: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%04x: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c" \00"
define void @dump(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %47
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %42
%7 = phi i64 [ 0, %4 ], [ %44, %42 ]
%8 = trunc i64 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %6, %21
%11 = phi i64 [ 0, %6 ], [ %22, %21 ]
%12 = add nuw nsw i64 %11, %7
%13 = icmp slt i64 %12, %5
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %10
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %14, %19
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, 16
br i1 %23, label %24, label %10
24: ; preds = %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ 0, %24 ], [ %40, %26 ]
%28 = add nuw nsw i64 %27, %7
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = load i8, i8* %29
%31 = and i8 %30, 127
%32 = zext i8 %31 to i32
%33 = icmp slt i64 %28, %5
%34 = icmp ult i8 %31, 32
%35 = icmp eq i8 %31, 127
%36 = or i1 %34, %35
%37 = select i1 %36, i32 46, i32 %32
%38 = select i1 %33, i32 %37, i32 32
%39 = tail call i32 @putchar(i32 %38)
%40 = add nuw nsw i64 %27, 1
%41 = icmp eq i64 %40, 16
br i1 %41, label %42, label %26
42: ; preds = %26
%43 = tail call i32 @putchar(i32 10)
%44 = add nuw i64 %7, 16
%45 = trunc i64 %44 to i32
%46 = icmp slt i32 %45, %1
br i1 %46, label %6, label %47
47: ; preds = %42, %2
ret void
}