#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 */

/* Variables and functions */
double a1f(int);
double a2f(int);
double b1f(int);
double b2f(int);
double c1f(double, double);
double c2f(int, double, double, double);
double e1f(double, double);
double e2f(double, double, double);
double sqrt(double);
double tajd(int nsam, int segsites, double sumk) {
  double a1, a2, b1, b2, c1, c2, e1, e2;
  if (segsites == 0)
    return (0.0);
  a1 = a1f(nsam);
  a2 = a2f(nsam);
  b1 = b1f(nsam);
  b2 = b2f(nsam);
  c1 = c1f(a1, b1);
  c2 = c2f(nsam, a1, a2, b2);
  e1 = e1f(a1, c1);
  e2 = e2f(a1, a2, c2);
  return ((sumk - (segsites / a1)) /
          sqrt((e1 * segsites) + ((e2 * segsites) * (segsites - 1))));
}


x86 assembly (clang, -O0):
<tajd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11ba <tajd+0x2a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a7 <tajd+0x117>
mov    -0xc(%rbp),%edi
call   1060 <a1f@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <a2f@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <b1f@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <b2f@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1090 <c1f@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1050 <c2f@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   10b0 <e1f@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
call   1080 <e2f@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   10a0 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tajd>:
test   %esi,%esi
je     1289 <tajd+0xf9>
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
movsd  %xmm0,0x20(%rsp)
call   1060 <a1f@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1070 <a2f@plt>
movsd  %xmm0,0x28(%rsp)
mov    %ebp,%edi
call   1030 <b1f@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1040 <b2f@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1090 <c1f@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1050 <c2f@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   10b0 <e1f@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
call   1080 <e2f@plt>
movsd  0x20(%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm3
mulsd  %xmm1,%xmm3
divsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm2
add    $0xffffffff,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
movapd %xmm3,%xmm0
jb     128d <tajd+0xfd>
sqrtsd %xmm0,%xmm0
jmp    129e <tajd+0x10e>
xorps  %xmm0,%xmm0
ret
movsd  %xmm2,0x20(%rsp)
call   10a0 <sqrt@plt>
movsd  0x20(%rsp),%xmm2
divsd  %xmm0,%xmm2
add    $0x38,%rsp
pop    %rbx
pop    %rbp
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @tajd(i32 %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3
store double 0.000000e+00, double* %4
br label %63
19: ; preds = %3
%20 = load i32, i32* %5
%21 = call double @a1f(i32 %20)
store double %21, double* %8
%22 = load i32, i32* %5
%23 = call double @a2f(i32 %22)
store double %23, double* %9
%24 = load i32, i32* %5
%25 = call double @b1f(i32 %24)
store double %25, double* %10
%26 = load i32, i32* %5
%27 = call double @b2f(i32 %26)
store double %27, double* %11
%28 = load double, double* %8
%29 = load double, double* %10
%30 = call double @c1f(double %28, double %29)
store double %30, double* %12
%31 = load i32, i32* %5
%32 = load double, double* %8
%33 = load double, double* %9
%34 = load double, double* %11
%35 = call double @c2f(i32 %31, double %32, double %33, double %34)
store double %35, double* %13
%36 = load double, double* %8
%37 = load double, double* %12
%38 = call double @e1f(double %36, double %37)
store double %38, double* %14
%39 = load double, double* %8
%40 = load double, double* %9
%41 = load double, double* %13
%42 = call double @e2f(double %39, double %40, double %41)
store double %42, double* %15
%43 = load double, double* %7
%44 = load i32, i32* %6
%45 = sitofp i32 %44 to double
%46 = load double, double* %8
%47 = fdiv double %45, %46
%48 = fsub double %43, %47
%49 = load double, double* %14
%50 = load i32, i32* %6
%51 = sitofp i32 %50 to double
%52 = load double, double* %15
%53 = load i32, i32* %6
%54 = sitofp i32 %53 to double
%55 = fmul double %52, %54
%56 = load i32, i32* %6
%57 = sub nsw i32 %56, 1
%58 = sitofp i32 %57 to double
%59 = fmul double %55, %58
%60 = call double @llvm.fmuladd.f64(double %49, double %51, double %59)
%61 = call double @sqrt(double %60)
%62 = fdiv double %48, %61
store double %62, double* %4
br label %63
63: ; preds = %19, %18
%64 = load double, double* %4
ret double %64
}

LLVM IR (-O2):
define double @tajd(i32 %0, i32 %1, double %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %24, label %5
5: ; preds = %3
%6 = tail call double @a1f(i32 %0)
%7 = tail call double @a2f(i32 %0)
%8 = tail call double @b1f(i32 %0)
%9 = tail call double @b2f(i32 %0)
%10 = tail call double @c1f(double %6, double %8)
%11 = tail call double @c2f(i32 %0, double %6, double %7, double %9)
%12 = tail call double @e1f(double %6, double %10)
%13 = tail call double @e2f(double %6, double %7, double %11)
%14 = sitofp i32 %1 to double
%15 = fdiv double %14, %6
%16 = fsub double %2, %15
%17 = fmul double %13, %14
%18 = add nsw i32 %1, -1
%19 = sitofp i32 %18 to double
%20 = fmul double %17, %19
%21 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %20)
%22 = tail call double @sqrt(double %21)
%23 = fdiv double %16, %22
br label %24
24: ; preds = %3, %5
%25 = phi double [ %23, %5 ], [ 0.000000e+00, %3 ]
ret double %25
}