#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) {
    fclose(file);
    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    13b8 <main+0x238>
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    13b8 <main+0x238>
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    1270 <main+0xf0>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b8 <main+0x238>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xdc7(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xdb0(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2d43(%rip),%rcx
cmp    (%rcx),%rax
je     1370 <main+0x1f0>
lea    -0x230(%rbp),%rdi
lea    0xd90(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    130a <main+0x18a>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xd6d(%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    136b <main+0x1eb>
lea    -0x230(%rbp),%rdi
lea    0xd3c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1342 <main+0x1c2>
mov    -0x18(%rbp),%rdi
lea    -0x10bd0(%rbp),%rdx
lea    0xd11(%rip),%rsi
call   1060 <fscanf@plt>
jmp    1366 <main+0x1e6>
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    136b <main+0x1eb>
jmp    1287 <main+0x107>
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    128f <main+0x11f>
mov    0x8(%rbx),%rdi
lea    0xe60(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     127b <main+0x10b>
mov    %rax,%r12
mov    0x10(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ab <main+0x13b>
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    12b5 <main+0x145>
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    1299 <main+0x129>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd95(%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
mov    %r12,%rdi
call   1040 <fclose@plt>
jmp    1294 <main+0x124>
xor    %ebp,%ebp
lea    0xd8b(%rip),%r13
lea    0x10(%rsp),%r14
xor    %ebx,%ebx
jmp    12fd <main+0x18d>
nopw   0x0(%rax,%rax,1)
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     1235 <main+0xc5>
mov    0x10(%rsp),%rax
movabs $0x4e4f4953524556,%rcx
cmp    %rcx,%rax
je     1350 <main+0x1e0>
movabs $0x444e414d4d4f43,%rcx
cmp    %rcx,%rax
jne    12d0 <main+0x160>
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    12e6 <main+0x176>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
lea    0x210(%rsp),%rdx
call   1060 <fscanf@plt>
jmp    12e6 <main+0x176>

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 %103
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 %103
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 %47, label %44
44: ; preds = %37
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
store i32 1, i32* %3
br label %103
47: ; preds = %37
%48 = load i32*, i32** %6
%49 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%50 = call i64 @fscanf(i32* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %89, %47
%52 = load i32*, i32** %6
%53 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%54 = call i64 @fscanf(i32* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = load i64, i64* @EOF
%56 = icmp ne i64 %54, %55
br i1 %56, label %57, label %90
57: ; preds = %51
%58 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %72, label %61
61: ; preds = %57
%62 = load i32*, i32** %6
%63 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%64 = call i64 @fscanf(i32* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %63)
%65 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%66 = call i8* @strdup(i8* %65)
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %13, i64 0, i64 %68
store i8* %66, i8** %69
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %89
72: ; preds = %57
%73 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%74 = call i32 @strcmp(i8* %73, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %80, label %76
76: ; preds = %72
%77 = load i32*, i32** %6
%78 = getelementptr inbounds [4000 x i8], [4000 x i8]* %14, i64 0, i64 0
%79 = call i64 @fscanf(i32* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %78)
br label %88
80: ; preds = %72
%81 = getelementptr inbounds [250 x i8], [250 x i8]* %11, i64 0, i64 0
%82 = call i8* @strdup(i8* %81)
%83 = load i32, i32* %8
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %12, i64 0, i64 %84
store i8* %82, i8** %85
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
br label %88
88: ; preds = %80, %76
br label %89
89: ; preds = %88, %61
br label %51
90: ; preds = %51
%91 = load i32*, i32** %6
%92 = call i32 @fclose(i32* %91)
%93 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%94 = load i32, i32* %8
%95 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %12, i64 0, i64 0
%96 = load i32, i32* %9
%97 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %13, i64 0, i64 0
%98 = getelementptr inbounds [4000 x i8], [4000 x i8]* %14, i64 0, i64 0
%99 = load i32*, i32** %7
%100 = call i32 @CreateInitFile(i8* %93, i32 %94, i8** %95, i32 %96, i8** %97, i8* %98, i32* %99)
%101 = load i32*, i32** %7
%102 = call i32 @fclose(i32* %101)
store i32 0, i32* %3
br label %103
103: ; preds = %90, %44, %31, %18
%104 = load i32, i32* %3
ret i32 %104
}

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 %72
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 %72
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 %32, label %34
32: ; preds = %27
%33 = tail call i32 @fclose(i32* %21)
br label %72
34: ; preds = %27
%35 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%36 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%37 = load i64, i64* @EOF
%38 = icmp eq i64 %36, %37
br i1 %38, label %64, label %39
39: ; preds = %34
%40 = bitcast [250 x i8]* %4 to i64*
br label %41
41: ; preds = %39, %58
%42 = phi i32 [ 0, %39 ], [ %60, %58 ]
%43 = phi i32 [ 0, %39 ], [ %59, %58 ]
%44 = load i64, i64* %40
switch i64 %44, label %53 [
i64 19226340793077571, label %45
i64 22042224532538710, label %51
]
45: ; preds = %41
%46 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%47 = call i8* @strdup(i8* %9)
%48 = sext i32 %42 to i64
%49 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %6, i64 0, i64 %48
store i8* %47, i8** %49
%50 = add nsw i32 %42, 1
br label %58
51: ; preds = %41
%52 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %58
53: ; preds = %41
%54 = call i8* @strdup(i8* %9)
%55 = sext i32 %43 to i64
%56 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %55
store i8* %54, i8** %56
%57 = add nsw i32 %43, 1
br label %58
58: ; preds = %51, %53, %45
%59 = phi i32 [ %57, %53 ], [ %43, %51 ], [ %43, %45 ]
%60 = phi i32 [ %42, %53 ], [ %42, %51 ], [ %50, %45 ]
%61 = call i64 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%62 = load i64, i64* @EOF
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %41
64: ; preds = %58, %34
%65 = phi i32 [ 0, %34 ], [ %59, %58 ]
%66 = phi i32 [ 0, %34 ], [ %60, %58 ]
%67 = call i32 @fclose(i32* %21)
%68 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 0
%69 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %6, i64 0, i64 0
%70 = call i32 @CreateInitFile(i8* %8, i32 %65, i8** %68, i32 %66, i8** %69, i8* %12, i32* %30)
%71 = call i32 @fclose(i32* %30)
br label %72
72: ; preds = %64, %32, %23, %14
%73 = phi i32 [ 1, %14 ], [ 0, %64 ], [ 1, %32 ], [ 1, %23 ]
ret i32 %73
}