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


x86 assembly (clang, -O0):
<quadratic_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    11ab <quadratic_io+0x9b>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe93(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1263 <quadratic_io+0x153>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe43(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe2a(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe08(%rip),%xmm0
divsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf3(%rip),%xmm2
divsd  %xmm2,%xmm0
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm0
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movsd  0xdd1(%rip),%xmm3
subsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quadratic_io>:
push   %rax
cvtss2sd %xmm1,%xmm1
mulsd  0xee3(%rip),%xmm1
cvtss2sd %xmm0,%xmm3
movaps %xmm3,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xedc(%rip),%xmm4
ucomiss %xmm0,%xmm4
jbe    1162 <quadratic_io+0x52>
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  0xeb8(%rip),%xmm1
movsd  %xmm1,(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
cvtss2sd %xmm0,%xmm0
mulsd  (%rsp),%xmm0
jmp    119c <quadratic_io+0x8c>
subsd  %xmm1,%xmm3
divsd  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsd2ss %xmm3,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulsd  0xe80(%rip),%xmm0
cvtss2sd %xmm1,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe74(%rip),%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @quadratic_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 %27
18: ; preds = %3
%19 = load float, float* %7
%20 = fpext float %19 to double
%21 = fdiv double %20, 2.000000e+00
%22 = load float, float* %8
%23 = call float @pow(float %22, i32 2)
%24 = fpext float %23 to double
%25 = fmul double %21, %24
%26 = fptrunc double %25 to float
store float %26, float* %4
br label %54
27: ; preds = %3
%28 = load float, float* %5
%29 = fpext float %28 to double
%30 = load float, float* %6
%31 = fpext float %30 to double
%32 = fdiv double %31, 2.000000e+00
%33 = fsub double %29, %32
%34 = load float, float* %6
%35 = fpext float %34 to double
%36 = fdiv double %35, 2.000000e+00
%37 = fdiv double %33, %36
%38 = fptrunc double %37 to float
store float %38, float* %8
%39 = load float, float* %7
%40 = fpext float %39 to double
%41 = fdiv double %40, 2.000000e+00
%42 = load float, float* %7
%43 = fpext float %42 to double
%44 = fdiv double %43, 2.000000e+00
%45 = load float, float* %8
%46 = fpext float %45 to double
%47 = fmul double %44, %46
%48 = load float, float* %8
%49 = fpext float %48 to double
%50 = fsub double %49, 2.000000e+00
%51 = fneg double %47
%52 = call double @llvm.fmuladd.f64(double %51, double %50, double %41)
%53 = fptrunc double %52 to float
store float %53, float* %4
br label %54
54: ; preds = %27, %18
%55 = load float, float* %4
ret float %55
}

LLVM IR (-O2):
define float @quadratic_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 %16
10: ; preds = %3
%11 = fpext float %2 to double
%12 = fmul double %11, 5.000000e-01
%13 = tail call float @pow(float %8, i32 2)
%14 = fpext float %13 to double
%15 = fmul double %12, %14
br label %27
16: ; preds = %3
%17 = fsub double %4, %6
%18 = fdiv double %17, %6
%19 = fptrunc double %18 to float
%20 = fpext float %2 to double
%21 = fmul double %20, 5.000000e-01
%22 = fpext float %19 to double
%23 = fadd double %22, -2.000000e+00
%24 = fneg double %21
%25 = fmul double %24, %22
%26 = tail call double @llvm.fmuladd.f64(double %25, double %23, double %21)
br label %27
27: ; preds = %16, %10
%28 = phi double [ %15, %10 ], [ %26, %16 ]
%29 = fptrunc double %28 to float
ret float %29
}