#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 M_PI;
double cosh(double);
double cosine(double);
double fexp(double);
scalar_t__ floor(double);
double _formant(double phase, int ratio, double width) {
  if (width < 700) {
    return cosh(cosine(0.5 * phase) * width) / cosh(width) *
           cosine(phase * ratio);
  } else {
    phase -= floor(phase + 0.5);
    return fexp(-0.5 * M_PI * M_PI * width * phase * phase) *
           cosine(phase * ratio);
  }
}


x86 assembly (clang, -O0):
<_formant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  0xea3(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11cd <_formant+0x8d>
movsd  0xea0(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <cosine@plt>
mulsd  -0x20(%rbp),%xmm0
call   1040 <cosh@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cosh@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cosine@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124d <_formant+0x10d>
movsd  0xe3b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1060 <floor@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe0e(%rip),%xmm0
mov    0x2de7(%rip),%rax
mulsd  (%rax),%xmm0
mov    0x2ddc(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <fexp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cosine@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_formant>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movapd %xmm0,%xmm2
movsd  0xead(%rip),%xmm0
movsd  %xmm1,0x18(%rsp)
ucomisd %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  0xe9d(%rip),%xmm0
jbe    11b1 <_formant+0x71>
mulsd  %xmm2,%xmm0
call   1030 <cosine@plt>
mulsd  0x18(%rsp),%xmm0
call   1040 <cosh@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cosh@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
jmp    1213 <_formant+0xd3>
addsd  %xmm2,%xmm0
call   1060 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    0x2e0f(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe2b(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
call   1050 <fexp@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cosine@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @_formant(double %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
store double %0, double* %5
store i32 %1, i32* %6
store double %2, double* %7
%8 = load double, double* %7
%9 = fcmp olt double %8, 7.000000e+02
br i1 %9, label %10, label %26
10: ; preds = %3
%11 = load double, double* %5
%12 = fmul double 5.000000e-01, %11
%13 = call double @cosine(double %12)
%14 = load double, double* %7
%15 = fmul double %13, %14
%16 = call double @cosh(double %15)
%17 = load double, double* %7
%18 = call double @cosh(double %17)
%19 = fdiv double %16, %18
%20 = load double, double* %5
%21 = load i32, i32* %6
%22 = sitofp i32 %21 to double
%23 = fmul double %20, %22
%24 = call double @cosine(double %23)
%25 = fmul double %19, %24
store double %25, double* %4
br label %50
26: ; preds = %3
%27 = load double, double* %5
%28 = fadd double %27, 5.000000e-01
%29 = call i64 @floor(double %28)
%30 = sitofp i64 %29 to double
%31 = load double, double* %5
%32 = fsub double %31, %30
store double %32, double* %5
%33 = load double, double* @M_PI
%34 = fmul double -5.000000e-01, %33
%35 = load double, double* @M_PI
%36 = fmul double %34, %35
%37 = load double, double* %7
%38 = fmul double %36, %37
%39 = load double, double* %5
%40 = fmul double %38, %39
%41 = load double, double* %5
%42 = fmul double %40, %41
%43 = call double @fexp(double %42)
%44 = load double, double* %5
%45 = load i32, i32* %6
%46 = sitofp i32 %45 to double
%47 = fmul double %44, %46
%48 = call double @cosine(double %47)
%49 = fmul double %43, %48
store double %49, double* %4
br label %50
50: ; preds = %26, %10
%51 = load double, double* %4
ret double %51
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @_formant(double %0, i32 %1, double %2) {
%4 = fcmp olt double %2, 7.000000e+02
br i1 %4, label %5, label %13
5: ; preds = %3
%6 = fmul double %0, 5.000000e-01
%7 = tail call double @cosine(double %6)
%8 = fmul double %7, %2
%9 = tail call double @cosh(double %8)
%10 = tail call double @cosh(double %2)
%11 = fdiv double %9, %10
%12 = sitofp i32 %1 to double
br label %26
13: ; preds = %3
%14 = fadd double %0, 5.000000e-01
%15 = tail call i64 @floor(double %14)
%16 = sitofp i64 %15 to double
%17 = fsub double %0, %16
%18 = load double, double* @M_PI
%19 = fmul double %18, -5.000000e-01
%20 = fmul double %18, %19
%21 = fmul double %20, %2
%22 = fmul double %17, %21
%23 = fmul double %17, %22
%24 = tail call double @fexp(double %23)
%25 = sitofp i32 %1 to double
br label %26
26: ; preds = %13, %5
%27 = phi double [ %25, %13 ], [ %0, %5 ]
%28 = phi double [ %17, %13 ], [ %12, %5 ]
%29 = phi double [ %24, %13 ], [ %11, %5 ]
%30 = fmul double %28, %27
%31 = tail call double @cosine(double %30)
%32 = fmul double %29, %31
ret double %32
}