#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 atoi(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
char *strchr(char *, char);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *inputFile = NULL;
  FILE *outputFile = NULL;
  char sBuffer[80];
  char *pch;
  char *newline, *endBracket;
  int i;
  if (argc != 3) {
    printf("%s %s %s\n", "Usage:", argv[0], "<header> <output>");
    return 1;
  }
  inputFile = fopen(argv[1], "r");
  if (inputFile == NULL) {
    printf("%s %s\n", "Unable to open input header:", argv[1]);
    return 1;
  }
  outputFile = fopen(argv[2], "wb");
  if (outputFile == NULL) {
    printf("%s %s\n", "Unable to open output file:", argv[2]);
    return 1;
  }
  for (i = 0; i < 4; i++) {
    fgets(sBuffer, 80, inputFile);
  }
  while (fgets(sBuffer, 80, inputFile)) {
    newline = strchr(sBuffer, '\n');
    if (newline) {
      *newline = 0;
    }
    endBracket = strchr(sBuffer, '}');
    if (endBracket) {
      continue;
    }
    pch = strtok(sBuffer, ",");
    while (pch != NULL) {
      fprintf(outputFile, "%c", atoi(pch));
      pch = strtok(NULL, ",");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11d2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4f(%rip),%rdi
lea    0xe52(%rip),%rsi
lea    0xe52(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x211>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe42(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121e <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdff(%rip),%rdi
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x211>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe15(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    126a <main+0xfa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdb3(%rip),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1381 <main+0x211>
movl   $0x0,-0x8c(%rbp)
cmpl   $0x4,-0x8c(%rbp)
jge    12a7 <main+0x137>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1274 <main+0x104>
jmp    12ac <main+0x13c>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     137a <main+0x20a>
lea    -0x70(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     12ec <main+0x17c>
mov    -0x80(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x70(%rbp),%rdi
mov    $0x7d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1314 <main+0x1a4>
jmp    12ac <main+0x13c>
lea    -0x70(%rbp),%rdi
lea    0xd42(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1375 <main+0x205>
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x78(%rbp),%rdi
call   1090 <atoi@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%edx
lea    0xd0c(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcfa(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x78(%rbp)
jmp    1328 <main+0x1b8>
jmp    12ac <main+0x13c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jne    1293 <main+0x123>
mov    0x8(%r15),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12b8 <main+0x148>
mov    %rax,%r14
mov    0x10(%r15),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12cc <main+0x15c>
mov    %rax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b4 <main+0x144>
mov    %rsp,%r15
lea    0xe3c(%rip),%r12
jmp    1245 <main+0xd5>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12b4 <main+0x144>
mov    %r15,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     125a <main+0xea>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    $0x7d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1230 <main+0xc0>
mov    %r15,%rdi
nop
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     1230 <main+0xc0>
mov    %rax,%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
xor    %edi,%edi
jmp    1270 <main+0x100>
mov    (%r15),%rdx
lea    0xd63(%rip),%rdi
lea    0xd66(%rip),%rsi
lea    0xd66(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12e5 <main+0x175>
xor    %eax,%eax
jmp    12ea <main+0x17a>
mov    0x8(%r15),%rdx
lea    0xd40(%rip),%rdi
lea    0xd5b(%rip),%rsi
jmp    12de <main+0x16e>
mov    0x10(%r15),%rdx
lea    0xd2c(%rip),%rdi
lea    0xd67(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s %s %s\0A\00"
@.str.1 = [7 x i8] c"Usage:\00"
@.str.2 = [18 x i8] c"<header> <output>\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
@.str.5 = [29 x i8] c"Unable to open input header:\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [28 x i8] c"Unable to open output file:\00"
@.str.8 = [2 x i8] c",\00"
@.str.9 = [3 x i8] c"%c\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 [80 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %88
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %88
32: ; preds = %20
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %36, i32** %7
%37 = load i32*, i32** %7
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %32
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %42)
store i32 1, i32* %3
br label %88
44: ; preds = %32
store i32 0, i32* %12
br label %45
45: ; preds = %52, %44
%46 = load i32, i32* %12
%47 = icmp slt i32 %46, 4
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%50 = load i32*, i32** %6
%51 = call i64 @fgets(i8* %49, i32 80, i32* %50)
br label %52
52: ; preds = %48
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
store i32 %54, i32* %12
br label %45
55: ; preds = %45
br label %56
56: ; preds = %86, %73, %55
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%58 = load i32*, i32** %6
%59 = call i64 @fgets(i8* %57, i32 80, i32* %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %87
61: ; preds = %56
%62 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%63 = call i8* @strchr(i8* %62, i8 signext 10)
store i8* %63, i8** %10
%64 = load i8*, i8** %10
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = load i8*, i8** %10
store i8 0, i8* %67
br label %68
68: ; preds = %66, %61
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%70 = call i8* @strchr(i8* %69, i8 signext 125)
store i8* %70, i8** %11
%71 = load i8*, i8** %11
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %74
73: ; preds = %68
br label %56
74: ; preds = %68
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%76 = call i8* @strtok(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i8* %76, i8** %9
br label %77
77: ; preds = %80, %74
%78 = load i8*, i8** %9
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %86
80: ; preds = %77
%81 = load i32*, i32** %7
%82 = load i8*, i8** %9
%83 = call i32 @atoi(i8* %82)
%84 = call i32 @fprintf(i32* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %83)
%85 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i8* %85, i8** %9
br label %77
86: ; preds = %77
br label %56
87: ; preds = %56
store i32 0, i32* %3
br label %88
88: ; preds = %87, %39, %27, %15
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s %s %s\0A\00"
@.str.1 = [7 x i8] c"Usage:\00"
@.str.2 = [18 x i8] c"<header> <output>\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
@.str.5 = [29 x i8] c"Unable to open input header:\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [28 x i8] c"Unable to open output file:\00"
@.str.8 = [2 x i8] c",\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %51
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %15)
br label %51
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %29, label %22
22: ; preds = %17
%23 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%24 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%25 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%26 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%27 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%28 = icmp eq i64 %27, 0
br i1 %28, label %51, label %32
29: ; preds = %17
%30 = load i8*, i8** %18
%31 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %30)
br label %51
32: ; preds = %22, %39
%33 = call i8* @strchr(i8* %4, i8 signext 10)
%34 = icmp eq i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %32
store i8 0, i8* %33
br label %36
36: ; preds = %35, %32
%37 = call i8* @strchr(i8* %4, i8 signext 125)
%38 = icmp eq i8* %37, null
br i1 %38, label %42, label %39
39: ; preds = %45, %42, %36
%40 = call i64 @fgets(i8* %4, i32 80, i32* %12)
%41 = icmp eq i64 %40, 0
br i1 %41, label %51, label %32
42: ; preds = %36
%43 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %39, label %45
45: ; preds = %42, %45
%46 = phi i8* [ %49, %45 ], [ %43, %42 ]
%47 = call i32 @atoi(i8* %46)
%48 = call i32 @fputc(i32 %47, i32* %20)
%49 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp eq i8* %49, null
br i1 %50, label %39, label %45
51: ; preds = %39, %22, %29, %14, %6
%52 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 1, %29 ], [ 0, %22 ], [ 0, %39 ]
ret i32 %52
}