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


x86 assembly (clang, -O0):
<dumpStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
jne    11d4 <dumpStr+0xa4>
cmpq   $0x0,-0x18(%rbp)
je     11b9 <dumpStr+0x89>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    11b9 <dumpStr+0x89>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
movzbl -0x19(%rbp),%edx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11e6 <dumpStr+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115a <dumpStr+0x2a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe98(%rip),%r15
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1070 <fwrite@plt>
lea    0xe83(%rip),%r13
xor    %ebx,%ebx
jmp    11ad <dumpStr+0x5d>
nopl   0x0(%rax,%rax,1)
mov    $0x22,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1207 <dumpStr+0xb7>
mov    %r12,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1190 <dumpStr+0x40>
test   %rbx,%rbx
je     11f4 <dumpStr+0xa4>
mov    %ebx,%eax
and    $0xf,%eax
test   %rax,%rax
jne    11f4 <dumpStr+0xa4>
mov    $0x22,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1070 <fwrite@plt>
movzbl %bpl,%edx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    119d <dumpStr+0x4d>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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