#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*/ CreateImplFile(char *, int, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ CreateInitFile(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_init;
  FILE *fout_impl;
  int numFiles = 0;
  char libName[250];
  char tmpVal[250];
  char *files[4000];
  if (argc < 4) {
    fprintf(stderr, "Usage: %s input_file init_file impl_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;
  }
  if (fscanf(file, "%s", libName) != 1) {
    fprintf(stderr, "Error getting libName\n");
    fclose(file);
    return 1;
  }
  while (fscanf(file, "%s", tmpVal) != EOF) {
    files[numFiles] = strdup(tmpVal);
    numFiles++;
  }
  fclose(file);
  file = NULL;
  fout_init = fopen(argv[2], "w");
  if (!fout_init) {
    return 1;
  }
  fout_impl = fopen(argv[3], "w");
  if (!fout_impl) {
    fclose(fout_init);
    return 1;
  }
  if (strcmp(libName, "vtkCommonCorePython") == 0) {
    files[numFiles] = strdup("mutable");
    numFiles++;
  }
  CreateInitFile(libName, fout_init);
  CreateImplFile(libName, numFiles, files, fout_impl);
  fclose(fout_init);
  fclose(fout_impl);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11d4 <main+0x54>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13be <main+0x23e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe47(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1222 <main+0xa2>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13be <main+0x23e>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xe1b(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
je     126e <main+0xee>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    13be <main+0x23e>
jmp    1273 <main+0xf3>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xdca(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2d57(%rip),%rcx
cmp    (%rcx),%eax
je     12c2 <main+0x142>
lea    -0x230(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
mov    %rcx,-0x7f30(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1273 <main+0xf3>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd87(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1302 <main+0x182>
movl   $0x1,-0x4(%rbp)
jmp    13be <main+0x23e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    133a <main+0x1ba>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    13be <main+0x23e>
lea    -0x130(%rbp),%rdi
lea    0xd23(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    137b <main+0x1fb>
lea    0xd21(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
mov    %rcx,-0x7f30(%rbp,%rax,8)
ff
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <CreateInitFile@plt>
lea    -0x130(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x7f30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <CreateImplFile@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7f30,%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,%r14
cmp    $0x3,%edi
jg     11b1 <main+0x31>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe54(%rip),%rsi
jmp    1305 <main+0x185>
mov    0x8(%r14),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12f1 <main+0x171>
mov    %rax,%r15
lea    0xe7b(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1325 <main+0x1a5>
lea    0xe60(%rip),%rsi
lea    0x100(%rsp),%rdx
mov    %r15,%rdi
call   1060 <fscanf@plt>
mov    0x2de2(%rip),%r13
xor    %ebx,%ebx
cmp    0x0(%r13),%eax
je     1248 <main+0xc8>
xor    %ebx,%ebx
lea    0x100(%rsp),%rbp
lea    0xe30(%rip),%r12
nop
mov    %rbp,%rdi
call   10a0 <strdup@plt>
mov    %rax,0x200(%rsp,%rbx,8)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%r13),%eax
jne    1220 <main+0xa0>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x10(%r14),%rdi
lea    0xe0e(%rip),%rsi
call   1090 <fopen@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1311 <main+0x191>
mov    %rax,%r15
mov    0x18(%r14),%rdi
lea    0xded(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1346 <main+0x1c6>
mov    %rax,%r14
lea    0xdd7(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    12ba <main+0x13a>
lea    0xdd7(%rip),%rdi
call   10a0 <strdup@plt>
mov    %ebx,%ecx
mov    %rax,0x200(%rsp,%rcx,8)
add    $0x1,%ebx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <CreateInitFile@plt>
lea    0x200(%rsp),%rdx
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r14,%rcx
call   1050 <CreateImplFile@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %ebp,%ebp
jmp    1311 <main+0x191>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xd27(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x7f08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
lea    0xd1d(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    130c <main+0x18c>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1311 <main+0x191>

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

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