#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int xfread_byte(int /*<<< orphan*/ *, char *);
void dump_bytes(FILE *fp, char *filename, int size) {
  int addr = 0, byte;
  while (size-- > 0) {
    if ((addr % 16) == 0) {
      if (addr != 0)
        printf("\n");
      printf("    C $%04X:", addr);
    }
    byte = xfread_byte(fp, filename);
    printf(" %02X", byte);
    addr++;
  }
  if (addr != 0)
    printf("\n");
}


x86 assembly (clang, -O0):
<dump_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    11ba <dump_bytes+0x9a>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118b <dump_bytes+0x6b>
cmpl   $0x0,-0x18(%rbp)
je     117a <dump_bytes+0x5a>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <xfread_byte@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <dump_bytes+0x1a>
cmpl   $0x0,-0x18(%rbp)
je     11d2 <dump_bytes+0xb2>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    11e8 <dump_bytes+0xb8>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeae(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <xfread_byte@plt>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     11d0 <dump_bytes+0xa0>
mov    $0x1,%ebp
lea    0xe79(%rip),%r12
lea    0xe7f(%rip),%r13
jmp    11ae <dump_bytes+0x7e>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <xfread_byte@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     11cc <dump_bytes+0x9c>
test   $0xf,%bpl
jne    1190 <dump_bytes+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <dump_bytes+0x60>
test   %ebx,%ebx
jle    11e8 <dump_bytes+0xb8>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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