#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 hex_dump(unsigned char *data, unsigned int n) {
  printf("HEX DUMP >>>>>>>>>\n");
  printf(
      "     :  0                          9                            19\n");
  printf("....................................................................."
         "............");
  int i;
  for (i = 0; i < n; ++i) {
    if ((i) % 20 == 0) {
      printf("\n%05d: ", (i / 20) * 20);
    }
    printf("%2x ", (int)data[i]);
  }
  printf("\nEND HEX<<<<<<<<\n");
  return 0;
}


x86 assembly (clang, -O0):
<hex_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b4 <hex_dump+0xa4>
mov    -0x10(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118c <hex_dump+0x7c>
mov    -0x10(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
imul   $0x14,%eax,%esi
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1150 <hex_dump+0x40>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     11ba <hex_dump+0x9a>
mov    %ebx,%r13d
mov    $0xcccccccd,%ebp
lea    0xee9(%rip),%r14
lea    0xeea(%rip),%r15
xor    %ebx,%ebx
jmp    1198 <hex_dump+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     11ba <hex_dump+0x9a>
mov    %ebx,%eax
imul   %rbp,%rax
shr    $0x24,%rax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
cmp    %eax,%ebx
jne    1180 <hex_dump+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <hex_dump+0x60>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"HEX DUMP >>>>>>>>>\0A\00"
@.str.1 = [68 x i8] c" : 0 9 19\0A\00"
@.str.2 = [82 x i8] c".................................................................................\00"
@.str.3 = [8 x i8] c"\0A%05d: \00"
@.str.4 = [5 x i8] c"%2x \00"
@.str.5 = [18 x i8] c"\0AEND HEX<<<<<<<<\0A\00"
define i32 @hex_dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %9
9: ; preds = %30, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i32, i32* %5
%15 = srem i32 %14, 20
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 20
%20 = mul nsw i32 %19, 20
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %17, %13
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %9
33: ; preds = %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [82 x i8] c".................................................................................\00"
@.str.3 = [8 x i8] c"\0A%05d: \00"
@.str.4 = [5 x i8] c"%2x \00"
@str = [19 x i8] c"HEX DUMP >>>>>>>>>\00"
@str.6 = [67 x i8] c" : 0 9 19\00"
@str.7 = [17 x i8] c"\0AEND HEX<<<<<<<<\00"
define i32 @hex_dump(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %1, 0
br i1 %6, label %23, label %7
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %16
%10 = phi i64 [ 0, %7 ], [ %21, %16 ]
%11 = trunc i64 %10 to i32
%12 = urem i32 %11, 20
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %11)
br label %16
16: ; preds = %14, %9
%17 = getelementptr inbounds i8, i8* %0, i64 %10
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %16, %2
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}