#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 */
scalar_t__ calloc(long, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sscanf(char *, char *, double *, double *);
int /*<<< orphan*/ stderr;
int read_mass_function(char *fname, double **x, double **y, long *N,
                       double xmin, long *Nred) {
  long Nlines = 0, N_gtmin = 0;
  FILE *f;
  char line[1024];
  double X, Y;
  if ((f = fopen(fname, "r")) == NULL) {
    perror("fopen:");
    fprintf(stderr, "Error while reading the file %s\n", fname);
    return -1;
  }
  while (fgets(line, 1024, f) != NULL) {
    if (line[0] != '#') {
      Nlines++;
    }
  }
  fclose(f);
  (*x) = (double *)calloc(Nlines, sizeof(double));
  (*y) = (double *)calloc(Nlines, sizeof(double));
  Nlines = 0;
  f = fopen(fname, "r");
  while (fgets(line, 1024, f) != NULL) {
    if (line[0] != '#') {
      sscanf(line, "%lf %lf", &X, &Y);
      (*x)[Nlines] = X;
      (*y)[Nlines] = Y;
      Nlines++;
      if (X > xmin)
        N_gtmin++;
    }
  }
  fclose(f);
  if (N_gtmin == Nlines) {
    fprintf(stderr, "Mass Function Doesn't Reach Lowest Mass Needed, %e, %e\n",
            xmin, (*x)[0]);
    exit(1);
  }
  *N = Nlines;
  *Nred = N_gtmin;
  return 1;
}


x86 assembly (clang, -O0):
<read_mass_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1205 <read_mass_function+0x85>
lea    0xe29(%rip),%rdi
call   1090 <perror@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13b9 <read_mass_function+0x239>
jmp    120a <read_mass_function+0x8a>
lea    -0x450(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     124a <read_mass_function+0xca>
movsbl -0x450(%rbp),%eax
cmp    $0x23,%eax
je     1245 <read_mass_function+0xc5>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    120a <read_mass_function+0x8a>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x50(%rbp)
lea    -0x450(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1354 <read_mass_function+0x1d4>
movsbl -0x450(%rbp),%eax
cmp    $0x23,%eax
je     134f <read_mass_function+0x1cf>
lea    -0x450(%rbp),%rdi
lea    0xd4e(%rip),%rsi
lea    -0x458(%rbp),%rdx
lea    -0x460(%rbp),%rcx
call   1070 <sscanf@plt>
movsd  -0x458(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x460(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
movsd  -0x458(%rbp),%xmm0
ff
ucomisd -0x30(%rbp),%xmm0
jbe    134a <read_mass_function+0x1ca>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    134f <read_mass_function+0x1cf>
jmp    129f <read_mass_function+0x11f>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    139c <read_mass_function+0x21c>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm1
lea    0xca7(%rip),%rsi
mov    $0x2,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mass_function>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %r8,%r14
movsd  %xmm0,0x10(%rsp)
mov    %rcx,%rbp
mov    %rdx,0x18(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%r13
lea    0xe4f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1335 <read_mass_function+0x1b5>
mov    %rax,%rbx
mov    %rbp,0x28(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1212 <read_mass_function+0x92>
lea    0x40(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
cmpb   $0x23,0x40(%rsp)
setne  %al
add    %rax,%rbp
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11f0 <read_mass_function+0x70>
mov    %r14,0x30(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
mov    %rbp,%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
lea    0xdb0(%rip),%rsi
mov    %r13,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0x40(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1362 <read_mass_function+0x1e2>
xor    %r14d,%r14d
lea    0x40(%rsp),%rbp
lea    0x20(%rsp),%r15
lea    0x38(%rsp),%r12
xor    %r13d,%r13d
jmp    12a5 <read_mass_function+0x125>
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1301 <read_mass_function+0x181>
cmpb   $0x23,0x40(%rsp)
je     1290 <read_mass_function+0x110>
mov    %rbp,%rdi
lea    0xd74(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1070 <sscanf@plt>
movsd  0x20(%rsp),%xmm0
mov    0x8(%rsp),%rax
mov    (%rax),%rax
movsd  %xmm0,(%rax,%r13,8)
movsd  0x38(%rsp),%xmm0
mov    0x18(%rsp),%rax
mov    (%rax),%rax
movsd  %xmm0,(%rax,%r13,8)
add    $0x1,%r13
movsd  0x20(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
jbe    1290 <read_mass_function+0x110>
add    $0x1,%r14
jmp    1290 <read_mass_function+0x110>
mov    %rbx,%rdi
call   1030 <fclose@plt>
cmp    %r13,%r14
je     136a <read_mass_function+0x1ea>
mov    0x28(%rsp),%rax
mov    %r13,(%rax)
mov    0x30(%rsp),%rax
mov    %r14,(%rax)
mov    $0x1,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc6(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1323 <read_mass_function+0x1a3>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm1
lea    0xcac(%rip),%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fopen:\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"Error while reading the file %s\0A\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [56 x i8] c"Mass Function Doesn't Reach Lowest Mass Needed, %e, %e\0A\00"
define i32 @read_mass_function(i8* %0, double** %1, double** %2, i64* %3, double %4, i64* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca double**
%10 = alloca double**
%11 = alloca i64*
%12 = alloca double
%13 = alloca i64*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32*
%17 = alloca [1024 x i8]
%18 = alloca double
%19 = alloca double
store i8* %0, i8** %8
store double** %1, double*** %9
store double** %2, double*** %10
store i64* %3, i64** %11
store double %4, double* %12
store i64* %5, i64** %13
store i64 0, i64* %14
store i64 0, i64* %15
%20 = load i8*, i8** %8
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %16
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %6
%24 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %8
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 -1, i32* %7
br label %109
28: ; preds = %6
br label %29
29: ; preds = %42, %28
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%31 = load i32*, i32** %16
%32 = call i32* @fgets(i8* %30, i32 1024, i32* %31)
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %43
34: ; preds = %29
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 35
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = load i64, i64* %14
%41 = add nsw i64 %40, 1
store i64 %41, i64* %14
br label %42
42: ; preds = %39, %34
br label %29
43: ; preds = %29
%44 = load i32*, i32** %16
%45 = call i32 @fclose(i32* %44)
%46 = load i64, i64* %14
%47 = call i64 @calloc(i64 %46, i32 8)
%48 = inttoptr i64 %47 to double*
%49 = load double**, double*** %9
store double* %48, double** %49
%50 = load i64, i64* %14
%51 = call i64 @calloc(i64 %50, i32 8)
%52 = inttoptr i64 %51 to double*
%53 = load double**, double*** %10
store double* %52, double** %53
store i64 0, i64* %14
%54 = load i8*, i8** %8
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %55, i32** %16
br label %56
56: ; preds = %88, %43
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%58 = load i32*, i32** %16
%59 = call i32* @fgets(i8* %57, i32 1024, i32* %58)
%60 = icmp ne i32* %59, null
br i1 %60, label %61, label %89
61: ; preds = %56
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 35
br i1 %65, label %66, label %88
66: ; preds = %61
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%68 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %18, double* %19)
%69 = load double, double* %18
%70 = load double**, double*** %9
%71 = load double*, double** %70
%72 = load i64, i64* %14
%73 = getelementptr inbounds double, double* %71, i64 %72
store double %69, double* %73
%74 = load double, double* %19
%75 = load double**, double*** %10
%76 = load double*, double** %75
%77 = load i64, i64* %14
%78 = getelementptr inbounds double, double* %76, i64 %77
store double %74, double* %78
%79 = load i64, i64* %14
%80 = add nsw i64 %79, 1
store i64 %80, i64* %14
%81 = load double, double* %18
%82 = load double, double* %12
%83 = fcmp ogt double %81, %82
br i1 %83, label %84, label %87
84: ; preds = %66
%85 = load i64, i64* %15
%86 = add nsw i64 %85, 1
store i64 %86, i64* %15
br label %87
87: ; preds = %84, %66
br label %88
88: ; preds = %87, %61
br label %56
89: ; preds = %56
%90 = load i32*, i32** %16
%91 = call i32 @fclose(i32* %90)
%92 = load i64, i64* %15
%93 = load i64, i64* %14
%94 = icmp eq i64 %92, %93
br i1 %94, label %95, label %104
95: ; preds = %89
%96 = load i32, i32* @stderr
%97 = load double, double* %12
%98 = load double**, double*** %9
%99 = load double*, double** %98
%100 = getelementptr inbounds double, double* %99, i64 0
%101 = load double, double* %100
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), double %97, double %101)
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %89
%105 = load i64, i64* %14
%106 = load i64*, i64** %11
store i64 %105, i64* %106
%107 = load i64, i64* %15
%108 = load i64*, i64** %13
store i64 %107, i64* %108
store i32 1, i32* %7
br label %109
109: ; preds = %104, %23
%110 = load i32, i32* %7
ret i32 %110
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fopen:\00"
@stderr = global i32 0
@.str.2 = [33 x i8] c"Error while reading the file %s\0A\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [56 x i8] c"Mass Function Doesn't Reach Lowest Mass Needed, %e, %e\0A\00"
define i32 @read_mass_function(i8* %0, double** nocapture %1, double** nocapture %2, i64* nocapture writeonly %3, double %4, i64* nocapture writeonly %5) {
%7 = alloca [1024 x i8]
%8 = alloca double
%9 = alloca double
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%11 = bitcast double* %8 to i8*
%12 = bitcast double* %9 to i8*
%13 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %6
%16 = call i32* @fgets(i8* %10, i32 1024, i32* %13)
%17 = icmp eq i32* %16, null
br i1 %17, label %30, label %22
18: ; preds = %6
%19 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %75
22: ; preds = %15, %22
%23 = phi i64 [ %27, %22 ], [ 0, %15 ]
%24 = load i8, i8* %10
%25 = icmp ne i8 %24, 35
%26 = zext i1 %25 to i64
%27 = add nuw nsw i64 %23, %26
%28 = call i32* @fgets(i8* %10, i32 1024, i32* %13)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %22
30: ; preds = %22, %15
%31 = phi i64 [ 0, %15 ], [ %27, %22 ]
%32 = call i32 @fclose(i32* %13)
%33 = call i64 @calloc(i64 %31, i32 8)
%34 = inttoptr i64 %33 to double*
store double* %34, double** %1
%35 = call i64 @calloc(i64 %31, i32 8)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %2
%37 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%38 = call i32* @fgets(i8* %10, i32 1024, i32* %37)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %30
%41 = call i32 @fclose(i32* %37)
br label %68
42: ; preds = %30, %60
%43 = phi i64 [ %62, %60 ], [ 0, %30 ]
%44 = phi i64 [ %61, %60 ], [ 0, %30 ]
%45 = load i8, i8* %10
%46 = icmp eq i8 %45, 35
br i1 %46, label %60, label %47
47: ; preds = %42
%48 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %8, double* %9)
%49 = load double, double* %8
%50 = load double*, double** %1
%51 = getelementptr inbounds double, double* %50, i64 %44
store double %49, double* %51
%52 = load double, double* %9
%53 = load double*, double** %2
%54 = getelementptr inbounds double, double* %53, i64 %44
store double %52, double* %54
%55 = add nsw i64 %44, 1
%56 = load double, double* %8
%57 = fcmp ogt double %56, %4
br i1 %57, label %58, label %60
58: ; preds = %47
%59 = add nsw i64 %43, 1
br label %60
60: ; preds = %47, %58, %42
%61 = phi i64 [ %55, %58 ], [ %55, %47 ], [ %44, %42 ]
%62 = phi i64 [ %59, %58 ], [ %43, %47 ], [ %43, %42 ]
%63 = call i32* @fgets(i8* %10, i32 1024, i32* %37)
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %42
65: ; preds = %60
%66 = call i32 @fclose(i32* %37)
%67 = icmp eq i64 %62, %61
br i1 %67, label %68, label %74
68: ; preds = %40, %65
%69 = load i32, i32* @stderr
%70 = load double*, double** %1
%71 = load double, double* %70
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), double %4, double %71)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %65
store i64 %61, i64* %3
store i64 %62, i64* %5
br label %75
75: ; preds = %74, %18
%76 = phi i32 [ -1, %18 ], [ 1, %74 ]
ret i32 %76
}