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


x86 assembly (clang, -O0):
<psnd_hz2chan>:
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)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1174 <psnd_hz2chan+0x64>
jp     1174 <psnd_hz2chan+0x64>
jmp    119f <psnd_hz2chan+0x8f>
movss  -0x14(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm2
mulss  %xmm2,%xmm1
divss  -0xc(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a7 <psnd_hz2chan+0x97>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psnd_hz2chan>:
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>
movss  0xc(%rsp),%xmm2
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
jne    1143 <psnd_hz2chan+0x33>
jnp    115e <psnd_hz2chan+0x4e>
add    $0xffffffff,%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
mulss  0x8(%rsp),%xmm1
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movaps %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @psnd_hz2chan(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 float, float* %10
%22 = fpext float %21 to double
%23 = fcmp une double %22, 0.000000e+00
br i1 %23, label %24, label %34
24: ; preds = %7
%25 = load float, float* %12
%26 = load float, float* %9
%27 = load i32, i32* %11
%28 = sub nsw i32 %27, 1
%29 = sitofp i32 %28 to float
%30 = fmul float %26, %29
%31 = load float, float* %10
%32 = fdiv float %30, %31
%33 = fsub float %25, %32
store float %33, float* %8
br label %35
34: ; preds = %7
store float 0.000000e+00, float* %8
br label %35
35: ; preds = %34, %24
%36 = load float, float* %8
ret float %36
}

LLVM IR (-O2):
define float @psnd_hz2chan(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 = fcmp une float %1, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = add nsw i32 %2, -1
%12 = sitofp i32 %11 to float
%13 = fmul float %12, %0
%14 = fdiv float %13, %1
%15 = fsub float %8, %14
br label %16
16: ; preds = %7, %10
%17 = phi float [ %15, %10 ], [ 0.000000e+00, %7 ]
ret float %17
}