#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
void oneDFileReader(char *filename, int n, double *result) {
  FILE *inputFile;
  int x;
  inputFile = fopen(filename, "r");
  if (inputFile != NULL) {
    for (x = 0; x < n; ++x) {
      fscanf(inputFile, "%lf", &result[x]);
    }
  } else
    exit(0);
  fclose(inputFile);
}


x86 assembly (clang, -O0):
<oneDFileReader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b7 <oneDFileReader+0x77>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <oneDFileReader+0x72>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe63(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1179 <oneDFileReader+0x39>
jmp    11be <oneDFileReader+0x7e>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oneDFileReader>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     119a <oneDFileReader+0x5a>
mov    %rax,%r14
test   %ebp,%ebp
jle    1188 <oneDFileReader+0x48>
mov    %ebp,%ebp
lea    0xe95(%rip),%r15
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
jne    1170 <oneDFileReader+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
define void @oneDFileReader(i8* %0, i32 %1, double* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store double* %2, double** %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %29
13: ; preds = %3
store i32 0, i32* %8
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32*, i32** %7
%20 = load double*, double** %6
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %14
28: ; preds = %14
br label %31
29: ; preds = %3
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %28
%32 = load i32*, i32** %7
%33 = call i32 @fclose(i32* %32)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%lf\00"
define void @oneDFileReader(i8* nocapture %0, i32 %1, double* %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %18
8: ; preds = %6
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %14, %10 ]
%12 = getelementptr inbounds double, double* %2, i64 %11
%13 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %12)
%14 = add nuw nsw i64 %11, 1
%15 = icmp eq i64 %14, %9
br i1 %15, label %18, label %10
16: ; preds = %3
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %10, %6
%19 = tail call i32 @fclose(i32* %4)
ret void
}