#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 wr_dump(void *data, int size) {
  int i;
  printf("\n--------------------------------------------------\n");
  for (i = 0; i < size; i++) {
    printf("%02hhx ", ((char *)data)[i]);
    if ((i + 1) % 8 == 0) {
      printf("   ");
    }
    if ((i + 1) % 16 == 0) {
      printf("\n");
    }
  }
  printf("\n--------------------------------------------------\n");
}


x86 assembly (clang, -O0):
<wr_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>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <wr_dump+0xa7>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117f <wr_dump+0x6f>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a4 <wr_dump+0x94>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <wr_dump+0x99>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <wr_dump+0x24>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wr_dump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    11bb <wr_dump+0x8b>
mov    %ebp,%ebp
lea    0xeaa(%rip),%r14
lea    0xeab(%rip),%r15
xor    %ebx,%ebx
jmp    1175 <wr_dump+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %rbx,%rbp
je     11bb <wr_dump+0x8b>
movsbl (%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
test   $0x7,%bl
je     11a0 <wr_dump+0x70>
test   $0xf,%bl
jne    1170 <wr_dump+0x40>
jmp    11af <wr_dump+0x7f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0xf,%bl
jne    1170 <wr_dump+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <wr_dump+0x40>
lea    0xe4a(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"\0A--------------------------------------------------\0A\00"
@.str.1 = [8 x i8] c"%02hhx \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @wr_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 ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %33, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %36
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
%21 = srem i32 %20, 8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %11
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
%28 = srem i32 %27, 16
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %7
36: ; preds = %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
ret void
}

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