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


x86 assembly (clang, -O0):
<loadTorgeirUpperMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    11ae <loadTorgeirUpperMatrix+0x6e>
mov    -0x28(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <loadTorgeirUpperMatrix+0x32>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    126f <loadTorgeirUpperMatrix+0x12f>
mov    -0x28(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x28(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    125c <loadTorgeirUpperMatrix+0x11c>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
imul   -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0xf8(%rbp),%rdx
add    -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11fe <loadTorgeirUpperMatrix+0xbe>
jmp    1261 <loadTorgeirUpperMatrix+0x121>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b5 <loadTorgeirUpperMatrix+0x75>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd89(%rip),%rdi
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadTorgeirUpperMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%r14
mov    %rdi,0x10(%rsp)
lea    0xea0(%rip),%rsi
mov    %rdx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
cmp    $0xffffffffffffffff,%r14
je     11b2 <loadTorgeirUpperMatrix+0x72>
mov    $0xffffffffffffffff,%rbp
lea    0xe83(%rip),%r12
lea    0x20(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1190 <loadTorgeirUpperMatrix+0x50>
test   %r14,%r14
je     1279 <loadTorgeirUpperMatrix+0x139>
mov    $0x1,%eax
mov    %rax,(%rsp)
xor    %eax,%eax
jmp    11d9 <loadTorgeirUpperMatrix+0x99>
nop
addq   $0x1,(%rsp)
mov    0x18(%rsp),%rax
cmp    %rbx,%rax
mov    %rbx,%r14
mov    %r12,%rbx
je     1279 <loadTorgeirUpperMatrix+0x139>
mov    %rax,%r15
mov    %rbx,%rdi
lea    0xe1c(%rip),%rbp
mov    %rbp,%rsi
lea    0x20(%rsp),%r13
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r15,%rax
mov    %r15,0x8(%rsp)
lea    0x1(%r15),%rax
mov    %rax,0x18(%rsp)
cmp    %r14,%rax
mov    %rbx,%r12
mov    %r14,%rbx
lea    0xddc(%rip),%r15
mov    0x10(%rsp),%r14
jae    11c0 <loadTorgeirUpperMatrix+0x80>
mov    0x8(%rsp),%r13
mov    (%rsp),%rbp
nopl   0x0(%rax)
mov    %r13d,%eax
imul   %ebp,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
add    0x8(%rsp),%ecx
movslq %ecx,%rax
lea    (%r14,%rax,4),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbp
add    $0x1,%r13
cmp    %rbx,%rbp
jb     1240 <loadTorgeirUpperMatrix+0x100>
jmp    11c0 <loadTorgeirUpperMatrix+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd80(%rip),%rdi
call   1030 <puts@plt>
add    $0xe8,%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 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [27 x i8] c"Done reading correlations\0A\00"
define void @loadTorgeirUpperMatrix(float* %0, i64 %1, i8* %2) {
%4 = alloca float*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [200 x i8]
store float* %0, float** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%11 = load i8*, i8** %6
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
store i32 0, i32* %7
br label %13
13: ; preds = %23, %3
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = load i64, i64* %5
%17 = add i64 %16, 1
%18 = icmp ult i64 %15, %17
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = load i32*, i32** %9
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%22 = call i32 (i32*, i8*, ...) @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %13
26: ; preds = %13
store i32 0, i32* %7
br label %27
27: ; preds = %63, %26
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = load i64, i64* %5
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %66
32: ; preds = %27
%33 = load i32*, i32** %9
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32*, i32** %9
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%38 = call i32 (i32*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %41
41: ; preds = %59, %32
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = load i64, i64* %5
%45 = icmp ult i64 %43, %44
br i1 %45, label %46, label %62
46: ; preds = %41
%47 = load i32*, i32** %9
%48 = load float*, float** %4
%49 = load i32, i32* %8
%50 = sub nsw i32 %49, 1
%51 = load i32, i32* %8
%52 = mul nsw i32 %50, %51
%53 = sdiv i32 %52, 2
%54 = load i32, i32* %7
%55 = add nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds float, float* %48, i64 %56
%58 = call i32 (i32*, i8*, ...) @fscanf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %57)
br label %59
59: ; preds = %46
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %41
62: ; preds = %41
br label %63
63: ; preds = %62
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %27
66: ; preds = %27
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
%69 = call i32 @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"%s\00"
@.str.2 = [3 x i8] c"%f\00"
@str = [26 x i8] c"Done reading correlations\00"
define void @loadTorgeirUpperMatrix(float* %0, i64 %1, i8* nocapture %2) {
%4 = alloca [200 x i8]
%5 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = icmp eq i64 %1, -1
br i1 %7, label %10, label %11
8: ; preds = %11
%9 = icmp eq i64 %1, 0
br i1 %9, label %40, label %10
10: ; preds = %3, %8
br label %19
11: ; preds = %3, %11
%12 = phi i64 [ %14, %11 ], [ 0, %3 ]
%13 = call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = add nuw i64 %12, 1
%15 = icmp eq i64 %12, %1
br i1 %15, label %8, label %11
16: ; preds = %28, %19
%17 = add nuw i64 %21, 1
%18 = icmp eq i64 %24, %1
br i1 %18, label %40, label %19
19: ; preds = %10, %16
%20 = phi i64 [ %24, %16 ], [ 0, %10 ]
%21 = phi i64 [ %17, %16 ], [ 1, %10 ]
%22 = call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%24 = add nuw i64 %20, 1
%25 = icmp ult i64 %24, %1
br i1 %25, label %26, label %16
26: ; preds = %19
%27 = trunc i64 %20 to i32
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ %21, %26 ], [ %38, %28 ]
%30 = trunc i64 %29 to i32
%31 = add nsw i32 %30, -1
%32 = mul nsw i32 %31, %30
%33 = sdiv i32 %32, 2
%34 = add nsw i32 %33, %27
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %0, i64 %35
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %36)
%38 = add i64 %29, 1
%39 = icmp ult i64 %38, %1
br i1 %39, label %28, label %16
40: ; preds = %16, %8
%41 = call i32 @fclose(i32* %5)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
ret void
}