#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 const *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ printf(char *, ...);
void loadLowerMatrix(float *v, size_t ngenes, const char *nvalf) {
  int i, j;
  FILE *fi;
  fi = fopen(nvalf, "r");
  for (i = 1; i < ngenes; i++)
    for (j = 0; j < i; j++)
      fscanf(fi, "%f", &v[(i - 1) * i / 2 + j]);
  fclose(fi);
  printf("v1: %f\n", v[1]);
  printf("Done reading correlations\n");
}


x86 assembly (clang, -O0):
<loadLowerMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11eb <loadLowerMatrix+0xab>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d8 <loadLowerMatrix+0x98>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
imul   -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rdx
add    -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe3d(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1184 <loadLowerMatrix+0x44>
jmp    11dd <loadLowerMatrix+0x9d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <loadLowerMatrix+0x2f>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadLowerMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,(%rsp)
lea    0xe97(%rip),%rsi
mov    %rdx,%rdi
call   1070 <fopen@plt>
mov    %rax,%r13
cmp    $0x2,%r15
jb     11d1 <loadLowerMatrix+0x81>
mov    $0x1,%r14d
lea    0xe7b(%rip),%r12
nopw   0x0(%rax,%rax,1)
lea    -0x1(%r14),%eax
imul   %r14d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
mov    %r14,%rbp
nop
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    11b0 <loadLowerMatrix+0x60>
add    $0x1,%r14
cmp    %r15,%r14
jne    1190 <loadLowerMatrix+0x40>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe18(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe12(%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 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"v1: %f\0A\00"
@.str.3 = [27 x i8] c"Done reading correlations\0A\00"
define void @loadLowerMatrix(float* %0, i64 %1, i8* %2) {
%4 = alloca float*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store float* %0, float** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%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
store i32 1, i32* %7
br label %12
12: ; preds = %39, %3
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = load i64, i64* %5
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %12
store i32 0, i32* %8
br label %18
18: ; preds = %35, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = load i32*, i32** %9
%24 = load float*, float** %4
%25 = load i32, i32* %7
%26 = sub nsw i32 %25, 1
%27 = load i32, i32* %7
%28 = mul nsw i32 %26, %27
%29 = sdiv i32 %28, 2
%30 = load i32, i32* %8
%31 = add nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %24, i64 %32
%34 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %33)
br label %35
35: ; preds = %22
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %18
38: ; preds = %18
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %12
42: ; preds = %12
%43 = load i32*, i32** %9
%44 = call i32 @fclose(i32* %43)
%45 = load float*, float** %4
%46 = getelementptr inbounds float, float* %45, i64 1
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [8 x i8] c"v1: %f\0A\00"
@str = [26 x i8] c"Done reading correlations\00"
define void @loadLowerMatrix(float* %0, i64 %1, i8* nocapture %2) {
%4 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp ugt i64 %1, 1
br i1 %5, label %6, label %23
6: ; preds = %3, %20
%7 = phi i64 [ %21, %20 ], [ 1, %3 ]
%8 = trunc i64 %7 to i32
%9 = add nsw i32 %8, -1
%10 = mul nsw i32 %9, %8
%11 = sdiv i32 %10, 2
%12 = sext i32 %11 to i64
br label %13
13: ; preds = %6, %13
%14 = phi i64 [ 0, %6 ], [ %18, %13 ]
%15 = add nsw i64 %14, %12
%16 = getelementptr inbounds float, float* %0, i64 %15
%17 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = add nuw i64 %7, 1
%22 = icmp eq i64 %21, %1
br i1 %22, label %23, label %6
23: ; preds = %20, %3
%24 = tail call i32 @fclose(i32* %4)
%25 = getelementptr inbounds float, float* %0, i64 1
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
ret void
}