#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*/ fprintf(int /*<<< orphan*/ *, char *, int, int, float);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
float getMIpair(double const *, size_t, int, int, int, int, int);
void getMIfile(const double *X, size_t ngenes, int nexp, int numbins,
               int splineord) {
  int i;
  int nlines = 36;
  FILE *fi, *fo;
  fi = fopen("genepairs.txt", "r");
  fo = fopen("genepairsmi.txt", "w");
  for (i = 0; i < nlines; i++) {
    int ng1, ng2;
    fscanf(fi, "%d %d", &ng1, &ng2);
    float mi = getMIpair(X, ngenes, nexp, ng1, ng2, numbins, splineord);
    fprintf(fo, "%d %d %f\n", ng1, ng2, mi);
  }
  fclose(fi);
  fclose(fo);
}


x86 assembly (clang, -O0):
<getMIfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x24,-0x24(%rbp)
lea    0xe88(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
lea    0xe81(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1219 <getMIfile+0xc9>
mov    -0x30(%rbp),%rdi
lea    0xe65(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <getMIpair@plt>
movss  %xmm0,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
movss  -0x44(%rbp),%xmm0
lea    0xe22(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a6 <getMIfile+0x56>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMIfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0x14(%rsp)
mov    %ecx,0x10(%rsp)
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xe89(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
lea    0xe83(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    $0x24,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
lea    0xe68(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <fscanf@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    0x10(%rsp),%r9d
call   1030 <getMIpair@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %r14,%rdi
lea    0xe2a(%rip),%rsi
call   1060 <fprintf@plt>
add    $0xffffffff,%r15d
jne    11b0 <getMIfile+0x60>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"genepairs.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"genepairsmi.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [10 x i8] c"%d %d %f\0A\00"
define void @getMIfile(double* %0, i64 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
br label %12
12: ; preds = %5, %12
%13 = phi i32 [ 0, %5 ], [ %21, %12 ]
%14 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call float @getMIpair(double* %0, i64 %1, i32 %2, i32 %15, i32 %16, i32 %3, i32 %4)
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %19, float %17)
%21 = add nuw nsw i32 %13, 1
%22 = icmp eq i32 %21, 36
br i1 %22, label %23, label %12
23: ; preds = %12
%24 = call i32 @fclose(i32* %8)
%25 = call i32 @fclose(i32* %9)
ret void
}