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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
unsigned long *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
void readInputFile(const char *filename, int *n, unsigned long **cases) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  fp = fopen(filename, "r");
  if (fp == NULL) {
    perror("Error opening input file.\n");
    exit(EXIT_FAILURE);
  }
  read = getline(&line, &len, fp);
  sscanf(line, "%d", n);
  *cases = malloc(sizeof(unsigned long) * *n);
  int i;
  for (i = 0; i < *n; i++) {
    read = getline(&line, &len, fp);
    unsigned long l;
    sscanf(line, "%lu", &l);
    *(*cases + i) = l;
  }
  fclose(fp);
  free(line);
}


x86 assembly (clang, -O0):
<readInputFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11dd <readInputFile+0x5d>
lea    0xe38(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1284 <readInputFile+0x104>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdc8(%rip),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1060 <sscanf@plt>
mov    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    122a <readInputFile+0xaa>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readInputFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe54(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1269 <readInputFile+0xe9>
mov    %rax,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1090 <getline@plt>
mov    (%rsp),%rdi
lea    0xe45(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
mov    (%r15),%ebp
lea    0x0(,%rbp,8),%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
test   %ebp,%ebp
jle    1249 <readInputFile+0xc9>
lea    0xe21(%rip),%rbp
lea    0x10(%rsp),%r12
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
mov    (%rsp),%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <sscanf@plt>
mov    0x10(%rsp),%rax
mov    (%r14),%rcx
mov    %rax,(%rcx,%r13,8)
add    $0x1,%r13
movslq (%r15),%rax
cmp    %rax,%r13
jl     1210 <readInputFile+0x90>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd92(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Error opening input file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lu\00"
define void @readInputFile(i8* %0, i32* %1, i64** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64**
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i64** %2, i64*** %6
store i8* null, i8** %8
store i64 0, i64* %9
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %3
%22 = load i32*, i32** %7
%23 = call i32 @getline(i8** %8, i64* %9, i32* %22)
store i32 %23, i32* %10
%24 = load i8*, i8** %8
%25 = load i32*, i32** %5
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %25)
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = mul i64 8, %29
%31 = trunc i64 %30 to i32
%32 = call i64* @malloc(i32 %31)
%33 = load i64**, i64*** %6
store i64* %32, i64** %33
store i32 0, i32* %11
br label %34
34: ; preds = %50, %21
%35 = load i32, i32* %11
%36 = load i32*, i32** %5
%37 = load i32, i32* %36
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %53
39: ; preds = %34
%40 = load i32*, i32** %7
%41 = call i32 @getline(i8** %8, i64* %9, i32* %40)
store i32 %41, i32* %10
%42 = load i8*, i8** %8
%43 = call i32 (i8*, i8*, ...) @sscanf(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %12)
%44 = load i64, i64* %12
%45 = load i64**, i64*** %6
%46 = load i64*, i64** %45
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i64, i64* %46, i64 %48
store i64 %44, i64* %49
br label %50
50: ; preds = %39
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
br label %34
53: ; preds = %34
%54 = load i32*, i32** %7
%55 = call i32 @fclose(i32* %54)
%56 = load i8*, i8** %8
%57 = call i32 @free(i8* %56)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Error opening input file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lu\00"
define void @readInputFile(i8* nocapture %0, i32* %1, i64** nocapture %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %3
%16 = call i32 @getline(i8** %4, i64* %5, i32* %9)
%17 = load i8*, i8** %4
%18 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = shl i32 %19, 3
%21 = call i64* @malloc(i32 %20)
store i64* %21, i64** %2
%22 = icmp sgt i32 %19, 0
br i1 %22, label %23, label %37
23: ; preds = %15
%24 = bitcast i64* %6 to i8*
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %33, %25 ]
%27 = call i32 @getline(i8** %4, i64* %5, i32* %9)
%28 = load i8*, i8** %4
%29 = call i32 (i8*, i8*, ...) @sscanf(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %6)
%30 = load i64, i64* %6
%31 = load i64*, i64** %2
%32 = getelementptr inbounds i64, i64* %31, i64 %26
store i64 %30, i64* %32
%33 = add nuw nsw i64 %26, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %25, label %37
37: ; preds = %25, %15
%38 = call i32 @fclose(i32* %9)
%39 = load i8*, i8** %4
%40 = call i32 @free(i8* %39)
ret void
}