#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 exp(double);
double gausdev();
double rekin_noises(int);
double sqrt(double);
double rekin(double k, double sigma, int ndeg, double taut) {
  double factor, r;
  if (taut > 0.1) {
    factor = exp(-1.0 / taut);
  } else {
    factor = 0.0;
  }
  r = gausdev();
  return k +
         (1.0 - factor) *
             (sigma * (rekin_noises(ndeg - 1) + r * r) / ndeg - k) +
         2.0 * r * sqrt(k * sigma / ndeg * (1.0 - factor) * factor);
}


x86 assembly (clang, -O0):
<rekin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe99(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118d <rekin+0x4d>
movsd  0xe8f(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1195 <rekin+0x55>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <gausdev@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe5d(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1040 <rekin_noises@plt>
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm4
movsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm5
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
cvtsi2sdl -0x14(%rbp),%xmm3
divsd  %xmm3,%xmm2
subsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdfb(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdce(%rip),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rekin>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x28(%rsp)
ucomisd 0xea5(%rip),%xmm2
xorpd  %xmm0,%xmm0
jbe    1172 <rekin+0x32>
movsd  0xe9f(%rip),%xmm0
divsd  %xmm2,%xmm0
call   1050 <exp@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <gausdev@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe83(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
lea    -0x1(%rbx),%edi
call   1040 <rekin_noises@plt>
movsd  0x10(%rsp),%xmm5
movapd %xmm5,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm3
divsd  %xmm1,%xmm3
movsd  0x28(%rsp),%xmm0
subsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm4
mulsd  %xmm4,%xmm3
addsd  %xmm0,%xmm3
addsd  %xmm5,%xmm5
movsd  %xmm5,0x10(%rsp)
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm4,%xmm0
mulsd  0x8(%rsp),%xmm0
ucomisd 0xe14(%rip),%xmm0
jb     120c <rekin+0xcc>
sqrtsd %xmm0,%xmm0
jmp    121d <rekin+0xdd>
movsd  %xmm3,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @rekin(double %0, double %1, i32 %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
store double %3, double* %8
%11 = load double, double* %8
%12 = fcmp ogt double %11, 1.000000e-01
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load double, double* %8
%15 = fdiv double -1.000000e+00, %14
%16 = call double @exp(double %15)
store double %16, double* %9
br label %18
17: ; preds = %4
store double 0.000000e+00, double* %9
br label %18
18: ; preds = %17, %13
%19 = call double (...) @gausdev()
store double %19, double* %10
%20 = load double, double* %5
%21 = load double, double* %9
%22 = fsub double 1.000000e+00, %21
%23 = load double, double* %6
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 1
%26 = call double @rekin_noises(i32 %25)
%27 = load double, double* %10
%28 = load double, double* %10
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double %26)
%30 = fmul double %23, %29
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = fdiv double %30, %32
%34 = load double, double* %5
%35 = fsub double %33, %34
%36 = call double @llvm.fmuladd.f64(double %22, double %35, double %20)
%37 = load double, double* %10
%38 = fmul double 2.000000e+00, %37
%39 = load double, double* %5
%40 = load double, double* %6
%41 = fmul double %39, %40
%42 = load i32, i32* %7
%43 = sitofp i32 %42 to double
%44 = fdiv double %41, %43
%45 = load double, double* %9
%46 = fsub double 1.000000e+00, %45
%47 = fmul double %44, %46
%48 = load double, double* %9
%49 = fmul double %47, %48
%50 = call double @sqrt(double %49)
%51 = call double @llvm.fmuladd.f64(double %38, double %50, double %36)
ret double %51
}

LLVM IR (-O2):
define double @rekin(double %0, double %1, i32 %2, double %3) {
%5 = fcmp ogt double %3, 1.000000e-01
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = fdiv double -1.000000e+00, %3
%8 = tail call double @exp(double %7)
br label %9
9: ; preds = %4, %6
%10 = phi double [ %8, %6 ], [ 0.000000e+00, %4 ]
%11 = tail call double (...) @gausdev()
%12 = fsub double 1.000000e+00, %10
%13 = add nsw i32 %2, -1
%14 = tail call double @rekin_noises(i32 %13)
%15 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %14)
%16 = fmul double %15, %1
%17 = sitofp i32 %2 to double
%18 = fdiv double %16, %17
%19 = fsub double %18, %0
%20 = tail call double @llvm.fmuladd.f64(double %12, double %19, double %0)
%21 = fmul double %11, 2.000000e+00
%22 = fmul double %0, %1
%23 = fdiv double %22, %17
%24 = fmul double %23, %12
%25 = fmul double %10, %24
%26 = tail call double @sqrt(double %25)
%27 = tail call double @llvm.fmuladd.f64(double %21, double %26, double %20)
ret double %27
}