#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 fabs(double);
double log(double);
scalar_t__ sizeq(double, double);
double cntevents(double dur, double s0, double s1) {
  double f1 = dur, f2;
  if (sizeq(s1, s0))
    return ((f1 * 2.0) / (s1 + s0));
  f2 = s1 - s0;
  f1 /= f2;
  f2 = s1 / s0;
  f2 = log(f2);
  f1 *= f2;
  return (fabs(f1));
}


x86 assembly (clang, -O0):
<cntevents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <sizeq@plt>
cmp    $0x0,%rax
je     117f <cntevents+0x5f>
movsd  0xeae(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <cntevents+0xc3>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xe26(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cntevents>:
sub    $0x18,%rsp
movsd  %xmm0,(%rsp)
movsd  %xmm2,0x10(%rsp)
movaps %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <sizeq@plt>
test   %rax,%rax
je     1160 <cntevents+0x40>
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm1
movsd  (%rsp),%xmm3
divsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
divsd  %xmm2,%xmm0
call   1040 <log@plt>
mulsd  (%rsp),%xmm0
andpd  0xe68(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @cntevents(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %5
store double %10, double* %8
%11 = load double, double* %7
%12 = load double, double* %6
%13 = call i64 @sizeq(double %11, double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %3
%16 = load double, double* %8
%17 = fmul double %16, 2.000000e+00
%18 = load double, double* %7
%19 = load double, double* %6
%20 = fadd double %18, %19
%21 = fdiv double %17, %20
store double %21, double* %4
br label %39
22: ; preds = %3
%23 = load double, double* %7
%24 = load double, double* %6
%25 = fsub double %23, %24
store double %25, double* %9
%26 = load double, double* %9
%27 = load double, double* %8
%28 = fdiv double %27, %26
store double %28, double* %8
%29 = load double, double* %7
%30 = load double, double* %6
%31 = fdiv double %29, %30
store double %31, double* %9
%32 = load double, double* %9
%33 = call double @log(double %32)
store double %33, double* %9
%34 = load double, double* %9
%35 = load double, double* %8
%36 = fmul double %35, %34
store double %36, double* %8
%37 = load double, double* %8
%38 = call double @llvm.fabs.f64(double %37)
store double %38, double* %4
br label %39
39: ; preds = %22, %15
%40 = load double, double* %4
ret double %40
}

LLVM IR (-O2):
define double @cntevents(double %0, double %1, double %2) {
%4 = tail call i64 @sizeq(double %2, double %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = fmul double %0, 2.000000e+00
%8 = fadd double %1, %2
%9 = fdiv double %7, %8
br label %17
10: ; preds = %3
%11 = fsub double %2, %1
%12 = fdiv double %0, %11
%13 = fdiv double %2, %1
%14 = tail call double @log(double %13)
%15 = fmul double %12, %14
%16 = tail call double @llvm.fabs.f64(double %15)
br label %17
17: ; preds = %10, %6
%18 = phi double [ %9, %6 ], [ %16, %10 ]
ret double %18
}