#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) {
    fclose(file);
    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    12d0 <main+0x170>
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    12d0 <main+0x170>
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    1236 <main+0xd6>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d0 <main+0x170>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe01(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xdea(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2d7d(%rip),%rcx
cmp    (%rcx),%rax
je     129d <main+0x13d>
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    124d <main+0xed>
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     12ac <main+0x14c>
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
mov    %r12,%rdi
call   1040 <fclose@plt>
jmp    1291 <main+0x131>

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 %71
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 %71
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 %43, label %40
40: ; preds = %33
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
store i32 1, i32* %3
br label %71
43: ; preds = %33
%44 = load i32*, i32** %6
%45 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%46 = call i64 @fscanf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %53, %43
%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)
%51 = load i64, i64* @EOF
%52 = icmp ne i64 %50, %51
br i1 %52, label %53, label %61
53: ; preds = %47
%54 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%55 = call i8* @strdup(i8* %54)
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 %57
store i8* %55, i8** %58
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %47
61: ; preds = %47
%62 = load i32*, i32** %6
%63 = call i32 @fclose(i32* %62)
%64 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%65 = load i32, i32* %8
%66 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 0
%67 = load i32*, i32** %7
%68 = call i32 @CreateInitFile(i8* %64, i32 %65, i8** %66, i32* %67)
%69 = load i32*, i32** %7
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %3
br label %71
71: ; preds = %61, %40, %27, %14
%72 = load i32, i32* %3
ret i32 %72
}

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 %51
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 %51
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 %28, label %30
28: ; preds = %23
%29 = tail call i32 @fclose(i32* %17)
br label %51
30: ; preds = %23
%31 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%32 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %45, label %35
35: ; preds = %30, %35
%36 = phi i64 [ %39, %35 ], [ 0, %30 ]
%37 = call i8* @strdup(i8* %7)
%38 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %36
store i8* %37, i8** %38
%39 = add nuw i64 %36, 1
%40 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %35
43: ; preds = %35
%44 = trunc i64 %39 to i32
br label %45
45: ; preds = %43, %30
%46 = phi i32 [ 0, %30 ], [ %44, %43 ]
%47 = call i32 @fclose(i32* %17)
%48 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 0
%49 = call i32 @CreateInitFile(i8* %6, i32 %46, i8** %48, i32* %26)
%50 = call i32 @fclose(i32* %26)
br label %51
51: ; preds = %45, %28, %19, %10
%52 = phi i32 [ 1, %10 ], [ 0, %45 ], [ 1, %28 ], [ 1, %19 ]
ret i32 %52
}