#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*/ abort();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ lex_all(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ optarg;
scalar_t__ opterr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *fin = stdin;
  FILE *fout = stdout;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "i:o:")) != -1)
    switch (c) {
    case 'i':
      fin = fopen(optarg, "r");
      break;
    case 'o':
      fout = fopen(optarg, "w");
      break;
    default:
      abort();
    }
  if (opterr != 0)
    return opterr;
  lex_all(fin, fout);
  fclose(fout);
  fclose(fin);
  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)
mov    0x2e73(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e47(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe62(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     121c <main+0xcc>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x69,%eax
je     11d4 <main+0x84>
jmp    11c3 <main+0x73>
mov    -0x28(%rbp),%eax
sub    $0x6f,%eax
je     11f2 <main+0xa2>
jmp    1210 <main+0xc0>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    1217 <main+0xc7>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1217 <main+0xc7>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1190 <main+0x40>
mov    0x2dad(%rip),%rax
cmpq   $0x0,(%rax)
je     123f <main+0xef>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1265 <main+0x115>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <lex_all@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e79(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rsp)
mov    0x2e53(%rip),%rax
mov    (%rax),%r15
mov    0x2e51(%rip),%rax
movq   $0x0,(%rax)
lea    0xe73(%rip),%r12
mov    0x2e64(%rip),%r14
lea    0xe6c(%rip),%r13
jmp    11ae <main+0x5e>
nopl   (%rax)
mov    (%r14),%edi
mov    %r13,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x6f,%eax
je     11a0 <main+0x50>
cmp    $0xffffffff,%eax
je     11df <main+0x8f>
cmp    $0x69,%eax
jne    121e <main+0xce>
mov    (%r14),%edi
lea    0xe31(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,(%rsp)
jmp    11ae <main+0x5e>
mov    0x2dea(%rip),%rax
mov    (%rax),%rax
test   %rax,%rax
jne    120f <main+0xbf>
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <lex_all@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@opterr = global i64 0
@.str = [5 x i8] c"i:o:\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32*, i32** @stdin
store i32* %9, i32** %6
%10 = load i32*, i32** @stdout
store i32* %10, i32** %7
store i64 0, i64* @opterr
br label %11
11: ; preds = %26, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %8
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = load i32, i32* %8
switch i32 %17, label %24 [
i32 105, label %18
i32 111, label %21
]
18: ; preds = %16
%19 = load i32, i32* @optarg
%20 = call i32* @fopen(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
br label %26
21: ; preds = %16
%22 = load i32, i32* @optarg
%23 = call i32* @fopen(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %7
br label %26
24: ; preds = %16
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %21, %18
br label %11
27: ; preds = %11
%28 = load i64, i64* @opterr
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i64, i64* @opterr
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
br label %41
33: ; preds = %27
%34 = load i32*, i32** %6
%35 = load i32*, i32** %7
%36 = call i32 @lex_all(i32* %34, i32* %35)
%37 = load i32*, i32** %7
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
store i32 0, i32* %3
br label %41
41: ; preds = %33, %30
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@opterr = global i64 0
@.str = [5 x i8] c"i:o:\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32*, i32** @stdin
%4 = load i32*, i32** @stdout
store i64 0, i64* @opterr
br label %5
5: ; preds = %11, %2
%6 = phi i32* [ %13, %11 ], [ %3, %2 ]
%7 = phi i32* [ %9, %11 ], [ %4, %2 ]
br label %8
8: ; preds = %5, %14
%9 = phi i32* [ %16, %14 ], [ %7, %5 ]
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %17 [
i32 -1, label %19
i32 105, label %11
i32 111, label %14
]
11: ; preds = %8
%12 = load i32, i32* @optarg
%13 = tail call i32* @fopen(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %5
14: ; preds = %8
%15 = load i32, i32* @optarg
%16 = tail call i32* @fopen(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %8
17: ; preds = %8
%18 = tail call i32 (...) @abort()
unreachable
19: ; preds = %8
%20 = load i64, i64* @opterr
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = trunc i64 %20 to i32
br label %28
24: ; preds = %19
%25 = tail call i32 @lex_all(i32* %6, i32* %9)
%26 = tail call i32 @fclose(i32* %9)
%27 = tail call i32 @fclose(i32* %6)
br label %28
28: ; preds = %24, %22
%29 = phi i32 [ %23, %22 ], [ 0, %24 ]
ret i32 %29
}