#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 MAX(float, float);
int /*<<< orphan*/ assert(int);
void lr_to_vb(float left, float right, float *volume, float *balance) {
  assert((left >= 0.0) && (right >= 0.0));
  *volume = MAX(left, right);
  if (left > right)
    *balance = -1.0 + right / left;
  else if (right > left)
    *balance = 1.0 - left / right;
  else
    *balance = 0.0;
}


x86 assembly (clang, -O0):
<lr_to_vb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jb     116b <lr_to_vb+0x4b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <MAX@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11c9 <lr_to_vb+0xa9>
movss  -0x8(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe54(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1213 <lr_to_vb+0xf3>
movss  -0x8(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1203 <lr_to_vb+0xe3>
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe12(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    120e <lr_to_vb+0xee>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1213 <lr_to_vb+0xf3>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lr_to_vb>:
push   %r14
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
movss  %xmm1,(%rsp)
setae  %al
ucomiss %xmm2,%xmm1
mov    %rsi,%r14
mov    %rdi,%rbx
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
movss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
call   1030 <MAX@plt>
movss  (%rsp),%xmm2
movss  %xmm0,(%rbx)
movss  0x4(%rsp),%xmm0
ucomiss %xmm2,%xmm0
jbe    1183 <lr_to_vb+0x63>
divss  %xmm0,%xmm2
addss  0xe86(%rip),%xmm2
movaps %xmm2,%xmm1
jmp    119b <lr_to_vb+0x7b>
ucomiss %xmm0,%xmm2
xorps  %xmm1,%xmm1
jbe    119b <lr_to_vb+0x7b>
divss  %xmm2,%xmm0
movss  0xe69(%rip),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @lr_to_vb(float %0, float %1, float* %2, float* %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
store float %0, float* %5
store float %1, float* %6
store float* %2, float** %7
store float* %3, float** %8
%9 = load float, float* %5
%10 = fpext float %9 to double
%11 = fcmp oge double %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load float, float* %6
%14 = fpext float %13 to double
%15 = fcmp oge double %14, 0.000000e+00
br label %16
16: ; preds = %12, %4
%17 = phi i1 [ false, %4 ], [ %15, %12 ]
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load float, float* %5
%21 = load float, float* %6
%22 = call float @MAX(float %20, float %21)
%23 = load float*, float** %7
store float %22, float* %23
%24 = load float, float* %5
%25 = load float, float* %6
%26 = fcmp ogt float %24, %25
br i1 %26, label %27, label %35
27: ; preds = %16
%28 = load float, float* %6
%29 = load float, float* %5
%30 = fdiv float %28, %29
%31 = fpext float %30 to double
%32 = fadd double -1.000000e+00, %31
%33 = fptrunc double %32 to float
%34 = load float*, float** %8
store float %33, float* %34
br label %50
35: ; preds = %16
%36 = load float, float* %6
%37 = load float, float* %5
%38 = fcmp ogt float %36, %37
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load float, float* %5
%41 = load float, float* %6
%42 = fdiv float %40, %41
%43 = fpext float %42 to double
%44 = fsub double 1.000000e+00, %43
%45 = fptrunc double %44 to float
%46 = load float*, float** %8
store float %45, float* %46
br label %49
47: ; preds = %35
%48 = load float*, float** %8
store float 0.000000e+00, float* %48
br label %49
49: ; preds = %47, %39
br label %50
50: ; preds = %49, %27
ret void
}

LLVM IR (-O2):
define void @lr_to_vb(float %0, float %1, float* nocapture writeonly %2, float* nocapture writeonly %3) {
%5 = fcmp oge float %0, 0.000000e+00
%6 = fcmp oge float %1, 0.000000e+00
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call float @MAX(float %0, float %1)
store float %10, float* %2
%11 = fcmp ogt float %0, %1
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = fdiv float %1, %0
%14 = fadd float %13, -1.000000e+00
br label %20
15: ; preds = %4
%16 = fcmp ogt float %1, %0
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = fdiv float %0, %1
%19 = fsub float 1.000000e+00, %18
br label %20
20: ; preds = %15, %17, %12
%21 = phi float [ %19, %17 ], [ %14, %12 ], [ 0.000000e+00, %15 ]
store float %21, float* %3
ret void
}