#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(unsigned char *ptr, unsigned int aadr, int len) {
  int start = aadr;
  int index = 0;
  printf("len=%d\n", len);
  while (index < len) {
    printf("%04x ", start + index);
    for (int i = 0; i < 8; i++) {
      if (index < len) {
        printf("%02x ", ptr[index]);
      } else {
        printf(".. ");
      }
      if (i == 3) {
        printf(" ");
      }
      index++;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ec <dump+0xdc>
mov    -0x14(%rbp),%esi
add    -0x18(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11d9 <dump+0xc9>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119c <dump+0x8c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <dump+0x9a>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x1c(%rbp)
jne    11c2 <dump+0xb2>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <dump+0x57>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1140 <dump+0x30>
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    %edx,%r13d
mov    %rsi,(%rsp)
mov    %rdi,%rbx
lea    0xec4(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13d,%r13d
jle    1316 <dump+0x1f6>
mov    %r13d,%r15d
lea    0xebc(%rip),%rbp
xor    %r14d,%r14d
jmp    118a <dump+0x6a>
nopl   (%rax)
movzbl (%rbx,%r12,1),%esi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%r14d
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r13d,%r14d
jge    1316 <dump+0x1f6>
mov    (%rsp),%rax
lea    (%rax,%r14,1),%esi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %r14d,%r12
cmp    %r13d,%r12d
jge    11c0 <dump+0xa0>
movzbl (%rbx,%r12,1),%esi
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ca <dump+0xaa>
nopl   (%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
or     $0x1,%rax
cmp    %r15,%rax
jge    11f0 <dump+0xd0>
movzbl (%rbx,%rax,1),%esi
lea    0xe2d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11fa <dump+0xda>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
or     $0x2,%rax
cmp    %r15,%rax
jge    1220 <dump+0x100>
movzbl (%rbx,%rax,1),%esi
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122a <dump+0x10a>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
or     $0x3,%rax
cmp    %r15,%rax
jge    1250 <dump+0x130>
movzbl (%rbx,%rax,1),%esi
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125a <dump+0x13a>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r12,%rax
or     $0x4,%rax
cmp    %r15,%rax
jge    1290 <dump+0x170>
movzbl (%rbx,%rax,1),%esi
lea    0xd93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    129a <dump+0x17a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
or     $0x5,%rax
cmp    %r15,%rax
jge    12c0 <dump+0x1a0>
movzbl (%rbx,%rax,1),%esi
lea    0xd5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12ca <dump+0x1aa>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rax
or     $0x6,%rax
cmp    %r15,%rax
jge    12f0 <dump+0x1d0>
movzbl (%rbx,%rax,1),%esi
lea    0xd2d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12fa <dump+0x1da>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
or     $0x7,%r12
cmp    %r15,%r12
jl     1160 <dump+0x40>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1173 <dump+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"len=%d\0A\00"
@.str.1 = [6 x i8] c"%04x \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c".. \00"
define void @dump(i8* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %96
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %92
%9 = phi i32 [ %93, %92 ], [ 0, %6 ]
%10 = add nsw i32 %9, %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = sext i32 %9 to i64
%13 = icmp slt i32 %9, %2
br i1 %13, label %14, label %19
14: ; preds = %8
%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.2, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %8
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %14, %19
%22 = or i64 %12, 1
%23 = icmp slt i64 %22, %7
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %31
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %0, i64 %22
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %24, %26
%32 = or i64 %12, 2
%33 = icmp slt i64 %32, %7
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %41
36: ; preds = %31
%37 = getelementptr inbounds i8, i8* %0, i64 %32
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34, %36
%42 = or i64 %12, 3
%43 = icmp slt i64 %42, %7
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %51
46: ; preds = %41
%47 = getelementptr inbounds i8, i8* %0, i64 %42
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %46, %44
%52 = tail call i32 @putchar(i32 32)
%53 = or i64 %12, 4
%54 = icmp slt i64 %53, %7
br i1 %54, label %57, label %55
55: ; preds = %51
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %62
57: ; preds = %51
%58 = getelementptr inbounds i8, i8* %0, i64 %53
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %55, %57
%63 = or i64 %12, 5
%64 = icmp slt i64 %63, %7
br i1 %64, label %67, label %65
65: ; preds = %62
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %72
67: ; preds = %62
%68 = getelementptr inbounds i8, i8* %0, i64 %63
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %65, %67
%73 = or i64 %12, 6
%74 = icmp slt i64 %73, %7
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %82
77: ; preds = %72
%78 = getelementptr inbounds i8, i8* %0, i64 %73
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %75, %77
%83 = or i64 %12, 7
%84 = icmp slt i64 %83, %7
br i1 %84, label %87, label %85
85: ; preds = %82
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %92
87: ; preds = %82
%88 = getelementptr inbounds i8, i8* %0, i64 %83
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %85, %87
%93 = add i32 %9, 8
%94 = tail call i32 @putchar(i32 10)
%95 = icmp slt i32 %93, %2
br i1 %95, label %8, label %96
96: ; preds = %92, %3
ret void
}