#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*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
uint8_t *readFile(const char *fileName, uint32_t *fileLen) {
  FILE *file = fopen(fileName, "r");
  if (file == NULL) {
    printf("Unable to open file %s\n", fileName);
    exit(1);
  }
  fseek(file, 0L, SEEK_END);
  *fileLen = ftell(file);
  rewind(file);
  uint32_t roundedFileLen = ((*fileLen + 28 - 1) / 28) * 28;
  uint8_t *data = calloc(roundedFileLen, sizeof(uint8_t));
  assert(fread(data, 1, *fileLen, file) == *fileLen);
  fclose(file);
  return data;
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e9 <readFile+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1c,%eax
sub    $0x1,%eax
mov    $0x1c,%ecx
cltd
idiv   %ecx
imul   $0x1c,%eax,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe4b(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     125d <readFile+0xbd>
mov    %rax,%rbx
mov    0x2e1b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    (%r14),%r15d
lea    0x1b(%r15),%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %r15d,%eax
add    $0x1b,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x4,%eax
add    %ecx,%eax
lea    (%rax,%rax,8),%ecx
lea    (%rcx,%rcx,2),%edi
add    %eax,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %edi,%edi
cmp    (%r14),%eax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd9e(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Unable to open file %s\0A\00"
@SEEK_END = global i32 0
define i32* @readFile(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i32*, i32** %5
%18 = load i32, i32* @SEEK_END
%19 = call i32 @fseek(i32* %17, i64 0, i32 %18)
%20 = load i32*, i32** %5
%21 = call i32 @ftell(i32* %20)
%22 = load i32*, i32** %4
store i32 %21, i32* %22
%23 = load i32*, i32** %5
%24 = call i32 @rewind(i32* %23)
%25 = load i32*, i32** %4
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 28
%28 = sub nsw i32 %27, 1
%29 = sdiv i32 %28, 28
%30 = mul nsw i32 %29, 28
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i32* @calloc(i32 %31, i32 4)
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
%36 = load i32*, i32** %5
%37 = call i32 @fread(i32* %33, i32 1, i32 %35, i32* %36)
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = icmp eq i32 %37, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32*, i32** %5
%44 = call i32 @fclose(i32* %43)
%45 = load i32*, i32** %7
ret i32* %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Unable to open file %s\0A\00"
@SEEK_END = global i32 0
define noalias i32* @readFile(i8* %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 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %3, i64 0, i32 %9)
%11 = tail call i32 @ftell(i32* %3)
store i32 %11, i32* %1
%12 = tail call i32 @rewind(i32* %3)
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 27
%15 = srem i32 %14, 28
%16 = sub i32 %14, %15
%17 = tail call i32* @calloc(i32 %16, i32 4)
%18 = tail call i32 @fread(i32* %17, i32 1, i32 %13, i32* %3)
%19 = load i32, i32* %1
%20 = icmp eq i32 %18, %19
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32 @fclose(i32* %3)
ret i32* %17
}