#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 log(double);
int ELK_to_s(double e_val, int n0, int n1, double Lambda, double K, double H) {
  double a_n0, a_n1;
  double a_n0f, mp, np;
  a_n0 = (double)n0;
  a_n1 = (double)n1;
  a_n0f = log(K * a_n0 * a_n1) / H;
  mp = a_n0 - a_n0f;
  np = a_n1 - a_n0f;
  if (np < 1.0)
    np = 1.0;
  if (mp < 1.0)
    mp = 1.0;
  return (int)((log(K * mp * np / e_val)) / Lambda);
}


x86 assembly (clang, -O0):
<ELK_to_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1030 <log@plt>
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe76(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    11a2 <ELK_to_s+0x92>
movsd  0xe63(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe56(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11c2 <ELK_to_s+0xb2>
movsd  0xe43(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ELK_to_s>:
sub    $0x38,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <log@plt>
divsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm3
subsd  %xmm0,%xmm3
movsd  0xe8b(%rip),%xmm0
movapd %xmm0,%xmm1
maxsd  %xmm3,%xmm1
maxsd  %xmm2,%xmm0
mulsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0x28(%rsp),%xmm0
call   1030 <log@plt>
divsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
define i32 @ELK_to_s(double %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double %0, double* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%18 = load i32, i32* %8
%19 = sitofp i32 %18 to double
store double %19, double* %13
%20 = load i32, i32* %9
%21 = sitofp i32 %20 to double
store double %21, double* %14
%22 = load double, double* %11
%23 = load double, double* %13
%24 = fmul double %22, %23
%25 = load double, double* %14
%26 = fmul double %24, %25
%27 = call double @log(double %26)
%28 = load double, double* %12
%29 = fdiv double %27, %28
store double %29, double* %15
%30 = load double, double* %13
%31 = load double, double* %15
%32 = fsub double %30, %31
store double %32, double* %16
%33 = load double, double* %14
%34 = load double, double* %15
%35 = fsub double %33, %34
store double %35, double* %17
%36 = load double, double* %17
%37 = fcmp olt double %36, 1.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %6
store double 1.000000e+00, double* %17
br label %39
39: ; preds = %38, %6
%40 = load double, double* %16
%41 = fcmp olt double %40, 1.000000e+00
br i1 %41, label %42, label %43
42: ; preds = %39
store double 1.000000e+00, double* %16
br label %43
43: ; preds = %42, %39
%44 = load double, double* %11
%45 = load double, double* %16
%46 = fmul double %44, %45
%47 = load double, double* %17
%48 = fmul double %46, %47
%49 = load double, double* %7
%50 = fdiv double %48, %49
%51 = call double @log(double %50)
%52 = load double, double* %10
%53 = fdiv double %51, %52
%54 = fptosi double %53 to i32
ret i32 %54
}

LLVM IR (-O2):
define i32 @ELK_to_s(double %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = sitofp i32 %1 to double
%8 = sitofp i32 %2 to double
%9 = fmul double %7, %4
%10 = fmul double %9, %8
%11 = tail call double @log(double %10)
%12 = fdiv double %11, %5
%13 = fsub double %7, %12
%14 = fsub double %8, %12
%15 = fcmp olt double %14, 1.000000e+00
%16 = select i1 %15, double 1.000000e+00, double %14
%17 = fcmp olt double %13, 1.000000e+00
%18 = select i1 %17, double 1.000000e+00, double %13
%19 = fmul double %18, %4
%20 = fmul double %16, %19
%21 = fdiv double %20, %0
%22 = tail call double @log(double %21)
%23 = fdiv double %22, %3
%24 = fptosi double %23 to i32
ret i32 %24
}