#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, float);
float calculate_work(float grade, float mass, float distance) {
  float cost = 280.5 * pow(grade, 5.0f) + -58.7f * pow(grade, 4.0f) +
               -76.8f * pow(grade, 3.0f) + 51.9f * pow(grade, 2.0f) +
               19.6f * grade + 2.5;
  return cost * mass * distance;
}


x86 assembly (clang, -O0):
<calculate_work>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xef8(%rip),%xmm1
call   1030 <pow@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xed9(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movss  0xec0(%rip),%xmm1
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe94(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe92(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movss  0xe79(%rip),%xmm1
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe57(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
movss  0xe3e(%rip),%xmm1
mulss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movss  0xe26(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_work>:
sub    $0x18,%rsp
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0x4(%rsp)
movss  0xed2(%rip),%xmm1
call   1030 <pow@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movss  0xebf(%rip),%xmm1
movss  0x4(%rsp),%xmm0
call   1030 <pow@plt>
mulss  0xeb0(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xeb6(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movss  0xe90(%rip),%xmm1
movss  0x4(%rsp),%xmm0
call   1030 <pow@plt>
mulss  0xe81(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm2
movaps %xmm2,%xmm1
mulss  %xmm2,%xmm1
mulss  0xe66(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm1
mulss  0xe5a(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe57(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  0x10(%rsp),%xmm0
mulss  0x14(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @calculate_work(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %4
%9 = call float @pow(float %8, float 5.000000e+00)
%10 = fpext float %9 to double
%11 = load float, float* %4
%12 = call float @pow(float %11, float 4.000000e+00)
%13 = fmul float 0xC04D5999A0000000, %12
%14 = fpext float %13 to double
%15 = call double @llvm.fmuladd.f64(double 2.805000e+02, double %10, double %14)
%16 = load float, float* %4
%17 = call float @pow(float %16, float 3.000000e+00)
%18 = fmul float 0xC053333340000000, %17
%19 = fpext float %18 to double
%20 = fadd double %15, %19
%21 = load float, float* %4
%22 = call float @pow(float %21, float 2.000000e+00)
%23 = fmul float 0x4049F33340000000, %22
%24 = fpext float %23 to double
%25 = fadd double %20, %24
%26 = load float, float* %4
%27 = fmul float 0x40339999A0000000, %26
%28 = fpext float %27 to double
%29 = fadd double %25, %28
%30 = fadd double %29, 2.500000e+00
%31 = fptrunc double %30 to float
store float %31, float* %7
%32 = load float, float* %7
%33 = load float, float* %5
%34 = fmul float %32, %33
%35 = load float, float* %6
%36 = fmul float %34, %35
ret float %36
}

LLVM IR (-O2):
define float @calculate_work(float %0, float %1, float %2) {
%4 = tail call float @pow(float %0, float 5.000000e+00)
%5 = fpext float %4 to double
%6 = tail call float @pow(float %0, float 4.000000e+00)
%7 = fmul float %6, 0xC04D5999A0000000
%8 = fpext float %7 to double
%9 = tail call double @llvm.fmuladd.f64(double %5, double 2.805000e+02, double %8)
%10 = tail call float @pow(float %0, float 3.000000e+00)
%11 = fmul float %10, 0xC053333340000000
%12 = fpext float %11 to double
%13 = fadd double %9, %12
%14 = fmul float %0, %0
%15 = fmul float %14, 0x4049F33340000000
%16 = fpext float %15 to double
%17 = fadd double %13, %16
%18 = fmul float %0, 0x40339999A0000000
%19 = fpext float %18 to double
%20 = fadd double %17, %19
%21 = fadd double %20, 2.500000e+00
%22 = fptrunc double %21 to float
%23 = fmul float %22, %1
%24 = fmul float %23, %2
ret float %24
}