#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 */
int /*<<< orphan*/ assert(int);
double fabs(double);
double iter_fcn(double, double);
int log(double);
double get_lyapunov(double lambda, double x, double delta, int nsteps) {
  int i;
  double y = x + delta;
  assert(delta > 0);
  for (i = 0; i < nsteps; i++) {
    x = iter_fcn(lambda, x);
    y = iter_fcn(lambda, y);
  }
  return (log(fabs(y - x) / delta)) / nsteps;
}


x86 assembly (clang, -O0):
<get_lyapunov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bb <get_lyapunov+0x8b>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <iter_fcn@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <iter_fcn@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1179 <get_lyapunov+0x49>
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe34(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
cltd
idivl  -0x1c(%rbp)
cvtsi2sd %eax,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_lyapunov>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
xor    %edi,%edi
movsd  %xmm2,0x20(%rsp)
ucomisd %xmm0,%xmm2
seta   %dil
call   1040 <assert@plt>
test   %ebx,%ebx
jle    11b2 <get_lyapunov+0x82>
mov    %ebx,%ebp
movapd 0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
nopl   0x0(%rax,%rax,1)
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <iter_fcn@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <iter_fcn@plt>
movsd  (%rsp),%xmm1
add    $0xffffffff,%ebp
jne    1180 <get_lyapunov+0x50>
jmp    11bd <get_lyapunov+0x8d>
movapd 0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm1,%xmm0
andpd  0xe37(%rip),%xmm0
divsd  0x20(%rsp),%xmm0
call   1050 <log@plt>
cltd
idiv   %ebx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @get_lyapunov(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
%11 = load double, double* %6
%12 = load double, double* %7
%13 = fadd double %11, %12
store double %13, double* %10
%14 = load double, double* %7
%15 = fcmp ogt double %14, 0.000000e+00
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store i32 0, i32* %9
br label %18
18: ; preds = %29, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load double, double* %5
%24 = load double, double* %6
%25 = call double @iter_fcn(double %23, double %24)
store double %25, double* %6
%26 = load double, double* %5
%27 = load double, double* %10
%28 = call double @iter_fcn(double %26, double %27)
store double %28, double* %10
br label %29
29: ; preds = %22
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %18
32: ; preds = %18
%33 = load double, double* %10
%34 = load double, double* %6
%35 = fsub double %33, %34
%36 = call double @llvm.fabs.f64(double %35)
%37 = load double, double* %7
%38 = fdiv double %36, %37
%39 = call i32 @log(double %38)
%40 = load i32, i32* %8
%41 = sdiv i32 %39, %40
%42 = sitofp i32 %41 to double
ret double %42
}

LLVM IR (-O2):
define double @get_lyapunov(double %0, double %1, double %2, i32 %3) {
%5 = fadd double %1, %2
%6 = fcmp ogt double %2, 0.000000e+00
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %18
10: ; preds = %4, %10
%11 = phi double [ %15, %10 ], [ %5, %4 ]
%12 = phi i32 [ %16, %10 ], [ 0, %4 ]
%13 = phi double [ %14, %10 ], [ %1, %4 ]
%14 = tail call double @iter_fcn(double %0, double %13)
%15 = tail call double @iter_fcn(double %0, double %11)
%16 = add nuw nsw i32 %12, 1
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %10
18: ; preds = %10, %4
%19 = phi double [ %1, %4 ], [ %14, %10 ]
%20 = phi double [ %5, %4 ], [ %15, %10 ]
%21 = fsub double %20, %19
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fdiv double %22, %2
%24 = tail call i32 @log(double %23)
%25 = sdiv i32 %24, %3
%26 = sitofp i32 %25 to double
ret double %26
}