#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
unsigned char *data_from_file_raw(const char *filename, int *data_size) {
  FILE *data_file = fopen(filename, "r");
  fseek(data_file, 0L, SEEK_END);
  *data_size = ftell(data_file);
  rewind(data_file);
  unsigned char *data = (unsigned char *)malloc(*data_size);
  fread(data, 1, *data_size, data_file);
  fclose(data_file);
  return data;
}


x86 assembly (clang, -O0):
<data_from_file_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_from_file_raw>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xe81(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    (%r14),%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define i8* @data_from_file_raw(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = load i32, i32* @SEEK_END
%11 = call i32 @fseek(i32* %9, i64 0, i32 %10)
%12 = load i32*, i32** %5
%13 = call i32 @ftell(i32* %12)
%14 = load i32*, i32** %4
store i32 %13, i32* %14
%15 = load i32*, i32** %5
%16 = call i32 @rewind(i32* %15)
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = load i32*, i32** %5
%25 = call i32 @fread(i8* %21, i32 1, i32 %23, i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
%28 = load i8*, i8** %6
ret i8* %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define i8* @data_from_file_raw(i8* nocapture %0, i32* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %3, i64 0, i32 %4)
%6 = tail call i32 @ftell(i32* %3)
store i32 %6, i32* %1
%7 = tail call i32 @rewind(i32* %3)
%8 = load i32, i32* %1
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = load i32, i32* %1
%12 = tail call i32 @fread(i8* %10, i32 1, i32 %11, i32* %3)
%13 = tail call i32 @fclose(i32* %3)
ret i8* %10
}