#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getFileSize(char *);
unsigned char *inEx(int /*<<< orphan*/ *, int /*<<< orphan*/,
                    int /*<<< orphan*/, int *);
int /*<<< orphan*/ printf(char *, char *);
unsigned char *in(char *in, int *outSize) {
  FILE *fin;
  unsigned char *result;
  fin = fopen(in, "rb");
  if (!fin) {
    printf("Error: Couldn't open input file %s\n", in);
    *outSize = 0;
    return 0;
  }
  result = inEx(fin, 0, getFileSize(in), outSize);
  fclose(fin);
  return result;
}


x86 assembly (clang, -O0):
<in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a6 <in+0x56>
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11dd <in+0x8d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getFileSize@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
call   1030 <inEx@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1196 <in+0x46>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <getFileSize@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   1030 <inEx@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rax
jmp    11ae <in+0x5e>
lea    0xe66(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
movl   $0x0,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [36 x i8] c"Error: Couldn't open input file %s\0A\00"
define i8* @in(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32*, i32** %5
store i32 0, i32* %15
store i8* null, i8** %3
br label %25
16: ; preds = %2
%17 = load i32*, i32** %6
%18 = load i8*, i8** %4
%19 = call i32 @getFileSize(i8* %18)
%20 = load i32*, i32** %5
%21 = call i8* @inEx(i32* %17, i32 0, i32 %19, i32* %20)
store i8* %21, i8** %7
%22 = load i32*, i32** %6
%23 = call i32 @fclose(i32* %22)
%24 = load i8*, i8** %7
store i8* %24, i8** %3
br label %25
25: ; preds = %16, %12
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [36 x i8] c"Error: Couldn't open input file %s\0A\00"
define i8* @in(i8* %0, i32* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %0)
store i32 0, i32* %1
br label %11
7: ; preds = %2
%8 = tail call i32 @getFileSize(i8* %0)
%9 = tail call i8* @inEx(i32* %3, i32 0, i32 %8, i32* %1)
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %7, %5
%12 = phi i8* [ %9, %7 ], [ null, %5 ]
ret i8* %12
}