#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_LN2;
double log(double);
void c2spd_to_note(int c2spd, int *n, int *f) {
  int c;
  if (c2spd == 0) {
    *n = *f = 0;
    return;
  }
  c = (int)(1536.0 * log((double)c2spd / 8363) / M_LN2);
  *n = c / 128;
  *f = c % 128;
}


x86 assembly (clang, -O0):
<c2spd_to_note>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1146 <c2spd_to_note+0x36>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11a1 <c2spd_to_note+0x91>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe99(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2e6e(%rip),%rax
divsd  (%rax),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c2spd_to_note>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
test   %edi,%edi
je     115f <c2spd_to_note+0x4f>
cvtsi2sd %edi,%xmm0
divsd  0xed6(%rip),%xmm0
call   1030 <log@plt>
mulsd  0xed1(%rip),%xmm0
mov    0x2ea2(%rip),%rax
divsd  (%rax),%xmm0
cvttsd2si %xmm0,%eax
lea    0x7f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
mov    %ecx,%edx
sar    $0x7,%edx
mov    %edx,(%rbx)
and    $0xffffff80,%ecx
sub    %ecx,%eax
mov    %eax,(%r14)
jmp    116c <c2spd_to_note+0x5c>
movl   $0x0,(%r14)
movl   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_LN2 = global double 0.000000e+00
define void @c2spd_to_note(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32*, i32** %6
store i32 0, i32* %11
%12 = load i32*, i32** %5
store i32 0, i32* %12
br label %28
13: ; preds = %3
%14 = load i32, i32* %4
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 8.363000e+03
%17 = call double @log(double %16)
%18 = fmul double 1.536000e+03, %17
%19 = load double, double* @M_LN2
%20 = fdiv double %18, %19
%21 = fptosi double %20 to i32
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = sdiv i32 %22, 128
%24 = load i32*, i32** %5
store i32 %23, i32* %24
%25 = load i32, i32* %7
%26 = srem i32 %25, 128
%27 = load i32*, i32** %6
store i32 %26, i32* %27
br label %28
28: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@M_LN2 = global double 0.000000e+00
define void @c2spd_to_note(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %6
5: ; preds = %3
store i32 0, i32* %2
store i32 0, i32* %1
br label %16
6: ; preds = %3
%7 = sitofp i32 %0 to double
%8 = fdiv double %7, 8.363000e+03
%9 = tail call double @log(double %8)
%10 = fmul double %9, 1.536000e+03
%11 = load double, double* @M_LN2
%12 = fdiv double %10, %11
%13 = fptosi double %12 to i32
%14 = sdiv i32 %13, 128
store i32 %14, i32* %1
%15 = srem i32 %13, 128
store i32 %15, i32* %2
br label %16
16: ; preds = %6, %5
ret void
}