#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 *, double *);
int /*<<< orphan*/ printf(char *, ...);
int read_input(char *fn, double *m, long n) {
  long i;
  FILE *fp;
  if ((fp = fopen(fn, "r")) == NULL) {
    printf("Inital file not found: %s\n", fn);
    printf("Get help on how to create it on:\n");
    printf("https://github.com/B0RJA/legendre-1D\n");
    return (1);
  }
  for (i = 0; i < n; i++) {
    fscanf(fp, "%lf", &(m[i * 2]));
    fscanf(fp, "%lf", &(m[i * 2 + 1]));
  }
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<read_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11ac <read_input+0x6c>
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <read_input+0xed>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    121d <read_input+0xdd>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
shl    $0x1,%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe85(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
shl    $0x1,%rax
add    $0x1,%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe5e(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11b4 <read_input+0x74>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c3 <read_input+0x73>
mov    %rax,%r15
test   %r14,%r14
jle    11b7 <read_input+0x67>
lea    0xe9c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
lea    0x8(%rbx),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <fscanf@plt>
add    $0x10,%rbx
add    $0xffffffffffffffff,%r14
jne    1190 <read_input+0x40>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11f1 <read_input+0xa1>
lea    0xe38(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Inital file not found: %s\0A\00"
@.str.4 = [4 x i8] c"%lf\00"
@str = [33 x i8] c"Get help on how to create it on:\00"
@str.5 = [37 x i8] c"https://github.com/B0RJA/legendre-1D\00"
define i32 @read_input(i8* %0, double* %1, i64 %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 %8, label %6
6: ; preds = %3
%7 = icmp sgt i64 %2, 0
br i1 %7, label %12, label %22
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.5, i64 0, i64 0))
br label %24
12: ; preds = %6, %12
%13 = phi i64 [ %20, %12 ], [ 0, %6 ]
%14 = shl nuw nsw i64 %13, 1
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %15)
%17 = or i64 %14, 1
%18 = getelementptr inbounds double, double* %1, i64 %17
%19 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %18)
%20 = add nuw nsw i64 %13, 1
%21 = icmp eq i64 %20, %2
br i1 %21, label %22, label %12
22: ; preds = %12, %6
%23 = tail call i32 @fclose(i32* %4)
br label %24
24: ; preds = %22, %8
%25 = phi i32 [ 1, %8 ], [ 0, %22 ]
ret i32 %25
}