#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 gausdev();
double gdev(int);
double rekin_noises(int n) {
  double r;
  if (n == 0) {
    return 0.0;
  } else if (n == 1) {
    r = gausdev();
    return r * r;
  } else if (n % 2 == 0) {
    return 2.0 * gdev(n / 2);
  } else {
    r = gausdev();
    return 2.0 * gdev((n - 1) / 2) + r * r;
  }
}


x86 assembly (clang, -O0):
<rekin_noises>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1142 <rekin_noises+0x22>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <rekin_noises+0xc3>
cmpl   $0x1,-0xc(%rbp)
jne    116c <rekin_noises+0x4c>
mov    $0x0,%al
call   1030 <gausdev@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <rekin_noises+0xc3>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ab <rekin_noises+0x8b>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <gdev@plt>
movaps %xmm0,%xmm1
movsd  0xe63(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <rekin_noises+0xc3>
mov    $0x0,%al
call   1030 <gausdev@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <gdev@plt>
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rekin_noises>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     113d <rekin_noises+0x1d>
mov    %edi,%ebx
cmp    $0x1,%edi
jne    1143 <rekin_noises+0x23>
xor    %eax,%eax
call   1030 <gausdev@plt>
mulsd  %xmm0,%xmm0
jmp    1190 <rekin_noises+0x70>
xorpd  %xmm0,%xmm0
jmp    1190 <rekin_noises+0x70>
test   $0x1,%bl
jne    115c <rekin_noises+0x3c>
mov    %ebx,%edi
shr    $0x1f,%edi
add    %ebx,%edi
sar    %edi
call   1040 <gdev@plt>
addsd  %xmm0,%xmm0
jmp    1190 <rekin_noises+0x70>
xor    %eax,%eax
call   1030 <gausdev@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%eax
add    $0xffffffff,%eax
shr    $0x1f,%eax
lea    (%rbx,%rax,1),%edi
add    $0xffffffff,%edi
sar    %edi
call   1040 <gdev@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @rekin_noises(i32 %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store double 0.000000e+00, double* %2
br label %35
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call double (...) @gausdev()
store double %12, double* %4
%13 = load double, double* %4
%14 = load double, double* %4
%15 = fmul double %13, %14
store double %15, double* %2
br label %35
16: ; preds = %8
%17 = load i32, i32* %3
%18 = srem i32 %17, 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 2
%23 = call double @gdev(i32 %22)
%24 = fmul double 2.000000e+00, %23
store double %24, double* %2
br label %35
25: ; preds = %16
%26 = call double (...) @gausdev()
store double %26, double* %4
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
%29 = sdiv i32 %28, 2
%30 = call double @gdev(i32 %29)
%31 = load double, double* %4
%32 = load double, double* %4
%33 = fmul double %31, %32
%34 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %30, double %33)
store double %34, double* %2
br label %35
35: ; preds = %25, %20, %11, %7
%36 = load double, double* %2
ret double %36
}

LLVM IR (-O2):
define double @rekin_noises(i32 %0) {
switch i32 %0, label %5 [
i32 0, label %19
i32 1, label %2
]
2: ; preds = %1
%3 = tail call double (...) @gausdev()
%4 = fmul double %3, %3
br label %19
5: ; preds = %1
%6 = and i32 %0, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = sdiv i32 %0, 2
%10 = tail call double @gdev(i32 %9)
%11 = fmul double %10, 2.000000e+00
br label %19
12: ; preds = %5
%13 = tail call double (...) @gausdev()
%14 = add nsw i32 %0, -1
%15 = sdiv i32 %14, 2
%16 = tail call double @gdev(i32 %15)
%17 = fmul double %13, %13
%18 = tail call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double %17)
br label %19
19: ; preds = %1, %12, %8, %2
%20 = phi double [ %4, %2 ], [ %11, %8 ], [ %18, %12 ], [ 0.000000e+00, %1 ]
ret double %20
}