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


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
movss  -0xc(%rbp),%xmm1
movss  0xecb(%rip),%xmm2
divss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeb2(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1193 <quadratic_io+0x83>
movss  -0x10(%rbp),%xmm0
movss  0xe9f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1219 <quadratic_io+0x109>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xe5f(%rip),%xmm2
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xe4a(%rip),%xmm2
divss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm1
movss  0xe30(%rip),%xmm0
divss  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xe1f(%rip),%xmm2
divss  %xmm2,%xmm0
mulss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movss  0xe09(%rip),%xmm3
subss  %xmm3,%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quadratic_io>:
push   %rax
mulss  0xee7(%rip),%xmm1
movaps %xmm0,%xmm4
divss  %xmm1,%xmm4
movss  0xedc(%rip),%xmm3
ucomiss %xmm4,%xmm3
jbe    1150 <quadratic_io+0x40>
mulss  0xecb(%rip),%xmm2
movss  %xmm2,0x4(%rsp)
movaps %xmm4,%xmm0
mov    $0x2,%edi
call   1030 <powf@plt>
mulss  0x4(%rsp),%xmm0
pop    %rax
ret
subss  %xmm1,%xmm0
divss  %xmm1,%xmm0
mulss  0xea0(%rip),%xmm2
movss  0xea0(%rip),%xmm1
addss  %xmm0,%xmm1
mulss  %xmm2,%xmm0
mulss  %xmm1,%xmm0
subss  %xmm0,%xmm2
movaps %xmm2,%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 = 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 %21
15: ; preds = %3
%16 = load float, float* %7
%17 = fdiv float %16, 2.000000e+00
%18 = load float, float* %8
%19 = call float @powf(float %18, i32 2)
%20 = fmul float %17, %19
store float %20, float* %4
br label %39
21: ; preds = %3
%22 = load float, float* %5
%23 = load float, float* %6
%24 = fdiv float %23, 2.000000e+00
%25 = fsub float %22, %24
%26 = load float, float* %6
%27 = fdiv float %26, 2.000000e+00
%28 = fdiv float %25, %27
store float %28, float* %8
%29 = load float, float* %7
%30 = fdiv float %29, 2.000000e+00
%31 = load float, float* %7
%32 = fdiv float %31, 2.000000e+00
%33 = load float, float* %8
%34 = fmul float %32, %33
%35 = load float, float* %8
%36 = fsub float %35, 2.000000e+00
%37 = fneg float %34
%38 = call float @llvm.fmuladd.f32(float %37, float %36, float %30)
store float %38, float* %4
br label %39
39: ; preds = %21, %15
%40 = load float, float* %4
ret float %40
}

LLVM IR (-O2):
define float @quadratic_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
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = fmul float %2, 5.000000e-01
%9 = tail call float @powf(float %5, i32 2)
%10 = fmul float %8, %9
br label %19
11: ; preds = %3
%12 = fsub float %0, %4
%13 = fdiv float %12, %4
%14 = fmul float %2, 5.000000e-01
%15 = fadd float %13, -2.000000e+00
%16 = fneg float %14
%17 = fmul float %13, %16
%18 = tail call float @llvm.fmuladd.f32(float %17, float %15, float %14)
br label %19
19: ; preds = %11, %7
%20 = phi float [ %10, %7 ], [ %18, %11 ]
ret float %20
}