#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 FLT_MAX;
float powf(float, int);
float linecost(float spill, float M, int wc, int justify) {
  float cost;
  if (spill < 0)
    return FLT_MAX;
  cost = powf(spill, 3);
  if (wc > 1 && justify)
    cost /= wc - 1;
  return cost;
}


x86 assembly (clang, -O0):
<linecost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    114a <linecost+0x3a>
mov    0x2eac(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1194 <linecost+0x84>
movss  -0x8(%rbp),%xmm0
mov    $0x3,%edi
call   1030 <powf@plt>
movss  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0x10(%rbp)
jle    118a <linecost+0x7a>
cmpl   $0x0,-0x14(%rbp)
je     118a <linecost+0x7a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linecost>:
push   %rbp
push   %rbx
push   %rax
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    1128 <linecost+0x18>
mov    0x2ec6(%rip),%rax
movss  (%rax),%xmm0
jmp    114d <linecost+0x3d>
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0x3,%edi
call   1030 <powf@plt>
cmp    $0x2,%ebx
jl     114d <linecost+0x3d>
test   %ebp,%ebp
je     114d <linecost+0x3d>
add    $0xffffffff,%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
divss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FLT_MAX = global float 0.000000e+00
define float @linecost(float %0, float %1, i32 %2, i32 %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store float %0, float* %6
store float %1, float* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load float, float* %6
%12 = fcmp olt float %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = load float, float* @FLT_MAX
store float %14, float* %5
br label %31
15: ; preds = %4
%16 = load float, float* %6
%17 = call float @powf(float %16, i32 3)
store float %17, float* %10
%18 = load i32, i32* %8
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = load i32, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = sitofp i32 %25 to float
%27 = load float, float* %10
%28 = fdiv float %27, %26
store float %28, float* %10
br label %29
29: ; preds = %23, %20, %15
%30 = load float, float* %10
store float %30, float* %5
br label %31
31: ; preds = %29, %13
%32 = load float, float* %5
ret float %32
}

LLVM IR (-O2):
@FLT_MAX = global float 0.000000e+00
define float @linecost(float %0, float %1, i32 %2, i32 %3) {
%5 = fcmp olt float %0, 0.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = load float, float* @FLT_MAX
br label %17
8: ; preds = %4
%9 = tail call float @powf(float %0, i32 3)
%10 = icmp sgt i32 %2, 1
%11 = icmp ne i32 %3, 0
%12 = and i1 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = add nsw i32 %2, -1
%15 = sitofp i32 %14 to float
%16 = fdiv float %9, %15
br label %17
17: ; preds = %8, %13, %6
%18 = phi float [ %7, %6 ], [ %16, %13 ], [ %9, %8 ]
ret float %18
}