#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t dumpHex(FILE *inFile, FILE *outCFile, char nullTerminate) {
  size_t bufLen = 0;
  unsigned char ch;
  fprintf(outCFile, "\n{");
  do {
    ch = fgetc(inFile);
    if (feof(inFile) && nullTerminate)
      ch = 0x00;
    if (!feof(inFile) || nullTerminate) {
      if ((bufLen % 16) == 0)
        fprintf(outCFile, "\n   ");
      fprintf(outCFile, " 0x%02x,", (unsigned int)ch);
      ++bufLen;
    }
  } while (!feof(inFile));
  fprintf(outCFile, "\n}");
  return bufLen;
}


x86 assembly (clang, -O0):
<dumpHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     118f <dumpHex+0x5f>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     118f <dumpHex+0x5f>
movb   $0x0,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11af <dumpHex+0x7f>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     11f5 <dumpHex+0xc5>
mov    -0x20(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    11d3 <dumpHex+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movzbl -0x21(%rbp),%edx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11fa <dumpHex+0xca>
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115f <dumpHex+0x2f>
mov    -0x10(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xea6(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rcx,(%rsp)
call   1060 <fwrite@plt>
xor    %r15d,%r15d
jmp    11bb <dumpHex+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
and    %r14b,%r13b
test   $0xf,%r15b
je     11f0 <dumpHex+0xb0>
movzbl %r12b,%edx
test   %r13b,%r13b
mov    $0x0,%eax
cmovne %eax,%edx
mov    (%rsp),%rdi
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%r15
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    120f <dumpHex+0xcf>
test   %bpl,%bpl
setne  %r13b
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %rax,%rax
setne  %r14b
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %bpl,%bpl
jne    1180 <dumpHex+0x40>
test   %rax,%rax
jne    11ae <dumpHex+0x6e>
jmp    1180 <dumpHex+0x40>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xe02(%rip),%rdi
mov    (%rsp),%rcx
call   1060 <fwrite@plt>
jmp    1189 <dumpHex+0x49>
lea    0xdfb(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    (%rsp),%rcx
call   1060 <fwrite@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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