#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
char *calloc(int, size_t);
int /*<<< orphan*/ error(char *);
int execute(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  char *src;
  if (argc < 2)
    error("no given filename");
  FILE *fp = fopen(argv[1], "rb");
  size_t ssz = 0;
  if (!fp) {
    perror("file not found");
    exit(0);
  }
  fseek(fp, 0, SEEK_END);
  ssz = ftell(fp);
  fseek(fp, 0, SEEK_SET);
  src = calloc(sizeof(char), ssz + 2);
  fread(src, sizeof(char), ssz, fp);
  fclose(fp);
  return execute(src);
}


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)
jge    11cc <main+0x2c>
lea    0xe39(%rip),%rdi
call   1090 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120a <main+0x6a>
lea    0xe17(%rip),%rdi
call   10b0 <perror@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dd3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2da2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <execute@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11b9 <main+0x19>
lea    0xe4c(%rip),%rdi
call   1090 <error@plt>
mov    0x8(%rbx),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     123b <main+0x9b>
mov    %rax,%rbx
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,%r14
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0x2(%r14),%rsi
mov    $0x1,%edi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <execute@plt>
lea    0xdd3(%rip),%rdi
call   10b0 <perror@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"no given filename\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [15 x i8] c"file not found\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %7
store i64 0, i64* %8
%18 = load i32*, i32** %7
%19 = icmp ne i32* %18, null
br i1 %19, label %23, label %20
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %13
%24 = load i32*, i32** %7
%25 = load i32, i32* @SEEK_END
%26 = call i32 @fseek(i32* %24, i32 0, i32 %25)
%27 = load i32*, i32** %7
%28 = call i64 @ftell(i32* %27)
store i64 %28, i64* %8
%29 = load i32*, i32** %7
%30 = load i32, i32* @SEEK_SET
%31 = call i32 @fseek(i32* %29, i32 0, i32 %30)
%32 = load i64, i64* %8
%33 = add i64 %32, 2
%34 = call i8* @calloc(i32 1, i64 %33)
store i8* %34, i8** %6
%35 = load i8*, i8** %6
%36 = load i64, i64* %8
%37 = load i32*, i32** %7
%38 = call i32 @fread(i8* %35, i32 1, i64 %36, i32* %37)
%39 = load i32*, i32** %7
%40 = call i32 @fclose(i32* %39)
%41 = load i8*, i8** %6
%42 = call i32 @execute(i8* %41)
ret i32 %42
}

LLVM IR (-O2):
@.str = [18 x i8] c"no given filename\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [15 x i8] c"file not found\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
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 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %6
%15 = load i32, i32* @SEEK_END
%16 = tail call i32 @fseek(i32* %9, i32 0, i32 %15)
%17 = tail call i64 @ftell(i32* %9)
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @fseek(i32* %9, i32 0, i32 %18)
%20 = add i64 %17, 2
%21 = tail call i8* @calloc(i32 1, i64 %20)
%22 = tail call i32 @fread(i8* %21, i32 1, i64 %17, i32* %9)
%23 = tail call i32 @fclose(i32* %9)
%24 = tail call i32 @execute(i8* %21)
ret i32 %24
}