#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 */
scalar_t__ powf(float, int);
int sqrtf(scalar_t__);
float circular_io(float step, float max_steps, float max_val) {
  float ratio = step / (max_steps / 2);
  if (ratio < 1)
    return -max_val / 2 * (sqrtf(1 - powf(ratio, 2)) - 1);
  return max_val / 2 * (sqrtf(1 - powf(ratio - 2, 2)) + 1);
}


x86 assembly (clang, -O0):
<circular_io>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xebb(%rip),%xmm2
divss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xea2(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    11c1 <circular_io+0xa1>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe82(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
mov    $0x1,%edi
sub    %rax,%rdi
call   1040 <sqrtf@plt>
movss  -0x18(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1214 <circular_io+0xf4>
movss  -0x10(%rbp),%xmm0
movss  0xe36(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe20(%rip),%xmm1
subss  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
mov    $0x1,%edi
sub    %rax,%rdi
call   1040 <sqrtf@plt>
movss  -0x1c(%rbp),%xmm0
add    $0x1,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circular_io>:
push   %rbx
sub    $0x10,%rsp
mulss  0xed3(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xecb(%rip),%xmm1
xor    %eax,%eax
xor    %ebx,%ebx
ucomiss %xmm0,%xmm1
seta   %cl
setbe  %dl
ja     1150 <circular_io+0x30>
addss  0xeb8(%rip),%xmm0
mov    %dl,%bl
mov    %cl,%al
lea    0xeb1(%rip),%rcx
mulss  (%rcx,%rax,4),%xmm2
movss  %xmm2,0xc(%rsp)
mov    $0x2,%edi
call   1030 <powf@plt>
mov    $0x1,%edi
sub    %rax,%rdi
call   1040 <sqrtf@plt>
lea    (%rax,%rbx,2),%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @circular_io(float %0, float %1, float %2) {
%4 = alloca float
%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
%9 = load float, float* %5
%10 = load float, float* %6
%11 = fdiv float %10, 2.000000e+00
%12 = fdiv float %9, %11
store float %12, float* %8
%13 = load float, float* %8
%14 = fcmp olt float %13, 1.000000e+00
br i1 %14, label %15, label %26
15: ; preds = %3
%16 = load float, float* %7
%17 = fneg float %16
%18 = fdiv float %17, 2.000000e+00
%19 = load float, float* %8
%20 = call i64 @powf(float %19, i32 2)
%21 = sub nsw i64 1, %20
%22 = call i32 @sqrtf(i64 %21)
%23 = sub nsw i32 %22, 1
%24 = sitofp i32 %23 to float
%25 = fmul float %18, %24
store float %25, float* %4
br label %37
26: ; preds = %3
%27 = load float, float* %7
%28 = fdiv float %27, 2.000000e+00
%29 = load float, float* %8
%30 = fsub float %29, 2.000000e+00
%31 = call i64 @powf(float %30, i32 2)
%32 = sub nsw i64 1, %31
%33 = call i32 @sqrtf(i64 %32)
%34 = add nsw i32 %33, 1
%35 = sitofp i32 %34 to float
%36 = fmul float %28, %35
store float %36, float* %4
br label %37
37: ; preds = %26, %15
%38 = load float, float* %4
ret float %38
}

LLVM IR (-O2):
define float @circular_io(float %0, float %1, float %2) {
%4 = fmul float %1, 5.000000e-01
%5 = fdiv float %0, %4
%6 = fcmp olt float %5, 1.000000e+00
%7 = fadd float %5, -2.000000e+00
%8 = select i1 %6, float %5, float %7
%9 = select i1 %6, i32 -1, i32 1
%10 = select i1 %6, float -5.000000e-01, float 5.000000e-01
%11 = fmul float %10, %2
%12 = tail call i64 @powf(float %8, i32 2)
%13 = sub nsw i64 1, %12
%14 = tail call i32 @sqrtf(i64 %13)
%15 = add nsw i32 %14, %9
%16 = sitofp i32 %15 to float
%17 = fmul float %11, %16
ret float %17
}