#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 */
double pnf_cooc(double, double, double, double, double);
double pnf_cooc_test_alt(double lambda_i, double lambda_r, double v_i,
                         double v_r, double delta, unsigned int n_v_i_steps) {
  double dvi;
  double vii;
  double result = 0;
  if (n_v_i_steps < 2)
    n_v_i_steps = 2;
  dvi = v_i / n_v_i_steps;
  for (vii = dvi; vii <= v_i; vii += dvi) {
    const double cooc = pnf_cooc(lambda_i, lambda_r, vii, v_r, delta);
    if (cooc > result)
      result = cooc;
  }
  return result;
}


x86 assembly (clang, -O0):
<pnf_cooc_test_alt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %edi,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jae    114d <pnf_cooc_test_alt+0x3d>
movl   $0x2,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11d7 <pnf_cooc_test_alt+0xc7>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
call   1030 <pnf_cooc@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11be <pnf_cooc_test_alt+0xae>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11c3 <pnf_cooc_test_alt+0xb3>
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    116d <pnf_cooc_test_alt+0x5d>
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnf_cooc_test_alt>:
sub    $0x48,%rsp
movapd %xmm0,%xmm5
cmp    $0x3,%edi
mov    $0x2,%eax
cmovae %edi,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd %xmm2,%xmm6
divsd  %xmm0,%xmm6
xorpd  %xmm0,%xmm0
movsd  %xmm6,0x8(%rsp)
ucomisd %xmm6,%xmm2
jb     11c3 <pnf_cooc_test_alt+0xb3>
xorpd  %xmm7,%xmm7
movsd  0x8(%rsp),%xmm6
movsd  %xmm4,0x30(%rsp)
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm5,0x10(%rsp)
nop
movsd  %xmm7,0x38(%rsp)
movsd  %xmm6,0x40(%rsp)
movapd %xmm5,%xmm0
movsd  0x18(%rsp),%xmm1
movapd %xmm6,%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x30(%rsp),%xmm4
call   1030 <pnf_cooc@plt>
movsd  0x40(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movsd  0x20(%rsp),%xmm2
maxsd  0x38(%rsp),%xmm0
addsd  0x8(%rsp),%xmm6
ucomisd %xmm6,%xmm2
movapd %xmm0,%xmm7
jae    1170 <pnf_cooc_test_alt+0x60>
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @pnf_cooc_test_alt(double %0, double %1, double %2, double %3, double %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store i32 %5, i32* %12
store double 0.000000e+00, double* %15
%17 = load i32, i32* %12
%18 = icmp ult i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %6
store i32 2, i32* %12
br label %20
20: ; preds = %19, %6
%21 = load double, double* %9
%22 = load i32, i32* %12
%23 = uitofp i32 %22 to double
%24 = fdiv double %21, %23
store double %24, double* %13
%25 = load double, double* %13
store double %25, double* %14
br label %26
26: ; preds = %43, %20
%27 = load double, double* %14
%28 = load double, double* %9
%29 = fcmp ole double %27, %28
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = load double, double* %7
%32 = load double, double* %8
%33 = load double, double* %14
%34 = load double, double* %10
%35 = load double, double* %11
%36 = call double @pnf_cooc(double %31, double %32, double %33, double %34, double %35)
store double %36, double* %16
%37 = load double, double* %16
%38 = load double, double* %15
%39 = fcmp ogt double %37, %38
br i1 %39, label %40, label %42
40: ; preds = %30
%41 = load double, double* %16
store double %41, double* %15
br label %42
42: ; preds = %40, %30
br label %43
43: ; preds = %42
%44 = load double, double* %13
%45 = load double, double* %14
%46 = fadd double %45, %44
store double %46, double* %14
br label %26
47: ; preds = %26
%48 = load double, double* %15
ret double %48
}

LLVM IR (-O2):
define double @pnf_cooc_test_alt(double %0, double %1, double %2, double %3, double %4, i32 %5) {
%7 = icmp ugt i32 %5, 2
%8 = select i1 %7, i32 %5, i32 2
%9 = uitofp i32 %8 to double
%10 = fdiv double %2, %9
%11 = fcmp ugt double %10, %2
br i1 %11, label %20, label %12
12: ; preds = %6, %12
%13 = phi double [ %18, %12 ], [ %10, %6 ]
%14 = phi double [ %17, %12 ], [ 0.000000e+00, %6 ]
%15 = tail call double @pnf_cooc(double %0, double %1, double %13, double %3, double %4)
%16 = fcmp ogt double %15, %14
%17 = select i1 %16, double %15, double %14
%18 = fadd double %10, %13
%19 = fcmp ugt double %18, %2
br i1 %19, label %20, label %12
20: ; preds = %12, %6
%21 = phi double [ 0.000000e+00, %6 ], [ %17, %12 ]
ret double %21
}