#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 */
double bounce_in(float, float, float);
double 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.5;
  else
    return bounce_out(step * 2 - max_steps, max_steps, max_val) * 0.5 +
           max_val * 0.5;
}


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    118c <bounce_io+0x6c>
movss  0xea2(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
call   1030 <bounce_in@plt>
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e8 <bounce_io+0xc8>
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  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe3d(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe31(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%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>
mulsd  0xec5(%rip),%xmm0
jmp    1176 <bounce_io+0x56>
addss  %xmm0,%xmm0
subss  %xmm1,%xmm0
movss  %xmm2,0x4(%rsp)
call   1040 <bounce_out@plt>
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe9e(%rip),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%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 %20
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 double @bounce_in(float %14, float %15, float %16)
%18 = fmul double %17, 5.000000e-01
%19 = fptrunc double %18 to float
store float %19, float* %4
br label %33
20: ; preds = %3
%21 = load float, float* %5
%22 = load float, float* %6
%23 = fneg float %22
%24 = call float @llvm.fmuladd.f32(float %21, float 2.000000e+00, float %23)
%25 = load float, float* %6
%26 = load float, float* %7
%27 = call double @bounce_out(float %24, float %25, float %26)
%28 = load float, float* %7
%29 = fpext float %28 to double
%30 = fmul double %29, 5.000000e-01
%31 = call double @llvm.fmuladd.f64(double %27, double 5.000000e-01, double %30)
%32 = fptrunc double %31 to float
store float %32, float* %4
br label %33
33: ; preds = %20, %12
%34 = load float, float* %4
ret float %34
}

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 double @bounce_in(float %7, float %1, float %2)
%9 = fmul double %8, 5.000000e-01
br label %17
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 double @bounce_out(float %12, float %1, float %2)
%14 = fpext float %2 to double
%15 = fmul double %14, 5.000000e-01
%16 = tail call double @llvm.fmuladd.f64(double %13, double 5.000000e-01, double %15)
br label %17
17: ; preds = %10, %6
%18 = phi double [ %9, %6 ], [ %16, %10 ]
%19 = fptrunc double %18 to float
ret float %19
}