#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 */
int pow(float, int);
float cubic_io(float step, float max_steps, float max_val) {
  float ratio = step / (max_steps / 2.0);
  if (ratio < 1)
    return max_val / 2 * pow(ratio, 3);
  return max_val / 2 * (pow(ratio - 2, 3) + 2);
}


x86 assembly (clang, -O0):
<cubic_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
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xec7(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xea6(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    11a0 <cubic_io+0x90>
movss  -0x10(%rbp),%xmm0
movss  0xe93(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <pow@plt>
movss  -0x18(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e6 <cubic_io+0xd6>
movss  -0x10(%rbp),%xmm0
movss  0xe57(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe41(%rip),%xmm1
subss  %xmm1,%xmm0
mov    $0x3,%edi
call   1030 <pow@plt>
movss  -0x1c(%rbp),%xmm0
add    $0x2,%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):
<cubic_io>:
push   %rax
cvtss2sd %xmm1,%xmm1
mulsd  0xee3(%rip),%xmm1
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm2,0x4(%rsp)
movss  0xed1(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1148 <cubic_io+0x38>
mov    $0x3,%edi
call   1030 <pow@plt>
jmp    115d <cubic_io+0x4d>
addss  0xebc(%rip),%xmm0
mov    $0x3,%edi
call   1030 <pow@plt>
add    $0x2,%eax
movss  0x4(%rsp),%xmm1
mulss  0xea5(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  %xmm1,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define float @cubic_io(float %0, float %1, float %2) {
%4 = fpext float %0 to double
%5 = fpext float %1 to double
%6 = fmul double %5, 5.000000e-01
%7 = fdiv double %4, %6
%8 = fptrunc double %7 to float
%9 = fcmp olt float %8, 1.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @pow(float %8, i32 3)
br label %16
12: ; preds = %3
%13 = fadd float %8, -2.000000e+00
%14 = tail call i32 @pow(float %13, i32 3)
%15 = add nsw i32 %14, 2
br label %16
16: ; preds = %12, %10
%17 = phi i32 [ %15, %12 ], [ %11, %10 ]
%18 = fmul float %2, 5.000000e-01
%19 = sitofp i32 %17 to float
%20 = fmul float %18, %19
ret float %20
}