#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(char);
void dumpBuffer(unsigned char *buf, int length) {
  int j = 0, i, k, l = 0;
  if (length <= 0)
    return;
  putchar('\n');
  for (;; ++l) {
    printf("%03x0: ", l);
    for (i = 0; i < 16; ++i) {
      if (i == 8)
        putchar(' ');
      printf("%02x ", buf[16 * l + i]);
      ++j;
      if (j == length)
        break;
    }
    if (j == length) {
      for (k = i + 1; k < 16; ++k)
        printf("   ");
      if (k == 8)
        putchar(' ');
      ++i;
    }
    printf("   ");
    for (k = 0; k < i; ++k) {
      if (k == 8)
        putchar(' ');
      if ((buf[16 * l + k] > 31) && (buf[16 * l + k] < 128))
        putchar(buf[16 * l + k]);
      else
        putchar('.');
    }
    putchar('\n');
    if (j == length)
      break;
  }
  putchar('\n');
  putchar('\n');
}


x86 assembly (clang, -O0):
<dumpBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     114c <dumpBuffer+0x2c>
jmp    1321 <dumpBuffer+0x201>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11db <dumpBuffer+0xbb>
cmpl   $0x8,-0x14(%rbp)
jne    118c <dumpBuffer+0x6c>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11c8 <dumpBuffer+0xa8>
jmp    11db <dumpBuffer+0xbb>
jmp    11cd <dumpBuffer+0xad>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <dumpBuffer+0x4e>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1233 <dumpBuffer+0x113>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    1216 <dumpBuffer+0xf6>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f0 <dumpBuffer+0xd0>
cmpl   $0x8,-0x18(%rbp)
jne    122a <dumpBuffer+0x10a>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12df <dumpBuffer+0x1bf>
cmpl   $0x8,-0x18(%rbp)
jne    1268 <dumpBuffer+0x148>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x1f,%eax
jle    12c2 <dumpBuffer+0x1a2>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x80,%eax
jge    12c2 <dumpBuffer+0x1a2>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    12cc <dumpBuffer+0x1ac>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    12d1 <dumpBuffer+0x1b1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1248 <dumpBuffer+0x128>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    12fa <dumpBuffer+0x1da>
jmp    130d <dumpBuffer+0x1ed>
jmp    12ff <dumpBuffer+0x1df>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <dumpBuffer+0x36>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x30(%rsp)
test   %esi,%esi
jle    12d2 <dumpBuffer+0x1b2>
mov    %esi,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,0x14(%rsp)
mov    %ebx,%eax
neg    %eax
mov    %rax,0x28(%rsp)
lea    0xead(%rip),%rbp
mov    $0x2e,%r15d
xor    %r14d,%r14d
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    1194 <dumpBuffer+0x74>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    $0x10,%r14
cmpb   $0x0,0x4(%rsp)
lea    0xe7a(%rip),%rbp
jne    12eb <dumpBuffer+0x1cb>
mov    %r14,0x20(%rsp)
mov    %r14d,%r12d
and    $0xfffffff0,%r12d
add    0x30(%rsp),%r12
lea    0xe54(%rip),%rdi
mov    %r13,0x18(%rsp)
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%rax
mov    0x8(%rsp),%rcx
lea    (%rax,%rcx,1),%r14d
mov    $0xf,%ebx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x8,%r13
jne    11f0 <dumpBuffer+0xd0>
mov    $0x20,%edi
call   1030 <putchar@plt>
movzbl (%r12,%r13,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r14,%r13,1),%eax
cmp    $0xffffffff,%eax
je     1240 <dumpBuffer+0x120>
add    $0x1,%r13
add    $0xffffffff,%ebx
cmp    $0x10,%r13
jne    11e0 <dumpBuffer+0xc0>
xor    %ebx,%ebx
add    %r13d,%r14d
sete   %bl
mov    %ebx,0x4(%rsp)
or     $0x10,%ebx
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
add    %r13d,%eax
jmp    127f <dumpBuffer+0x15f>
nopl   0x0(%rax)
cmp    $0xe,%r13d
lea    0xdc3(%rip),%rbp
ja     125f <dumpBuffer+0x13f>
nopl   (%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1250 <dumpBuffer+0x130>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
js     12e1 <dumpBuffer+0x1c1>
add    $0x1,%r13
mov    $0x1,%al
mov    %eax,0x4(%rsp)
mov    %r13d,%ebx
mov    0x14(%rsp),%eax
mov    %rax,0x8(%rsp)
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%r13
mov    %ebx,%ebx
xor    %ebp,%ebp
jmp    12c0 <dumpBuffer+0x1a0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rbp,1),%eax
cmp    $0x20,%al
cmovl  %r15d,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1170 <dumpBuffer+0x50>
cmp    $0x8,%rbp
jne    12a0 <dumpBuffer+0x180>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    12a0 <dumpBuffer+0x180>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%03x0: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
define void @dumpBuffer(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
br label %131
12: ; preds = %2
%13 = call i32 @putchar(i8 signext 10)
br label %14
14: ; preds = %125, %12
%15 = load i32, i32* %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 0, i32* %6
br label %17
17: ; preds = %43, %14
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 16
br i1 %19, label %20, label %46
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 8
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @putchar(i8 signext 32)
br label %25
25: ; preds = %23, %20
%26 = load i8*, i8** %3
%27 = load i32, i32* %8
%28 = mul nsw i32 16, %27
%29 = load i32, i32* %6
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %26, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = load i32, i32* %4
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %25
br label %46
42: ; preds = %25
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %17
46: ; preds = %41, %17
%47 = load i32, i32* %5
%48 = load i32, i32* %4
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %69
50: ; preds = %46
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %53
53: ; preds = %58, %50
%54 = load i32, i32* %7
%55 = icmp slt i32 %54, 16
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %53
61: ; preds = %53
%62 = load i32, i32* %7
%63 = icmp eq i32 %62, 8
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @putchar(i8 signext 32)
br label %66
66: ; preds = %64, %61
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %69
69: ; preds = %66, %46
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %71
71: ; preds = %115, %69
%72 = load i32, i32* %7
%73 = load i32, i32* %6
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %118
75: ; preds = %71
%76 = load i32, i32* %7
%77 = icmp eq i32 %76, 8
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 @putchar(i8 signext 32)
br label %80
80: ; preds = %78, %75
%81 = load i8*, i8** %3
%82 = load i32, i32* %8
%83 = mul nsw i32 16, %82
%84 = load i32, i32* %7
%85 = add nsw i32 %83, %84
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %81, i64 %86
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = icmp sgt i32 %89, 31
br i1 %90, label %91, label %112
91: ; preds = %80
%92 = load i8*, i8** %3
%93 = load i32, i32* %8
%94 = mul nsw i32 16, %93
%95 = load i32, i32* %7
%96 = add nsw i32 %94, %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %92, i64 %97
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = icmp slt i32 %100, 128
br i1 %101, label %102, label %112
102: ; preds = %91
%103 = load i8*, i8** %3
%104 = load i32, i32* %8
%105 = mul nsw i32 16, %104
%106 = load i32, i32* %7
%107 = add nsw i32 %105, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %103, i64 %108
%110 = load i8, i8* %109
%111 = call i32 @putchar(i8 signext %110)
br label %114
112: ; preds = %91, %80
%113 = call i32 @putchar(i8 signext 46)
br label %114
114: ; preds = %112, %102
br label %115
115: ; preds = %114
%116 = load i32, i32* %7
%117 = add nsw i32 %116, 1
store i32 %117, i32* %7
br label %71
118: ; preds = %71
%119 = call i32 @putchar(i8 signext 10)
%120 = load i32, i32* %5
%121 = load i32, i32* %4
%122 = icmp eq i32 %120, %121
br i1 %122, label %123, label %124
123: ; preds = %118
br label %128
124: ; preds = %118
br label %125
125: ; preds = %124
%126 = load i32, i32* %8
%127 = add nsw i32 %126, 1
store i32 %127, i32* %8
br label %14
128: ; preds = %123
%129 = call i32 @putchar(i8 signext 10)
%130 = call i32 @putchar(i8 signext 10)
br label %131
131: ; preds = %128, %11
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%03x0: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
define void @dumpBuffer(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %73, label %4
4: ; preds = %2
%5 = tail call i32 @putchar(i8 signext 10)
br label %6
6: ; preds = %67, %4
%7 = phi i64 [ %69, %67 ], [ 0, %4 ]
%8 = phi i32 [ %50, %67 ], [ 0, %4 ]
%9 = trunc i64 %7 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = shl i64 %7, 4
%12 = and i64 %11, 4294967280
br label %13
13: ; preds = %6, %27
%14 = phi i64 [ 0, %6 ], [ %28, %27 ]
%15 = phi i32 [ %8, %6 ], [ %25, %27 ]
%16 = icmp eq i64 %14, 8
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @putchar(i8 signext 32)
br label %19
19: ; preds = %17, %13
%20 = add nuw nsw i64 %14, %12
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = add nsw i32 %15, 1
%26 = icmp eq i32 %25, %1
br i1 %26, label %34, label %27
27: ; preds = %19
%28 = add nuw nsw i64 %14, 1
%29 = icmp eq i64 %28, 16
br i1 %29, label %30, label %13
30: ; preds = %27
%31 = icmp eq i32 %25, %1
%32 = select i1 %31, i32 17, i32 16
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %48
34: ; preds = %19
%35 = trunc i64 %14 to i32
%36 = add nuw nsw i32 %35, 1
%37 = icmp ult i32 %35, 15
br i1 %37, label %38, label %43
38: ; preds = %34, %38
%39 = phi i32 [ %41, %38 ], [ %36, %34 ]
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%41 = add nuw nsw i32 %39, 1
%42 = icmp eq i32 %41, 16
br i1 %42, label %43, label %38
43: ; preds = %38, %34
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp sgt i32 %35, -1
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 @putchar(i8 signext 10)
br label %70
48: ; preds = %30, %43
%49 = phi i32 [ %32, %30 ], [ %36, %43 ]
%50 = phi i32 [ %25, %30 ], [ %1, %43 ]
%51 = phi i1 [ %31, %30 ], [ true, %43 ]
%52 = zext i32 %49 to i64
br label %53
53: ; preds = %48, %58
%54 = phi i64 [ 0, %48 ], [ %65, %58 ]
%55 = icmp eq i64 %54, 8
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = tail call i32 @putchar(i8 signext 32)
br label %58
58: ; preds = %56, %53
%59 = add nuw nsw i64 %54, %12
%60 = getelementptr inbounds i8, i8* %0, i64 %59
%61 = load i8, i8* %60
%62 = icmp sgt i8 %61, 31
%63 = select i1 %62, i8 %61, i8 46
%64 = tail call i32 @putchar(i8 signext %63)
%65 = add nuw nsw i64 %54, 1
%66 = icmp eq i64 %65, %52
br i1 %66, label %67, label %53
67: ; preds = %58
%68 = tail call i32 @putchar(i8 signext 10)
%69 = add nuw i64 %7, 1
br i1 %51, label %70, label %6
70: ; preds = %67, %46
%71 = tail call i32 @putchar(i8 signext 10)
%72 = tail call i32 @putchar(i8 signext 10)
br label %73
73: ; preds = %2, %70
ret void
}