#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*/ *);
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  FILE *file;
  FILE *fout;
  int numFiles = 0;
  char libName[250];
  char tmpVal[250];
  char *files[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;
  }
  if (fscanf(file, "%s", libName) != 1) {
    fprintf(stderr, "Error getting libName\n");
    fclose(file);
    fclose(fout);
    return 1;
  }
  while (fscanf(file, "%s", tmpVal) != EOF) {
    files[numFiles] = strdup(tmpVal);
    numFiles++;
  }
  fclose(file);
  if (strcmp(libName, "vtkCommonCorePython") == 0) {
    files[numFiles] = strdup("mutable");
    numFiles++;
  }
  CreateInitFile(libName, numFiles, files, 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    11c4 <main+0x54>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <main+0x1f7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1212 <main+0xa2>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <main+0x1f7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124a <main+0xda>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <main+0x1f7>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xded(%rip),%rsi
call   1050 <fscanf@plt>
cmp    $0x1,%eax
je     129f <main+0x12f>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <main+0x1f7>
jmp    12a4 <main+0x134>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xd93(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2d26(%rip),%rcx
cmp    (%rcx),%eax
je     12f3 <main+0x183>
lea    -0x220(%rbp),%rdi
call   1090 <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    12a4 <main+0x134>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x120(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    133d <main+0x1cd>
lea    0xd57(%rip),%rdi
call   1090 <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)
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    $0x7f08,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     11a1 <main+0x31>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe64(%rip),%rsi
jmp    12c1 <main+0x151>
mov    0x8(%rbx),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ad <main+0x13d>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ca <main+0x15a>
mov    %rax,%r14
lea    0xe69(%rip),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
call   1050 <fscanf@plt>
cmp    $0x1,%eax
jne    12cf <main+0x15f>
lea    0xe4e(%rip),%rsi
lea    0x100(%rsp),%rdx
mov    %r15,%rdi
call   1050 <fscanf@plt>
mov    0x2dd6(%rip),%rbp
xor    %ebx,%ebx
cmp    0x0(%rbp),%eax
je     1257 <main+0xe7>
xor    %ebx,%ebx
lea    0x100(%rsp),%r12
lea    0xe1f(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1090 <strdup@plt>
mov    %rax,0x200(%rsp,%rbx,8)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
cmp    0x0(%rbp),%eax
jne    1230 <main+0xc0>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xdfd(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    128c <main+0x11c>
lea    0xdfd(%rip),%rdi
call   1090 <strdup@plt>
mov    %ebx,%ecx
mov    %rax,0x200(%rsp,%rcx,8)
add    $0x1,%ebx
mov    %rsp,%rdi
lea    0x200(%rsp),%rdx
mov    %ebx,%esi
mov    %r14,%rcx
call   1030 <CreateInitFile@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12fb <main+0x18b>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd63(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12f6 <main+0x186>
mov    %r15,%rdi
jmp    12f1 <main+0x181>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x7f08,%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"
@.str.5 = [23 x i8] c"Error getting libName\0A\00"
@EOF = global i32 0
@.str.6 = [20 x i8] c"vtkCommonCorePython\00"
@.str.7 = [8 x i8] c"mutable\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 [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 (i32, i8*, ...) @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 %91
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 (i32, i8*, ...) @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 %91
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 %91
43: ; preds = %33
%44 = load i32*, i32** %6
%45 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%46 = call i32 @fscanf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %45)
%47 = icmp ne i32 %46, 1
br i1 %47, label %48, label %55
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
%53 = load i32*, i32** %7
%54 = call i32 @fclose(i32* %53)
store i32 1, i32* %3
br label %91
55: ; preds = %43
br label %56
56: ; preds = %62, %55
%57 = load i32*, i32** %6
%58 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%59 = call i32 @fscanf(i32* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = load i32, i32* @EOF
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %70
62: ; preds = %56
%63 = getelementptr inbounds [250 x i8], [250 x i8]* %10, i64 0, i64 0
%64 = call i8* @strdup(i8* %63)
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 %66
store i8* %64, i8** %67
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %56
70: ; preds = %56
%71 = load i32*, i32** %6
%72 = call i32 @fclose(i32* %71)
%73 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %83
76: ; preds = %70
%77 = call i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%78 = load i32, i32* %8
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 %79
store i8* %77, i8** %80
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %83
83: ; preds = %76, %70
%84 = getelementptr inbounds [250 x i8], [250 x i8]* %9, i64 0, i64 0
%85 = load i32, i32* %8
%86 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %11, i64 0, i64 0
%87 = load i32*, i32** %7
%88 = call i32 @CreateInitFile(i8* %84, i32 %85, i8** %86, i32* %87)
%89 = load i32*, i32** %7
%90 = call i32 @fclose(i32* %89)
store i32 0, i32* %3
br label %91
91: ; preds = %83, %48, %40, %27, %14
%92 = load i32, i32* %3
ret i32 %92
}

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"
@.str.5 = [23 x i8] c"Error getting libName\0A\00"
@EOF = global i32 0
@.str.6 = [20 x i8] c"vtkCommonCorePython\00"
@.str.7 = [8 x i8] c"mutable\00"
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 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %67
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 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %67
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 %67
30: ; preds = %23
%31 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %52, label %42
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 @fclose(i32* %17)
%41 = call i32 @fclose(i32* %26)
br label %67
42: ; preds = %33, %42
%43 = phi i64 [ %46, %42 ], [ 0, %33 ]
%44 = call i8* @strdup(i8* %7)
%45 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %43
store i8* %44, i8** %45
%46 = add nuw i64 %43, 1
%47 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%48 = load i32, i32* @EOF
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %42
50: ; preds = %42
%51 = trunc i64 %46 to i32
br label %52
52: ; preds = %50, %33
%53 = phi i32 [ 0, %33 ], [ %51, %50 ]
%54 = call i32 @fclose(i32* %17)
%55 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %52
%58 = call dereferenceable_or_null(8) i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%59 = zext i32 %53 to i64
%60 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 %59
store i8* %58, i8** %60
%61 = add nuw nsw i32 %53, 1
br label %62
62: ; preds = %57, %52
%63 = phi i32 [ %61, %57 ], [ %53, %52 ]
%64 = getelementptr inbounds [4000 x i8*], [4000 x i8*]* %5, i64 0, i64 0
%65 = call i32 @CreateInitFile(i8* %6, i32 %63, i8** %64, i32* %26)
%66 = call i32 @fclose(i32* %26)
br label %67
67: ; preds = %62, %37, %28, %19, %10
%68 = phi i32 [ 1, %10 ], [ 1, %37 ], [ 0, %62 ], [ 1, %28 ], [ 1, %19 ]
ret i32 %68
}