#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 */
int /*<<< orphan*/ EM_log(int, char *, double);
double pow(int, double);
double mtof(double f) {
  EM_log(7, "mtof converting midi note %f into frequency", f);
  if (f <= -1500)
    return (0);
  else if (f > 1499)
    return (mtof(1499));
  else {
    double freq = pow(2, (f - 69) / 12.0) * 440.0;
    EM_log(7, "Returning %f", freq);
    return freq;
  }
}


x86 assembly (clang, -O0):
<mtof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x7,%edi
lea    0xeda(%rip),%rsi
call   1030 <EM_log@plt>
movsd  0xea5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1173 <mtof+0x43>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f9 <mtof+0xc9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a1 <mtof+0x71>
movsd  0xe76(%rip),%xmm0
call   1050 <mtof@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11f9 <mtof+0xc9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0xe40(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x7,%edi
lea    0xe6a(%rip),%rsi
call   1030 <EM_log@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtof>:
push   %rax
movsd  %xmm0,(%rsp)
lea    0xf03(%rip),%rsi
mov    $0x7,%edi
call   1030 <EM_log@plt>
xorps  %xmm1,%xmm1
movsd  0xebe(%rip),%xmm0
movsd  (%rsp),%xmm2
ucomisd %xmm2,%xmm0
jae    11bb <mtof+0x9b>
movapd %xmm2,%xmm0
ucomisd 0xeaf(%rip),%xmm2
jbe    117e <mtof+0x5e>
lea    0xece(%rip),%rsi
movsd  0xe9e(%rip),%xmm0
mov    $0x7,%edi
call   1030 <EM_log@plt>
movsd  0xea4(%rip),%xmm0
jmp    118e <mtof+0x6e>
addsd  0xe8a(%rip),%xmm0
divsd  0xe8a(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mulsd  0xe88(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0xeb0(%rip),%rsi
mov    $0x7,%edi
call   1030 <EM_log@plt>
movsd  (%rsp),%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [44 x i8] c"mtof converting midi note %f into frequency\00"
@.str.1 = [13 x i8] c"Returning %f\00"
define double @mtof(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = call i32 @EM_log(i32 7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %5)
%7 = load double, double* %3
%8 = fcmp ole double %7, -1.500000e+03
br i1 %8, label %9, label %10
9: ; preds = %1
store double 0.000000e+00, double* %2
br label %24
10: ; preds = %1
%11 = load double, double* %3
%12 = fcmp ogt double %11, 1.499000e+03
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call double @mtof(double 1.499000e+03)
store double %14, double* %2
br label %24
15: ; preds = %10
%16 = load double, double* %3
%17 = fsub double %16, 6.900000e+01
%18 = fdiv double %17, 1.200000e+01
%19 = call double @pow(i32 2, double %18)
%20 = fmul double %19, 4.400000e+02
store double %20, double* %4
%21 = load double, double* %4
%22 = call i32 @EM_log(i32 7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = load double, double* %4
store double %23, double* %2
br label %24
24: ; preds = %15, %13, %9
%25 = load double, double* %2
ret double %25
}

LLVM IR (-O2):
@.str = [44 x i8] c"mtof converting midi note %f into frequency\00"
@.str.1 = [13 x i8] c"Returning %f\00"
define double @mtof(double %0) {
%2 = tail call i32 @EM_log(i32 7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double %0)
%3 = fcmp ugt double %0, -1.500000e+03
br i1 %3, label %4, label %16
4: ; preds = %1
%5 = fcmp ogt double %0, 1.499000e+03
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @EM_log(i32 7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), double 1.499000e+03)
br label %11
8: ; preds = %4
%9 = fadd double %0, -6.900000e+01
%10 = fdiv double %9, 1.200000e+01
br label %11
11: ; preds = %6, %8
%12 = phi double [ 0x405DCAAAAAAAAAAB, %6 ], [ %10, %8 ]
%13 = tail call double @pow(i32 2, double %12)
%14 = fmul double %13, 4.400000e+02
%15 = tail call i32 @EM_log(i32 7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %14)
br label %16
16: ; preds = %11, %1
%17 = phi double [ 0.000000e+00, %1 ], [ %14, %11 ]
ret double %17
}