#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_byte(unsigned long ka, char *base, unsigned long size) {
  unsigned long i;
  for (i = 0; i < size; i++) {
    if (i % 16 == 0) {
      printf("\n");
      printf("0x%08x: ", ka + i);
    }
    printf("%02X ", base[i]);
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<dump_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    119b <dump_byte+0x8b>
mov    -0x20(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    1170 <dump_byte+0x60>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
add    -0x20(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <dump_byte+0x1c>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1198 <dump_byte+0x68>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeb0(%rip),%r12
lea    0xeb2(%rip),%r13
xor    %ebp,%ebp
jmp    1178 <dump_byte+0x48>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1198 <dump_byte+0x68>
test   $0xf,%bpl
jne    1160 <dump_byte+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%r15,%rbp,1),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1160 <dump_byte+0x30>
lea    0xe70(%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 = [2 x i8] c"\0A\00"
@.str.1 = [9 x i8] c"0x%08x: \00"
@.str.2 = [6 x i8] c"%02X \00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define void @dump_byte(i64 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %29, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i64, i64* %7
%14 = urem i64 %13, 16
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = load i64, i64* %4
%19 = load i64, i64* %7
%20 = add i64 %18, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %16, %12
%23 = load i8*, i8** %5
%24 = load i64, i64* %7
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %22
%30 = load i64, i64* %7
%31 = add i64 %30, 1
store i64 %31, i64* %7
br label %8
32: ; preds = %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

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