#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*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
char *strchr(char *, char);
int main(void) {
  FILE *fp = stdin;
  char buf[256], *p;
  int line;
  printf("static const char *gamefile_data[] = {\n");
  line = 0;
  while (fgets(buf, 256, fp)) {
    ++line;
    p = strchr(buf, '\n');
    if (!p) {
      fprintf(stderr, "Too long line: %d\n", line);
      exit(1);
    }
    *p = 0;
    if (*buf == '#' || *buf == 0)
      continue;
    printf("\t\"%s\\n\",\n", buf);
  }
  printf("\t0,\n};\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x11c(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     124a <main+0xfa>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    1201 <main+0xb1>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
mov    -0x11c(%rbp),%edx
lea    0xe36(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x118(%rbp),%rax
movb   $0x0,(%rax)
movsbl -0x110(%rbp),%eax
cmp    $0x23,%eax
je     122b <main+0xdb>
movsbl -0x110(%rbp),%eax
cmp    $0x0,%eax
jne    1230 <main+0xe0>
jmp    1188 <main+0x38>
lea    -0x110(%rbp),%rsi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1188 <main+0x38>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%r14
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11f8 <main+0x98>
mov    $0x1,%ebp
mov    %rsp,%rbx
lea    0xe6c(%rip),%r15
jmp    11c8 <main+0x68>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     11f8 <main+0x98>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1214 <main+0xb4>
movb   $0x0,(%rax)
movzbl (%rsp),%eax
test   %al,%al
je     11b0 <main+0x50>
cmp    $0x23,%al
je     11b0 <main+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x50>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    %ebp,%edx
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [40 x i8] c"static const char *gamefile_data[] = {\0A\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Too long line: %d\0A\00"
@.str.2 = [10 x i8] c"\09\22%s\\n\22,\0A\00"
@.str.3 = [8 x i8] c"\090,\0A};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32*, i32** @stdin
store i32* %6, i32** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %37, %36, %0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i64 @fgets(i8* %9, i32 256, i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %8
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i8* @strchr(i8* %16, i8 signext 10)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %25, label %20
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = load i32, i32* %5
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = load i8*, i8** %4
store i8 0, i8* %26
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 35
br i1 %30, label %36, label %31
31: ; preds = %25
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31, %25
br label %8
37: ; preds = %31
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %8
40: ; preds = %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@stderr = global i32 0
@.str.1 = [19 x i8] c"Too long line: %d\0A\00"
@.str.2 = [10 x i8] c"\09\22%s\\n\22,\0A\00"
@str = [39 x i8] c"static const char *gamefile_data[] = {\00"
@str.4 = [7 x i8] c"\090,\0A};\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = load i32*, i32** @stdin
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%5 = call i64 @fgets(i8* %3, i32 256, i32* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %0, %20
%8 = phi i32 [ %9, %20 ], [ 0, %0 ]
%9 = add nuw nsw i32 %8, 1
%10 = call i8* @strchr(i8* %3, i8 signext 10)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %7
store i8 0, i8* %10
%17 = load i8, i8* %3
switch i8 %17, label %18 [
i8 35, label %20
i8 0, label %20
]
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %20
20: ; preds = %18, %16, %16
%21 = call i64 @fgets(i8* %3, i32 256, i32* %2)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %7
23: ; preds = %20, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}