#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 /*<<< 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;
char *strdup(char *);
int main(int argc, char *argv[]) {
  FILE *file;
  FILE *fout;
  int numConcrete = 0;
  char libName[250];
  char tmpVal[250];
  char *concrete[4000];
  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) {
    concrete[numConcrete] = strdup(tmpVal);
    numConcrete++;
  }
  fclose(file);
  CreateInitFile(libName, numConcrete, concrete, fout);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11b2 <main+0x52>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5f(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c7 <main+0x167>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fe <main+0x9e>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe37(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c7 <main+0x167>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122d <main+0xcd>
movl   $0x1,-0x4(%rbp)
jmp    12c7 <main+0x167>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe0a(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xdf3(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2d86(%rip),%rcx
cmp    (%rcx),%rax
je     1294 <main+0x134>
lea    -0x220(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
mov    %rcx,-0x7f20(%rbp,%rax,8)
ff
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1244 <main+0xe4>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x120(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x7f20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <CreateInitFile@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7f20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f18,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jg     1192 <main+0x32>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe73(%rip),%rsi
jmp    128c <main+0x12c>
mov    0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1278 <main+0x118>
mov    %rax,%r12
mov    0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1291 <main+0x131>
mov    %rax,%rbx
lea    0xe78(%rip),%rbp
lea    0x110(%rsp),%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <fscanf@plt>
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <fscanf@plt>
mov    0x2ded(%rip),%r14
xor    %r15d,%r15d
mov    $0x0,%ebp
cmp    (%r14),%rax
je     124c <main+0xec>
mov    %rbx,0x8(%rsp)
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
lea    0xe2e(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <strdup@plt>
mov    %rax,0x210(%rsp,%rbp,8)
add    $0x1,%rbp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
cmp    (%r14),%rax
jne    1220 <main+0xc0>
mov    0x8(%rsp),%rbx
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0x110(%rsp),%rdi
lea    0x210(%rsp),%rdx
mov    %ebp,%esi
mov    %rbx,%rcx
call   1030 <CreateInitFile@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1297 <main+0x137>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xd98(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x7f18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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
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 [250 x i8]
%10 = alloca [250 x i8]
%11 = alloca [4000 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %69
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.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %33, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %31)
store i32 1, i32* %3
br label %69
33: ; preds = %20
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %37, i32** %7
%38 = load i32*, i32** %7
%39 = icmp ne i32* %38, null
br i1 %39, label %41, label %40
40: ; preds = %33
store i32 1, i32* %3
br label %69
41: ; preds = %33
%42 = load i32*, i32** %6
%43 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%44 = call i64 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %51, %41
%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)
%49 = load i64, i64* @EOF
%50 = icmp ne i64 %48, %49
br i1 %50, label %51, label %59
51: ; preds = %45
%52 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%53 = call i8* @strdup(i8* %52)
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 %55
store i8* %53, i8** %56
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %45
59: ; preds = %45
%60 = load i32*, i32** %6
%61 = call i32 @fclose(i32* %60)
%62 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%63 = load i32, i32* %8
%64 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 0
%65 = load i32*, i32** %7
%66 = call i32 @CreateInitFile(i8* %62, i32 %63, i8** %64, i32* %65)
%67 = load i32*, i32** %7
%68 = call i32 @fclose(i32* %67)
store i32 0, i32* %3
br label %69
69: ; preds = %59, %40, %27, %14
%70 = load i32, i32* %3
ret i32 %70
}

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 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 0
%8 = bitcast [4000 x i8*]* %5 to i8*
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %49
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %49
23: ; preds = %14
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %49, label %28
28: ; preds = %23
%29 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%30 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %43, label %33
33: ; preds = %28, %33
%34 = phi i64 [ %37, %33 ], [ 0, %28 ]
%35 = call i8* @strdup(i8* %7)
%36 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %34
store i8* %35, i8** %36
%37 = add nuw i64 %34, 1
%38 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%39 = load i64, i64* @EOF
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %33
41: ; preds = %33
%42 = trunc i64 %37 to i32
br label %43
43: ; preds = %41, %28
%44 = phi i32 [ 0, %28 ], [ %42, %41 ]
%45 = call i32 @fclose(i32* %17)
%46 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 0
%47 = call i32 @CreateInitFile(i8* %6, i32 %44, i8** %46, i32* %26)
%48 = call i32 @fclose(i32* %26)
br label %49
49: ; preds = %23, %43, %19, %10
%50 = phi i32 [ 1, %10 ], [ 0, %43 ], [ 1, %19 ], [ 1, %23 ]
ret i32 %50
}