#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ trans(int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc == 2) {
    FILE *in = fopen(argv[1], "r");
    if (in == 0) {
      fprintf(stderr, "can not open %s\n", argv[1]);
      exit(1);
    }
    trans(in, stdout);
    fclose(in);
  } else {
    trans(stdin, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11da <main+0x8a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ba <main+0x6a>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
call   1030 <trans@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11f2 <main+0xa2>
mov    0x2e07(%rip),%rax
mov    (%rax),%rdi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
call   1030 <trans@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    118f <main+0x3f>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b1 <main+0x61>
mov    %rax,%rbx
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <trans@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11a7 <main+0x57>
mov    0x2e52(%rip),%rax
mov    (%rax),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
call   1030 <trans@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"can not open %s\0A\00"
@stdout = global i32 0
@stdin = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %29
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %9
%24 = load i32*, i32** %6
%25 = load i32, i32* @stdout
%26 = call i32 @trans(i32* %24, i32 %25)
%27 = load i32*, i32** %6
%28 = call i32 @fclose(i32* %27)
br label %33
29: ; preds = %2
%30 = load i32*, i32** @stdin
%31 = load i32, i32* @stdout
%32 = call i32 @trans(i32* %30, i32 %31)
br label %33
33: ; preds = %29, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"can not open %s\0A\00"
@stdout = global i32 0
@stdin = global i32* null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %18
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %5
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %4
%15 = load i32, i32* @stdout
%16 = tail call i32 @trans(i32* %7, i32 %15)
%17 = tail call i32 @fclose(i32* %7)
br label %22
18: ; preds = %2
%19 = load i32*, i32** @stdin
%20 = load i32, i32* @stdout
%21 = tail call i32 @trans(i32* %19, i32 %20)
br label %22
22: ; preds = %18, %14
ret i32 0
}