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


x86 assembly (clang, -O0):
<formant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <floor@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <cosine@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <cosine@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe35(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    121c <formant+0xdc>
movsd  0xe3a(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <cosine@plt>
mulsd  -0x20(%rbp),%xmm0
call   1040 <cosh@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cosh@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    127b <formant+0x13b>
movsd  0xdf4(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1060 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdc9(%rip),%xmm0
mov    0x2d9a(%rip),%rax
mulsd  (%rax),%xmm0
mov    0x2d8f(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <fexp@plt>
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formant>:
sub    $0x38,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x30(%rsp)
movapd %xmm1,%xmm0
call   1060 <floor@plt>
movsd  %xmm0,0x18(%rsp)
mulsd  0x8(%rsp),%xmm0
call   1030 <cosine@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0xe82(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <cosine@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xe6b(%rip),%xmm0
ucomisd 0x10(%rsp),%xmm0
jbe    11e0 <formant+0xa0>
movsd  0x8(%rsp),%xmm0
mulsd  0xe5d(%rip),%xmm0
call   1030 <cosine@plt>
mulsd  0x10(%rsp),%xmm0
call   1040 <cosh@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cosh@plt>
movsd  0x8(%rsp),%xmm3
divsd  %xmm0,%xmm3
jmp    122f <formant+0xef>
movsd  0xe28(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1060 <floor@plt>
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
mov    0x2de4(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe08(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
call   1050 <fexp@plt>
movapd %xmm0,%xmm3
movsd  0x30(%rsp),%xmm2
subsd  0x18(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
add    $0x38,%rsp
ret

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

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