#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*/ CreateInitFile(char *, int, char **, int, char **, char *,
                                  int /*<<< orphan*/ *);
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  FILE *file;
  FILE *fout;
  int numConcrete = 0;
  int numCommands = 0;
  char libName[250];
  char tmpVal[250];
  char *concrete[4000];
  char *commands[4000];
  char version[4000] = {'\0'};
  if (argc < 3) {
    fprintf(stderr, "Usage: %s input_file output_file\n", argv[0]);
    return 1;
  }
  file = fopen(argv[1], "r");
  if (!file) {
    fprintf(stderr, "Input file %s could not be opened\n", argv[1]);
    return 1;
  }
  fout = fopen(argv[2], "w");
  if (!fout) {
    return 1;
  }
  fscanf(file, "%s", libName);
  while (fscanf(file, "%s", tmpVal) != EOF) {
    if (!strcmp(tmpVal, "COMMAND")) {
      fscanf(file, "%s", tmpVal);
      commands[numCommands] = strdup(tmpVal);
      numCommands++;
    } else if (!strcmp(tmpVal, "VERSION")) {
      fscanf(file, "%s", version);
    } else {
      concrete[numConcrete] = strdup(tmpVal);
      numConcrete++;
    }
  }
  fclose(file);
  CreateInitFile(libName, numConcrete, concrete, numCommands, commands, version,
                 fout);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10be0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x10bd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11ec <main+0x6c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe25(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13af <main+0x22f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe27(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1238 <main+0xb8>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfd(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13af <main+0x22f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe00(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1267 <main+0xe7>
movl   $0x1,-0x4(%rbp)
jmp    13af <main+0x22f>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xdd0(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xdb9(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2d4c(%rip),%rcx
cmp    (%rcx),%rax
je     1367 <main+0x1e7>
lea    -0x230(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1301 <main+0x181>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xd76(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x230(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rcx
movslq -0x28(%rbp),%rax
mov    %rcx,-0xfc30(%rbp,%rax,8)
ff
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1362 <main+0x1e2>
lea    -0x230(%rbp),%rdi
lea    0xd45(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1339 <main+0x1b9>
mov    -0x18(%rbp),%rdi
lea    -0x10bd0(%rbp),%rdx
lea    0xd1a(%rip),%rsi
call   1060 <fscanf@plt>
jmp    135d <main+0x1dd>
lea    -0x230(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
mov    %rcx,-0x7f30(%rbp,%rax,8)
ff
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1362 <main+0x1e2>
jmp    127e <main+0xfe>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x130(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x7f30(%rbp),%rdx
mov    -0x28(%rbp),%ecx
lea    -0xfc30(%rbp),%r8
lea    -0x10bd0(%rbp),%r9
mov    -0x20(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <CreateInitFile@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10be0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10bb8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x210(%rsp),%rdi
mov    $0xfa0,%edx
xor    %esi,%esi
call   1050 <memset@plt>
cmp    $0x2,%ebp
jg     11b7 <main+0x47>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe4e(%rip),%rsi
jmp    128b <main+0x11b>
mov    0x8(%rbx),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1277 <main+0x107>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1290 <main+0x120>
mov    %rax,0x8(%rsp)
lea    0xe51(%rip),%rbx
lea    0x110(%rsp),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <fscanf@plt>
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <fscanf@plt>
mov    0x2dc6(%rip),%r15
mov    $0x0,%ebx
mov    $0x0,%ebp
cmp    (%r15),%rax
jne    12a7 <main+0x137>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%r14
mov    %r14,(%rsp)
lea    0x110(%rsp),%rdi
lea    0x8eb0(%rsp),%rdx
lea    0x11b0(%rsp),%r8
lea    0x210(%rsp),%r9
mov    %ebx,%esi
mov    %ebp,%ecx
call   1030 <CreateInitFile@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1295 <main+0x125>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd99(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%eax
add    $0x10bb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0xd99(%rip),%r13
lea    0x10(%rsp),%r14
xor    %ebx,%ebx
jmp    12ed <main+0x17d>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1090 <strdup@plt>
movslq %ebx,%rbx
mov    %rax,0x8eb0(%rsp,%rbx,8)
add    $0x1,%ebx
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <fscanf@plt>
cmp    (%r15),%rax
je     1231 <main+0xc1>
mov    0x10(%rsp),%rax
movabs $0x4e4f4953524556,%rcx
cmp    %rcx,%rax
je     1340 <main+0x1d0>
movabs $0x444e414d4d4f43,%rcx
cmp    %rcx,%rax
jne    12c0 <main+0x150>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <fscanf@plt>
mov    %r14,%rdi
call   1090 <strdup@plt>
movslq %ebp,%rbp
mov    %rax,0x11b0(%rsp,%rbp,8)
add    $0x1,%ebp
jmp    12d6 <main+0x166>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
lea    0x210(%rsp),%rdx
call   1060 <fscanf@plt>
jmp    12d6 <main+0x166>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s input_file output_file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Input file %s could not be opened\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.5 = [8 x i8] c"COMMAND\00"
@.str.6 = [8 x i8] c"VERSION\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
%9 = alloca i32
%10 = alloca [250 x i8]
%11 = alloca [250 x i8]
%12 = alloca [4000 x i8*]
%13 = alloca [4000 x i8*]
%14 = alloca [4000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%15 = bitcast [4000 x i8]* %14 to i8*
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 1, i32* %3
br label %101
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %6
%29 = load i32*, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %37, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store i32 1, i32* %3
br label %101
37: ; preds = %24
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %7
%42 = load i32*, i32** %7
%43 = icmp ne i32* %42, null
br i1 %43, label %45, label %44
44: ; preds = %37
store i32 1, i32* %3
br label %101
45: ; preds = %37
%46 = load i32*, i32** %6
%47 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%48 = call i64 @fscanf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %87, %45
%50 = load i32*, i32** %6
%51 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%52 = call i64 @fscanf(i32* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %51)
%53 = load i64, i64* @EOF
%54 = icmp ne i64 %52, %53
br i1 %54, label %55, label %88
55: ; preds = %49
%56 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%57 = call i32 @strcmp(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp ne i32 %57, 0
br i1 %58, label %70, label %59
59: ; preds = %55
%60 = load i32*, i32** %6
%61 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%62 = call i64 @fscanf(i32* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %61)
%63 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%64 = call i8* @strdup(i8* %63)
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %13, i64 0, i64 %66
store i8* %64, i8** %67
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %87
70: ; preds = %55
%71 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%72 = call i32 @strcmp(i8* %71, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%73 = icmp ne i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %70
%75 = load i32*, i32** %6
%76 = getelementptr inbounds [4000 x i8], [4000 x i8]* %14, i64 0, i64 0
%77 = call i64 @fscanf(i32* %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %76)
br label %86
78: ; preds = %70
%79 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%80 = call i8* @strdup(i8* %79)
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %12, i64 0, i64 %82
store i8* %80, i8** %83
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %86
86: ; preds = %78, %74
br label %87
87: ; preds = %86, %59
br label %49
88: ; preds = %49
%89 = load i32*, i32** %6
%90 = call i32 @fclose(i32* %89)
%91 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%92 = load i32, i32* %8
%93 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %12, i64 0, i64 0
%94 = load i32, i32* %9
%95 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %13, i64 0, i64 0
%96 = getelementptr inbounds [4000 x i8], [4000 x i8]* %14, i64 0, i64 0
%97 = load i32*, i32** %7
%98 = call i32 @CreateInitFile(i8* %91, i32 %92, i8** %93, i32 %94, i8** %95, i8* %96, i32* %97)
%99 = load i32*, i32** %7
%100 = call i32 @fclose(i32* %99)
store i32 0, i32* %3
br label %101
101: ; preds = %88, %44, %31, %18
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s input_file output_file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Input file %s could not be opened\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [250 x i8]
%4 = alloca [250 x i8]
%5 = alloca [4000 x i8*]
%6 = alloca [4000 x i8*]
%7 = alloca [4000 x i8]
%8 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 0
%10 = bitcast [4000 x i8*]* %5 to i8*
%11 = bitcast [4000 x i8*]* %6 to i8*
%12 = getelementptr inbounds [4000 x i8], [4000 x i8]* %7, i64 0, i64 0
%13 = icmp slt i32 %0, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %70
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %19
%26 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %70
27: ; preds = %18
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %70, label %32
32: ; preds = %27
%33 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%34 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %62, label %37
37: ; preds = %32
%38 = bitcast [250 x i8]* %4 to i64*
br label %39
39: ; preds = %37, %56
%40 = phi i32 [ 0, %37 ], [ %58, %56 ]
%41 = phi i32 [ 0, %37 ], [ %57, %56 ]
%42 = load i64, i64* %38
switch i64 %42, label %51 [
i64 19226340793077571, label %43
i64 22042224532538710, label %49
]
43: ; preds = %39
%44 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%45 = call i8* @strdup(i8* %9)
%46 = sext i32 %40 to i64
%47 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %6, i64 0, i64 %46
store i8* %45, i8** %47
%48 = add nsw i32 %40, 1
br label %56
49: ; preds = %39
%50 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %56
51: ; preds = %39
%52 = call i8* @strdup(i8* %9)
%53 = sext i32 %41 to i64
%54 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %53
store i8* %52, i8** %54
%55 = add nsw i32 %41, 1
br label %56
56: ; preds = %49, %51, %43
%57 = phi i32 [ %55, %51 ], [ %41, %49 ], [ %41, %43 ]
%58 = phi i32 [ %40, %51 ], [ %40, %49 ], [ %48, %43 ]
%59 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%60 = load i64, i64* @EOF
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %39
62: ; preds = %56, %32
%63 = phi i32 [ 0, %32 ], [ %57, %56 ]
%64 = phi i32 [ 0, %32 ], [ %58, %56 ]
%65 = call i32 @fclose(i32* %21)
%66 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 0
%67 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %6, i64 0, i64 0
%68 = call i32 @CreateInitFile(i8* %8, i32 %63, i8** %66, i32 %64, i8** %67, i8* %12, i32* %30)
%69 = call i32 @fclose(i32* %30)
br label %70
70: ; preds = %27, %62, %23, %14
%71 = phi i32 [ 1, %14 ], [ 0, %62 ], [ 1, %23 ], [ 1, %27 ]
ret i32 %71
}