#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 bounce_in(float, float, float);
float bounce_out(float, float, float);
float bounce_io(float step, float max_steps, float max_val) {
  if (step < max_steps / 2)
    return bounce_in(step * 2, max_steps, max_val) * 0.5f;
  else
    return bounce_out(step * 2 - max_steps, max_steps, max_val) * 0.5f +
           max_val * 0.5f;
}


x86 assembly (clang, -O0):
<bounce_io>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movss  0xeb7(%rip),%xmm2
divss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jbe    1188 <bounce_io+0x68>
movss  0xea2(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1030 <bounce_in@plt>
movss  0xe8a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d8 <bounce_io+0xb8>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1040 <bounce_out@plt>
movss  0xe46(%rip),%xmm1
mulss  -0x10(%rbp),%xmm1
movss  0xe39(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bounce_io>:
push   %rax
movss  0xed7(%rip),%xmm3
mulss  %xmm1,%xmm3
ucomiss %xmm0,%xmm3
jbe    1145 <bounce_io+0x25>
addss  %xmm0,%xmm0
call   1030 <bounce_in@plt>
mulss  0xebd(%rip),%xmm0
pop    %rax
ret
addss  %xmm0,%xmm0
subss  %xmm1,%xmm0
movss  %xmm2,0x4(%rsp)
call   1040 <bounce_out@plt>
movss  0xea0(%rip),%xmm1
movss  0x4(%rsp),%xmm2
mulss  %xmm1,%xmm2
mulss  %xmm1,%xmm0
addss  %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @bounce_io(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%8 = load float, float* %5
%9 = load float, float* %6
%10 = fdiv float %9, 2.000000e+00
%11 = fcmp olt float %8, %10
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load float, float* %5
%14 = fmul float %13, 2.000000e+00
%15 = load float, float* %6
%16 = load float, float* %7
%17 = call float @bounce_in(float %14, float %15, float %16)
%18 = fmul float %17, 5.000000e-01
store float %18, float* %4
br label %30
19: ; preds = %3
%20 = load float, float* %5
%21 = load float, float* %6
%22 = fneg float %21
%23 = call float @llvm.fmuladd.f32(float %20, float 2.000000e+00, float %22)
%24 = load float, float* %6
%25 = load float, float* %7
%26 = call float @bounce_out(float %23, float %24, float %25)
%27 = load float, float* %7
%28 = fmul float %27, 5.000000e-01
%29 = call float @llvm.fmuladd.f32(float %26, float 5.000000e-01, float %28)
store float %29, float* %4
br label %30
30: ; preds = %19, %12
%31 = load float, float* %4
ret float %31
}

LLVM IR (-O2):
define float @bounce_io(float %0, float %1, float %2) {
%4 = fmul float %1, 5.000000e-01
%5 = fcmp ogt float %4, %0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = fmul float %0, 2.000000e+00
%8 = tail call float @bounce_in(float %7, float %1, float %2)
%9 = fmul float %8, 5.000000e-01
br label %16
10: ; preds = %3
%11 = fneg float %1
%12 = tail call float @llvm.fmuladd.f32(float %0, float 2.000000e+00, float %11)
%13 = tail call float @bounce_out(float %12, float %1, float %2)
%14 = fmul float %2, 5.000000e-01
%15 = tail call float @llvm.fmuladd.f32(float %13, float 5.000000e-01, float %14)
br label %16
16: ; preds = %10, %6
%17 = phi float [ %9, %6 ], [ %15, %10 ]
ret float %17
}