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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  static unsigned char buf[4096];
  int f;
  int size = fread(buf, 1, sizeof(buf), stdin);
  printf("/* PD ROM header file - automatically generated from pdrom.bin,\n"
         " * edits will be lost!\n"
         " */\n\n"
         "unsigned char pd_rom[]=\n  {");
  for (f = 0; f < size; f++) {
    if ((f % 8) == 0)
      printf("\n  ");
    printf("0x%02x,", buf[f]);
  }
  printf("\n  };\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%ecx
lea    0x2f01(%rip),%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0xc(%rbp)
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cf <main+0x9f>
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a4 <main+0x74>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x8(%rbp),%rcx
lea    0x2ea1(%rip),%rax
movzbl (%rax,%rcx,1),%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x46>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%ecx
lea    0x2ef7(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %eax,%ebx
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    11c9 <main+0x89>
mov    %ebx,%r13d
lea    0xeef(%rip),%r14
lea    0xeec(%rip),%r12
xor    %ebx,%ebx
jmp    11b8 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx,%r15,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     11c9 <main+0x89>
test   $0x7,%bl
jne    11a0 <main+0x60>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <main+0x60>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@main.buf = internal global [4096 x i8] zeroinitializer
@stdin = global i32 0
@.str = [120 x i8] c"/* PD ROM header file - automatically generated from pdrom.bin,\0A * edits will be lost!\0A */\0A\0Aunsigned char pd_rom[]=\0A {\00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [8 x i8] c"0x%02x,\00"
@.str.3 = [7 x i8] c"\0A };\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @stdin
%5 = call i32 @fread(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i32 1, i32 4096, i32 %4)
store i32 %5, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32, i32* %2
%13 = srem i32 %12, 8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %7
27: ; preds = %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@main.buf = internal global [4096 x i8] zeroinitializer
@stdin = global i32 0
@.str = [120 x i8] c"/* PD ROM header file - automatically generated from pdrom.bin,\0A * edits will be lost!\0A */\0A\0Aunsigned char pd_rom[]=\0A {\00"
@.str.1 = [4 x i8] c"\0A \00"
@.str.2 = [8 x i8] c"0x%02x,\00"
@str = [6 x i8] c"\0A };\00"
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @fread(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 0), i32 1, i32 4096, i32 %1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([120 x i8], [120 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %20
5: ; preds = %0
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %13
%8 = phi i64 [ 0, %5 ], [ %18, %13 ]
%9 = and i64 %8, 7
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* @main.buf, i64 0, i64 %8
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %13, %0
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
}