#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_buf(char *msg, char *data, int size) {
  if (msg != NULL) {
    printf("-------------- DUMP (%s) -----------------------\n");
  }
  int i;
  for (i = 0; i < size; i++) {
    if (i % 15 == 0)
      printf("\n");
    printf("%02X ", data[i]);
  }
  printf("------------------------------------------------\n");
  return;
}


x86 assembly (clang, -O0):
<dump_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     113c <dump_buf+0x2c>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1199 <dump_buf+0x89>
mov    -0x18(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1171 <dump_buf+0x61>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <dump_buf+0x33>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r12
test   %rdi,%rdi
je     1153 <dump_buf+0x23>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    11ab <dump_buf+0x7b>
mov    %ebp,%r13d
mov    $0x88888889,%r15d
lea    0xecb(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    118b <dump_buf+0x5b>
nopl   (%rax)
movsbl (%r12,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
add    $0xffffffff,%ebx
cmp    %rbp,%r13
je     11ab <dump_buf+0x7b>
mov    %ebp,%eax
imul   %r15,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
add    %ebx,%eax
jne    1170 <dump_buf+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1170 <dump_buf+0x40>
lea    0xe86(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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