#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 _redistribVal(float);
float applyMode(int mode, float t) {
  switch (mode) {
  case 0:
    return 0.5f * t + 0.5f * _redistribVal(t);
  case 1:
    return 0.5f * t + 0.5f * (1.f - _redistribVal(1.f - t));
  default:
    return t;
  }
}


x86 assembly (clang, -O0):
<applyMode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1144 <applyMode+0x34>
jmp    1133 <applyMode+0x23>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1186 <applyMode+0x76>
jmp    11dc <applyMode+0xcc>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <_redistribVal@plt>
movaps %xmm0,%xmm2
movss  -0x14(%rbp),%xmm0
movss  0xe98(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xe8c(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e6 <applyMode+0xd6>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe6c(%rip),%xmm0
subss  -0xc(%rbp),%xmm0
call   1030 <_redistribVal@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  0xe52(%rip),%xmm2
subss  %xmm1,%xmm2
movss  0xe42(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xe36(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e6 <applyMode+0xd6>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<applyMode>:
push   %rax
movaps %xmm0,%xmm1
cmp    $0x1,%edi
je     1147 <applyMode+0x37>
test   %edi,%edi
jne    1186 <applyMode+0x76>
movaps %xmm1,%xmm0
movss  %xmm1,0x4(%rsp)
call   1030 <_redistribVal@plt>
movss  0xed1(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm2
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
pop    %rax
ret
movss  0xeb1(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm1,0x4(%rsp)
call   1030 <_redistribVal@plt>
movss  0xe9a(%rip),%xmm1
subss  %xmm0,%xmm1
movss  0xe92(%rip),%xmm2
mulss  %xmm2,%xmm1
movss  0x4(%rsp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
pop    %rax
ret
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @applyMode(i32 %0, float %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca float
store i32 %0, i32* %4
store float %1, float* %5
%6 = load i32, i32* %4
switch i32 %6, label %21 [
i32 0, label %7
i32 1, label %13
]
7: ; preds = %2
%8 = load float, float* %5
%9 = load float, float* %5
%10 = call float @_redistribVal(float %9)
%11 = fmul float 5.000000e-01, %10
%12 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %8, float %11)
store float %12, float* %3
br label %23
13: ; preds = %2
%14 = load float, float* %5
%15 = load float, float* %5
%16 = fsub float 1.000000e+00, %15
%17 = call float @_redistribVal(float %16)
%18 = fsub float 1.000000e+00, %17
%19 = fmul float 5.000000e-01, %18
%20 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %14, float %19)
store float %20, float* %3
br label %23
21: ; preds = %2
%22 = load float, float* %5
store float %22, float* %3
br label %23
23: ; preds = %21, %13, %7
%24 = load float, float* %3
ret float %24
}

LLVM IR (-O2):
define float @applyMode(i32 %0, float %1) {
switch i32 %0, label %13 [
i32 0, label %3
i32 1, label %7
]
3: ; preds = %2
%4 = tail call float @_redistribVal(float %1)
%5 = fmul float %4, 5.000000e-01
%6 = tail call float @llvm.fmuladd.f32(float %1, float 5.000000e-01, float %5)
br label %13
7: ; preds = %2
%8 = fsub float 1.000000e+00, %1
%9 = tail call float @_redistribVal(float %8)
%10 = fsub float 1.000000e+00, %9
%11 = fmul float %10, 5.000000e-01
%12 = tail call float @llvm.fmuladd.f32(float %1, float 5.000000e-01, float %11)
br label %13
13: ; preds = %2, %7, %3
%14 = phi float [ %12, %7 ], [ %6, %3 ], [ %1, %2 ]
ret float %14
}