#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__ EOF;
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, float *);
double get_geno(FILE *MyGenoFile, double *Geno, int nIND, int ploidy) {
  float value, value2;
  int ind = 0, i;
  double res = 0;
  while (ind < nIND) {
    if (fscanf(MyGenoFile, "%g", &value) != EOF) {
      if (ploidy == 2)
        Geno[ind] = (double)value;
      if (ploidy == 1) {
        Geno[ind] = (double)value;
        fscanf(MyGenoFile, "%g", &value2);
        Geno[ind] += (double)value2;
        if (Geno[ind] >= 9)
          Geno[ind] = 9;
      }
      res += (double)Geno[ind] / 2.0;
    }
    ind++;
  }
  return (double)res / nIND;
}


x86 assembly (clang, -O0):
<get_geno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123e <get_geno+0x12e>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
je     1230 <get_geno+0x120>
cmpl   $0x2,-0x18(%rbp)
jne    1185 <get_geno+0x75>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x1,-0x18(%rbp)
jne    120d <get_geno+0xfd>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <fscanf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe17(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1208 <get_geno+0xf8>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    120d <get_geno+0xfd>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xde6(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1135 <get_geno+0x25>
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_geno>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
mov    %edx,0x10(%rsp)
jle    1210 <get_geno+0x100>
mov    %ecx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %edx,%r14d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %r13d,%r13d
lea    0xec6(%rip),%r12
jmp    1177 <get_geno+0x67>
movsd  (%rbx,%r13,8),%xmm0
mulsd  0xeae(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%r13
cmp    %r13,%r14
je     121a <get_geno+0x10a>
mov    %rbp,%rdi
mov    %r12,%rsi
lea    0x4(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%rax
je     116a <get_geno+0x5a>
cmp    $0x1,%r15d
je     11b1 <get_geno+0xa1>
cmp    $0x2,%r15d
jne    114c <get_geno+0x3c>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rbx,%r13,8)
jmp    1152 <get_geno+0x42>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rbx,%r13,8)
mov    %rbp,%rdi
mov    %r12,%rsi
lea    0x14(%rsp),%rdx
call   1030 <fscanf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
ucomisd 0xe11(%rip),%xmm0
jb     1152 <get_geno+0x42>
movabs $0x4022000000000000,%rax
mov    %rax,(%rbx,%r13,8)
movsd  0xdf5(%rip),%xmm0
jmp    1152 <get_geno+0x42>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sdl 0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%g\00"
@EOF = global i64 0
define double @get_geno(i32* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
store i32* %0, i32** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %11
store double 0.000000e+00, double* %13
br label %14
14: ; preds = %74, %4
%15 = load i32, i32* %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %77
18: ; preds = %14
%19 = load i32*, i32** %5
%20 = call i64 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %9)
%21 = load i64, i64* @EOF
%22 = icmp ne i64 %20, %21
br i1 %22, label %23, label %74
23: ; preds = %18
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load float, float* %9
%28 = fpext float %27 to double
%29 = load double*, double** %6
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %26, %23
%34 = load i32, i32* %8
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %65
36: ; preds = %33
%37 = load float, float* %9
%38 = fpext float %37 to double
%39 = load double*, double** %6
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
%43 = load i32*, i32** %5
%44 = call i64 @fscanf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %10)
%45 = load float, float* %10
%46 = fpext float %45 to double
%47 = load double*, double** %6
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fadd double %51, %46
store double %52, double* %50
%53 = load double*, double** %6
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = fcmp oge double %57, 9.000000e+00
br i1 %58, label %59, label %64
59: ; preds = %36
%60 = load double*, double** %6
%61 = load i32, i32* %11
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double 9.000000e+00, double* %63
br label %64
64: ; preds = %59, %36
br label %65
65: ; preds = %64, %33
%66 = load double*, double** %6
%67 = load i32, i32* %11
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fdiv double %70, 2.000000e+00
%72 = load double, double* %13
%73 = fadd double %72, %71
store double %73, double* %13
br label %74
74: ; preds = %65, %18
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
store i32 %76, i32* %11
br label %14
77: ; preds = %14
%78 = load double, double* %13
%79 = load i32, i32* %7
%80 = sitofp i32 %79 to double
%81 = fdiv double %78, %80
ret double %81
}

LLVM IR (-O2):
@.str = [3 x i8] c"%g\00"
@EOF = global i64 0
define double @get_geno(i32* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = alloca float
%6 = alloca float
%7 = bitcast float* %5 to i8*
%8 = bitcast float* %6 to i8*
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %45
10: ; preds = %4
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %10, %41
%13 = phi i64 [ 0, %10 ], [ %43, %41 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %42, %41 ]
%15 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %5)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %41, label %18
18: ; preds = %12
switch i32 %3, label %19 [
i32 2, label %22
i32 1, label %26
]
19: ; preds = %18
%20 = getelementptr inbounds double, double* %1, i64 %13
%21 = load double, double* %20
br label %37
22: ; preds = %18
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = getelementptr inbounds double, double* %1, i64 %13
store double %24, double* %25
br label %37
26: ; preds = %18
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = getelementptr inbounds double, double* %1, i64 %13
store double %28, double* %29
%30 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %6)
%31 = load float, float* %6
%32 = fpext float %31 to double
%33 = load double, double* %29
%34 = fadd double %33, %32
store double %34, double* %29
%35 = fcmp ult double %34, 9.000000e+00
br i1 %35, label %37, label %36
36: ; preds = %26
store double 9.000000e+00, double* %29
br label %37
37: ; preds = %19, %22, %26, %36
%38 = phi double [ %21, %19 ], [ %24, %22 ], [ %34, %26 ], [ 9.000000e+00, %36 ]
%39 = fmul double %38, 5.000000e-01
%40 = fadd double %14, %39
br label %41
41: ; preds = %37, %12
%42 = phi double [ %40, %37 ], [ %14, %12 ]
%43 = add nuw nsw i64 %13, 1
%44 = icmp eq i64 %43, %11
br i1 %44, label %45, label %12
45: ; preds = %41, %4
%46 = phi double [ 0.000000e+00, %4 ], [ %42, %41 ]
%47 = sitofp i32 %2 to double
%48 = fdiv double %46, %47
ret double %48
}