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


x86 assembly (clang, -O0):
<psnd_chan2ppm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  %xmm4,-0x1c(%rbp)
movss  %xmm5,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
mov    -0x24(%rbp),%edi
call   1030 <psnd_scale_xref@plt>
movss  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     11b3 <psnd_chan2ppm+0xa3>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1183 <psnd_chan2ppm+0x73>
jp     1183 <psnd_chan2ppm+0x73>
jmp    11b3 <psnd_chan2ppm+0xa3>
movss  -0x18(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11bb <psnd_chan2ppm+0xab>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psnd_chan2ppm>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x4(%rsp)
movaps %xmm3,%xmm0
movaps %xmm4,%xmm1
movaps %xmm5,%xmm2
mov    %esi,%edi
call   1030 <psnd_scale_xref@plt>
movss  0xc(%rsp),%xmm3
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm3
jne    1149 <psnd_chan2ppm+0x39>
jnp    1173 <psnd_chan2ppm+0x63>
cmp    $0x1,%ebx
je     1173 <psnd_chan2ppm+0x63>
add    $0xffffffff,%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
subss  0x4(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
divss  %xmm1,%xmm2
mulss  %xmm0,%xmm2
divss  %xmm3,%xmm2
movaps %xmm2,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

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