#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 *);
unsigned int loadfile_fileptr_fs(int /*<<< orphan*/ *, unsigned int,
                                 unsigned int *, double **, char *);
int /*<<< orphan*/ printf(char *, char *, char *, int);
unsigned int loadfile_fs(char *filename, unsigned int ncolumns,
                         unsigned int columns[], double *data[], char *fs) {
  FILE *in;
  unsigned int retval;
  if ((in = fopen(filename, "r")) == NULL) {
    printf("Unable to open %s  %s:%d\n", filename,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/UBC-Astrophysics/kd-match/refs/heads/"
           "master/loadfile.c",
           105);
    return 0;
  }
  retval = loadfile_fileptr_fs(in, ncolumns, columns, data, fs);
  fclose(in);
  return retval;
}


x86 assembly (clang, -O0):
<loadfile_fs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11a1 <loadfile_fs+0x61>
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
lea    0xe91(%rip),%rdx
mov    $0x69,%ecx
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cb <loadfile_fs+0x8b>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1040 <loadfile_fileptr_fs@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadfile_fs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%r13d
mov    %rdi,%rbx
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1190 <loadfile_fs+0x50>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13d,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <loadfile_fileptr_fs@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    %ebx,%eax
jmp    11ad <loadfile_fs+0x6d>
lea    0xe6b(%rip),%rdi
lea    0xe7e(%rip),%rdx
mov    %rbx,%rsi
mov    $0x69,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"Unable to open %s %s:%d\0A\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/UBC-Astrophysics/kd-match/refs/heads/master/loadfile.c\00"
define i32 @loadfile_fs(i8* %0, i32 %1, i32* %2, double** %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca double**
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store double** %3, double*** %10
store i8* %4, i8** %11
%14 = load i8*, i8** %7
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %12
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %5
%18 = load i8*, i8** %7
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 105)
store i32 0, i32* %6
br label %30
20: ; preds = %5
%21 = load i32*, i32** %12
%22 = load i32, i32* %8
%23 = load i32*, i32** %9
%24 = load double**, double*** %10
%25 = load i8*, i8** %11
%26 = call i32 @loadfile_fileptr_fs(i32* %21, i32 %22, i32* %23, double** %24, i8* %25)
store i32 %26, i32* %13
%27 = load i32*, i32** %12
%28 = call i32 @fclose(i32* %27)
%29 = load i32, i32* %13
store i32 %29, i32* %6
br label %30
30: ; preds = %20, %17
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"Unable to open %s %s:%d\0A\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/UBC-Astrophysics/kd-match/refs/heads/master/loadfile.c\00"
define i32 @loadfile_fs(i8* %0, i32 %1, i32* %2, double** %3, i8* %4) {
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 105)
br label %13
10: ; preds = %5
%11 = tail call i32 @loadfile_fileptr_fs(i32* %6, i32 %1, i32* %2, double** %3, i8* %4)
%12 = tail call i32 @fclose(i32* %6)
br label %13
13: ; preds = %10, %8
%14 = phi i32 [ 0, %8 ], [ %11, %10 ]
ret i32 %14
}