#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*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *);
void load_line(double *image, int row, char *name) {
  FILE *h = NULL;
  int tmp = 0;
  h = fopen(name, "r");
  if (h == NULL) {
    printf("file not found\n");
  } else {
    int i = 0, j = 0;
    for (i = 0; i < 1; i++) {
      for (j = 0; j < row; j++) {
        fscanf(h, "%i", &tmp);
        image[j] = (double)tmp;
      }
    }
    fclose(h);
  }
}


x86 assembly (clang, -O0):
<load_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1192 <load_line+0x52>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    1214 <load_line+0xd4>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jge    120b <load_line+0xcb>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f8 <load_line+0xb8>
mov    -0x20(%rbp),%rdi
lea    0xe43(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <fscanf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b8 <load_line+0x78>
jmp    11fd <load_line+0xbd>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a7 <load_line+0x67>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
lea    0xea1(%rip),%rsi
mov    %rdx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11cd <load_line+0x8d>
mov    %rax,%r13
test   %ebp,%ebp
jle    11b6 <load_line+0x76>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe84(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <load_line+0x50>
mov    %r13,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe31(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"file not found\0A\00"
@.str.2 = [3 x i8] c"%i\00"
define void @load_line(double* %0, i32 %1, i8* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32* null, i32** %7
store i32 0, i32* %8
%11 = load i8*, i8** %6
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %45
17: ; preds = %3
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %9
br label %18
18: ; preds = %39, %17
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %42
21: ; preds = %18
store i32 0, i32* %10
br label %22
22: ; preds = %35, %21
%23 = load i32, i32* %10
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32*, i32** %7
%28 = call i32 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%29 = load i32, i32* %8
%30 = sitofp i32 %29 to double
%31 = load double*, double** %4
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
br label %35
35: ; preds = %26
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %22
38: ; preds = %22
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %18
42: ; preds = %18
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %42, %15
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%i\00"
@str = [15 x i8] c"file not found\00"
define void @load_line(double* nocapture writeonly %0, i32 %1, i8* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %22
10: ; preds = %8
%11 = zext i32 %1 to i64
br label %14
12: ; preds = %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %24
14: ; preds = %10, %14
%15 = phi i64 [ 0, %10 ], [ %20, %14 ]
%16 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = getelementptr inbounds double, double* %0, i64 %15
store double %18, double* %19
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %11
br i1 %21, label %22, label %14
22: ; preds = %14, %8
%23 = call i32 @fclose(i32* %6)
br label %24
24: ; preds = %22, %12
ret void
}