#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void __hexdump(uint8_t *buff, unsigned int size, unsigned int offs) {
  unsigned int i;
  const uint8_t *b = (uint8_t *)buff;
  for (i = 0; i < size; i++) {
    if ((i & 0x0f) == 0x00)
      do {
        fprintf(stderr, " %08x: ", offs + i);
      } while (0);
    do {
      fprintf(stderr, " %02x", b[i]);
    } while (0);
    if ((i & 0x0f) == 0x0f)
      do {
        fprintf(stderr, "\n");
      } while (0);
  }
  do {
    fprintf(stderr, "\n");
  } while (0);
}


x86 assembly (clang, -O0):
<__hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11dc <__hexdump+0xcc>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1173 <__hexdump+0x63>
jmp    1151 <__hexdump+0x41>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
add    -0x14(%rbp),%edx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1173 <__hexdump+0x63>
jmp    1178 <__hexdump+0x68>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0xf,%eax
jne    11c9 <__hexdump+0xb9>
jmp    11ad <__hexdump+0x9d>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c9 <__hexdump+0xb9>
jmp    11ce <__hexdump+0xbe>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <__hexdump+0x21>
jmp    11e1 <__hexdump+0xd1>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1194 <__hexdump+0x84>
mov    %rdi,%r13
mov    %esi,%ebx
mov    %edx,%eax
mov    %rax,(%rsp)
mov    0x2eaf(%rip),%r14
lea    0xed0(%rip),%r15
xor    %r12d,%r12d
jmp    1149 <__hexdump+0x39>
nopl   (%rax)
add    $0x1,%r12
cmp    %r12,%rbx
je     1194 <__hexdump+0x84>
mov    %r12d,%ebp
and    $0xf,%ebp
jne    116a <__hexdump+0x5a>
mov    (%r14),%edi
mov    (%rsp),%rax
lea    (%rax,%r12,1),%edx
lea    0xe9d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
mov    0x0(%r13,%r12,4),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmp    $0xf,%ebp
jne    1140 <__hexdump+0x30>
mov    (%r14),%edi
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1140 <__hexdump+0x30>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

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