#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 */
unsigned int fread(unsigned char *, unsigned int, unsigned int,
                   int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  unsigned int bc;
  unsigned int tc;
  unsigned char c;
  printf("/* Converted binary gamefile (see binconv.c in assets) */\n"
         "\n"
         "#include \"types.h\"\n"
         "\n"
         "uint8 const gamefile[] = {\n");
  tc = 0U;
  while (1) {
    bc = fread(&c, 1U, 1U, stdin);
    if (bc != 1U) {
      break;
    }
    printf(" 0x%02XU,", c);
    tc++;
    if ((tc & 0xFU) == 0U) {
      printf("\n");
    }
  }
  if ((tc & 0xFU) != 0U) {
    printf("\n");
  }
  printf("};\n"
         "\n"
         "auint const gamefile_size = %u;\n",
         tc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%ecx
lea    -0xd(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     116f <main+0x4f>
jmp    11ac <main+0x8c>
movzbl -0xd(%rbp),%esi
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11a7 <main+0x87>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
je     11c9 <main+0xa9>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e8d(%rip),%r12
mov    (%r12),%ecx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <fread@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
jne    11dd <main+0x9d>
lea    0xe7f(%rip),%r14
lea    0x7(%rsp),%r15
xor    %ebx,%ebx
jmp    11ab <main+0x6b>
nopw   0x0(%rax,%rax,1)
mov    (%r12),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    11ce <main+0x8e>
movzbl 0x7(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
test   $0xf,%bl
jne    1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x50>
test   $0xf,%bl
je     11dd <main+0x9d>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe26(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [107 x i8] c"/* Converted binary gamefile (see binconv.c in assets) */\0A\0A#include \22types.h\22\0A\0Auint8 const gamefile[] = {\0A\00"
@stdin = global i32 0
@.str.1 = [10 x i8] c" 0x%02XU,\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [37 x i8] c"};\0A\0Aauint const gamefile_size = %u;\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %0, %23
%7 = load i32, i32* @stdin
%8 = call i32 @fread(i8* %4, i32 1, i32 1, i32 %7)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %6
br label %24
12: ; preds = %6
%13 = load i8, i8* %4
%14 = zext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = add i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = and i32 %18, 15
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %12
br label %6
24: ; preds = %11
%25 = load i32, i32* %3
%26 = and i32 %25, 15
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [10 x i8] c" 0x%02XU,\00"
@.str.3 = [37 x i8] c"};\0A\0Aauint const gamefile_size = %u;\0A\00"
@str = [106 x i8] c"/* Converted binary gamefile (see binconv.c in assets) */\0A\0A#include \22types.h\22\0A\0Auint8 const gamefile[] = {\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = call i32 @fread(i8* %1, i32 1, i32 1, i32 %3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %25
6: ; preds = %0, %16
%7 = phi i32 [ %11, %16 ], [ 0, %0 ]
%8 = load i8, i8* %1
%9 = zext i8 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = add i32 %7, 1
%12 = and i32 %11, 15
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @putchar(i32 10)
br label %16
16: ; preds = %14, %6
%17 = load i32, i32* @stdin
%18 = call i32 @fread(i8* %1, i32 1, i32 1, i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %6, label %20
20: ; preds = %16
%21 = and i32 %11, 15
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @putchar(i32 10)
br label %25
25: ; preds = %0, %23, %20
%26 = phi i32 [ %11, %23 ], [ %11, %20 ], [ 0, %0 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %26)
ret i32 0
}