#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 */
int EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int b;
  int first = 1;
  int count = 0;
  printf("const byte ROMImage[4096] PROGMEM = {");
  while ((b = getchar()) != EOF) {
    if (!first) {
      printf(", ");
    } else {
      first = 0;
    }
    if ((count & 0x0f) == 0) {
      printf("\n\t\t");
    }
    printf("0x%02x", b);
    count++;
  }
  printf("\n};\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
je     11cb <main+0xab>
cmpl   $0x0,-0x18(%rbp)
jne    1188 <main+0x68>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <main+0x6f>
movl   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11ac <main+0x8c>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <main+0x32>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e91(%rip),%r12
cmp    (%r12),%eax
je     118a <main+0x5a>
mov    %eax,%ebx
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r12),%eax
jne    11a7 <main+0x77>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe71(%rip),%r15
lea    0xe6d(%rip),%r14
lea    0xe6a(%rip),%r13
jmp    11ee <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     118a <main+0x5a>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0xf,%bl
jne    11d0 <main+0xa0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d0 <main+0xa0>

LLVM IR (-O0):
@.str = [38 x i8] c"const byte ROMImage[4096] PROGMEM = {\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c", \00"
@.str.2 = [4 x i8] c"\0A\09\09\00"
@.str.3 = [7 x i8] c"0x%02x\00"
@.str.4 = [6 x i8] c"\0A};\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %26, %2
%11 = call i32 (...) @getchar()
store i32 %11, i32* %6
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %20
19: ; preds = %14
store i32 0, i32* %7
br label %20
20: ; preds = %19, %17
%21 = load i32, i32* %8
%22 = and i32 %21, 15
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %10
31: ; preds = %10
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [38 x i8] c"const byte ROMImage[4096] PROGMEM = {\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c", \00"
@.str.2 = [4 x i8] c"\0A\09\09\00"
@.str.3 = [7 x i8] c"0x%02x\00"
@str = [5 x i8] c"\0A};\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %27, label %7
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %4)
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %27, label %13
13: ; preds = %7, %21
%14 = phi i32 [ %24, %21 ], [ %10, %7 ]
%15 = phi i32 [ %23, %21 ], [ 1, %7 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = and i32 %15, 15
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%23 = add nuw nsw i32 %15, 1
%24 = tail call i32 (...) @getchar()
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %13
27: ; preds = %21, %7, %2
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}