#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*/ emit_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int get_err();
int /*<<< orphan*/ io_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ parse_file();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *if_name = argv[1];
  char *of_name = argv[2];
  int ret;
  FILE *fin = fopen(if_name, "r");
  FILE *fout = fopen(of_name, "w");
  if (!fin) {
    fprintf(stderr, "Can't open %s for read.\n", if_name);
    return -1;
  }
  if (!fout) {
    fprintf(stderr, "Can't open %s for write.\n", of_name);
    return -1;
  }
  io_init(fin);
  emit_init(fout);
  parse_file();
  fclose(fin);
  fclose(fout);
  ret = get_err();
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f6 <main+0x86>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe1f(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1261 <main+0xf1>
cmpq   $0x0,-0x38(%rbp)
jne    1226 <main+0xb6>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe08(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1261 <main+0xf1>
mov    -0x30(%rbp),%rdi
call   1060 <io_init@plt>
mov    -0x38(%rbp),%rdi
call   1030 <emit_init@plt>
mov    $0x0,%al
call   1090 <parse_file@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x0,%al
call   1040 <get_err@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%r12
mov    0x10(%rsi),%r15
lea    0xe79(%rip),%rsi
mov    %r12,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe69(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rbx,%rbx
je     11e7 <main+0x77>
mov    %rax,%r14
test   %rax,%rax
je     11fc <main+0x8c>
mov    %rbx,%rdi
call   1060 <io_init@plt>
mov    %r14,%rdi
call   1030 <emit_init@plt>
xor    %eax,%eax
call   1090 <parse_file@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <get_err@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
mov    %r12,%rdx
jmp    120f <main+0x9f>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Can't open %s for read.\0A\00"
@.str.3 = [26 x i8] c"Can't open %s for write.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %6
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i8*, i8** %7
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %10
%21 = load i32*, i32** %9
%22 = icmp ne i32* %21, null
br i1 %22, label %27, label %23
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %6
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 -1, i32* %3
br label %46
27: ; preds = %2
%28 = load i32*, i32** %10
%29 = icmp ne i32* %28, null
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %7
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %32)
store i32 -1, i32* %3
br label %46
34: ; preds = %27
%35 = load i32*, i32** %9
%36 = call i32 @io_init(i32* %35)
%37 = load i32*, i32** %10
%38 = call i32 @emit_init(i32* %37)
%39 = call i32 (...) @parse_file()
%40 = load i32*, i32** %9
%41 = call i32 @fclose(i32* %40)
%42 = load i32*, i32** %10
%43 = call i32 @fclose(i32* %42)
%44 = call i32 (...) @get_err()
store i32 %44, i32* %8
%45 = load i32, i32* %8
store i32 %45, i32* %3
br label %46
46: ; preds = %34, %30, %23
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Can't open %s for read.\0A\00"
@.str.3 = [26 x i8] c"Can't open %s for write.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %7, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %25
13: ; preds = %2
%14 = icmp eq i32* %8, null
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %25
18: ; preds = %13
%19 = tail call i32 @io_init(i32* %7)
%20 = tail call i32 @emit_init(i32* %8)
%21 = tail call i32 (...) @parse_file()
%22 = tail call i32 @fclose(i32* %7)
%23 = tail call i32 @fclose(i32* %8)
%24 = tail call i32 (...) @get_err()
br label %25
25: ; preds = %18, %15, %10
%26 = phi i32 [ %24, %18 ], [ -1, %15 ], [ -1, %10 ]
ret i32 %26
}