#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 */

/* Variables and functions */
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ yyparse();
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("need filename\n");
    return 1;
  }
  if (argc > 2) {
    printf("only ONE file required\n");
    return 1;
  }
  freopen(argv[1], "r", stdin);
  yyparse();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1168 <main+0x38>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <main+0x85>
cmpl   $0x2,-0x8(%rbp)
jle    118a <main+0x5a>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
lea    0xe85(%rip),%rsi
call   1050 <freopen@plt>
mov    $0x0,%al
call   1030 <yyparse@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     113f <main+0xf>
lea    0xedc(%rip),%rdi
jmp    116f <main+0x3f>
cmp    $0x2,%edi
jne    1168 <main+0x38>
mov    0x8(%rsi),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
lea    0xea8(%rip),%rsi
call   1050 <freopen@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <yyparse@plt>
jmp    1179 <main+0x49>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"need filename\0A\00"
@.str.1 = [24 x i8] c"only ONE file required\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %22
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %22
15: ; preds = %10
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @stdin
%20 = call i32 @freopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 (...) @yyparse()
store i32 0, i32* %3
br label %22
22: ; preds = %15, %13, %8
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@str = [23 x i8] c"only ONE file required\00"
@str.3 = [14 x i8] c"need filename\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %16
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %16
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @stdin
%14 = tail call i32 @freopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = tail call i32 (...) @yyparse()
br label %16
16: ; preds = %10, %8, %4
%17 = phi i32 [ 1, %4 ], [ 1, %8 ], [ 0, %10 ]
ret i32 %17
}