#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 */
float psnd_scale_xref(float, float, float, int);
float psnd_chan2hz(float chan, float sw, int n, float xref, float aref,
                   float bref, int irc) {
  xref = psnd_scale_xref(xref, aref, bref, irc);
  if (n != 1)
    return (xref - chan) * (sw / ((float)(n - 1)));
  return 0.0;
}


x86 assembly (clang, -O0):
<psnd_chan2hz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  %xmm4,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
mov    -0x20(%rbp),%edi
call   1030 <psnd_scale_xref@plt>
movss  %xmm0,-0x14(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1188 <psnd_chan2hz+0x78>
movss  -0x14(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1190 <psnd_chan2hz+0x80>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psnd_chan2hz>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
movaps %xmm2,%xmm0
movaps %xmm3,%xmm1
movaps %xmm4,%xmm2
mov    %esi,%edi
call   1030 <psnd_scale_xref@plt>
xorps  %xmm1,%xmm1
cmp    $0x1,%ebx
je     115c <psnd_chan2hz+0x4c>
add    $0xffffffff,%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
subss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm2
divss  %xmm1,%xmm2
mulss  %xmm0,%xmm2
movaps %xmm2,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @psnd_chan2hz(float %0, float %1, i32 %2, float %3, float %4, float %5, i32 %6) {
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca i32
store float %0, float* %9
store float %1, float* %10
store i32 %2, i32* %11
store float %3, float* %12
store float %4, float* %13
store float %5, float* %14
store i32 %6, i32* %15
%16 = load float, float* %12
%17 = load float, float* %13
%18 = load float, float* %14
%19 = load i32, i32* %15
%20 = call float @psnd_scale_xref(float %16, float %17, float %18, i32 %19)
store float %20, float* %12
%21 = load i32, i32* %11
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %33
23: ; preds = %7
%24 = load float, float* %12
%25 = load float, float* %9
%26 = fsub float %24, %25
%27 = load float, float* %10
%28 = load i32, i32* %11
%29 = sub nsw i32 %28, 1
%30 = sitofp i32 %29 to float
%31 = fdiv float %27, %30
%32 = fmul float %26, %31
store float %32, float* %8
br label %34
33: ; preds = %7
store float 0.000000e+00, float* %8
br label %34
34: ; preds = %33, %23
%35 = load float, float* %8
ret float %35
}

LLVM IR (-O2):
define float @psnd_chan2hz(float %0, float %1, i32 %2, float %3, float %4, float %5, i32 %6) {
%8 = tail call float @psnd_scale_xref(float %3, float %4, float %5, i32 %6)
%9 = icmp eq i32 %2, 1
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = fsub float %8, %0
%12 = add nsw i32 %2, -1
%13 = sitofp i32 %12 to float
%14 = fdiv float %1, %13
%15 = fmul float %14, %11
br label %16
16: ; preds = %7, %10
%17 = phi float [ %15, %10 ], [ 0.000000e+00, %7 ]
ret float %17
}