#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*/ *fopen(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ parse(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
char *strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *in;
  FILE *out;
  if (argc > 2) {
    char *filename = (char *)malloc(500 * sizeof(char));
    filename = strncpy(filename, argv[1], 500);
    in = fopen(filename, "r");
    filename = strncpy(filename, argv[2], 500);
    out = fopen(filename, "w");
  } else {
    in = stdin;
    out = stdout;
  }
  parse(in, out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11cf <main+0x8f>
mov    $0x1f4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    11eb <main+0xab>
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <parse@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jl     11a2 <main+0x62>
mov    %rsi,%r15
mov    $0x1f4,%edi
call   1040 <malloc@plt>
mov    0x8(%r15),%rsi
mov    %rax,%rdi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
mov    %rax,%rbx
lea    0xe8e(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    0x10(%r15),%rsi
mov    %rbx,%rdi
mov    $0x1f4,%edx
call   1030 <strncpy@plt>
lea    0xe6d(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
mov    %rax,%rsi
jmp    11b6 <main+0x76>
mov    0x2e3f(%rip),%rax
mov    (%rax),%r14
mov    0x2e25(%rip),%rax
mov    (%rax),%rsi
mov    %r14,%rdi
call   1060 <parse@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32* null
@stdout = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %28
11: ; preds = %2
%12 = call i64 @malloc(i32 500)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i8* @strncpy(i8* %14, i8* %17, i32 500)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i8*, i8** %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i8* @strncpy(i8* %21, i8* %24, i32 500)
store i8* %25, i8** %8
%26 = load i8*, i8** %8
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %7
br label %31
28: ; preds = %2
%29 = load i32*, i32** @stdin
store i32* %29, i32** %6
%30 = load i32*, i32** @stdout
store i32* %30, i32** %7
br label %31
31: ; preds = %28, %11
%32 = load i32*, i32** %6
%33 = load i32*, i32** %7
%34 = call i32 @parse(i32* %32, i32* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@stdin = global i32* null
@stdout = global i32* null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = tail call i64 @malloc(i32 500)
%6 = inttoptr i64 %5 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i8* @strncpy(i8* %6, i8* %8, i32 500)
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i8* @strncpy(i8* %9, i8* %12, i32 500)
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %18
15: ; preds = %2
%16 = load i32*, i32** @stdin
%17 = load i32*, i32** @stdout
br label %18
18: ; preds = %15, %4
%19 = phi i32* [ %14, %4 ], [ %17, %15 ]
%20 = phi i32* [ %10, %4 ], [ %16, %15 ]
%21 = tail call i32 @parse(i32* %20, i32* %19)
ret i32 0
}