#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
double get_lyapunov(double, double, double, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_iter_seq(int /*<<< orphan*/ *, double, int, int);
int main(void) {
  FILE *fout = fopen("state_logistic", "w");
  double lambda;
  if (fout == NULL) {
    perror("fopen() state_logistic");
    abort();
  }
  for (lambda = 0.0; lambda <= 4; lambda += 0.01) {
    print_iter_seq(fout, lambda, 512, 128);
  }
  fclose(fout);
  fout = fopen("lyapunov_logistic", "w");
  if (fout == NULL) {
    perror("fopen() lyapunov_logistic");
    abort();
  }
  for (lambda = 0.0; lambda <= 4; lambda += 0.01) {
    fprintf(fout, "%.12f %.12f\n", lambda,
            get_lyapunov(lambda, (0.789), 0.01, 1024));
  }
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b4 <main+0x44>
lea    0xe72(%rip),%rdi
call   1080 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe3c(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11fe <main+0x8e>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
mov    $0x200,%esi
mov    $0x80,%edx
call   1090 <print_iter_seq@plt>
movsd  0xe21(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11bc <main+0x4c>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xe2b(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    123c <main+0xcc>
lea    0xe01(%rip),%rdi
call   1080 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdb4(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     12b7 <main+0x147>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd92(%rip),%xmm1
movsd  0xd92(%rip),%xmm2
mov    $0x400,%edi
call   1040 <get_lyapunov@plt>
mov    -0x28(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
lea    0xdb0(%rip),%rsi
call   1060 <fprintf@plt>
movsd  0xd68(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1244 <main+0xd4>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea7(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1274 <main+0x104>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
mov    $0x200,%esi
mov    $0x80,%edx
call   1090 <print_iter_seq@plt>
movsd  (%rsp),%xmm0
addsd  0xe37(%rip),%xmm0
movsd  0xe37(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11a0 <main+0x30>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe53(%rip),%rdi
lea    0xe2b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     127d <main+0x10d>
mov    %rax,%rbx
xorpd  %xmm1,%xmm1
lea    0xe42(%rip),%r14
nopl   0x0(%rax)
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
movsd  0xdef(%rip),%xmm1
movsd  0xdd7(%rip),%xmm2
mov    $0x400,%edi
call   1040 <get_lyapunov@plt>
movapd %xmm0,%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  (%rsp),%xmm0
call   1060 <fprintf@plt>
movsd  (%rsp),%xmm1
addsd  0xdac(%rip),%xmm1
movsd  0xdac(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1210 <main+0xa0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd9f(%rip),%rdi
jmp    1284 <main+0x114>
lea    0xdad(%rip),%rdi
call   1080 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"state_logistic\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [23 x i8] c"fopen() state_logistic\00"
@.str.3 = [18 x i8] c"lyapunov_logistic\00"
@.str.4 = [26 x i8] c"fopen() lyapunov_logistic\00"
@.str.5 = [13 x i8] c"%.12f %.12f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca double
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
store double 0.000000e+00, double* %3
br label %11
11: ; preds = %18, %10
%12 = load double, double* %3
%13 = fcmp ole double %12, 4.000000e+00
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32*, i32** %2
%16 = load double, double* %3
%17 = call i32 @print_iter_seq(i32* %15, double %16, i32 512, i32 128)
br label %18
18: ; preds = %14
%19 = load double, double* %3
%20 = fadd double %19, 1.000000e-02
store double %20, double* %3
br label %11
21: ; preds = %11
%22 = load i32*, i32** %2
%23 = call i32 @fclose(i32* %22)
%24 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %2
%25 = load i32*, i32** %2
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %21
store double 0.000000e+00, double* %3
br label %31
31: ; preds = %40, %30
%32 = load double, double* %3
%33 = fcmp ole double %32, 4.000000e+00
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i32*, i32** %2
%36 = load double, double* %3
%37 = load double, double* %3
%38 = call double @get_lyapunov(double %37, double 7.890000e-01, double 1.000000e-02, i32 1024)
%39 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %36, double %38)
br label %40
40: ; preds = %34
%41 = load double, double* %3
%42 = fadd double %41, 1.000000e-02
store double %42, double* %3
br label %31
43: ; preds = %31
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"state_logistic\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [23 x i8] c"fopen() state_logistic\00"
@.str.3 = [18 x i8] c"lyapunov_logistic\00"
@.str.4 = [26 x i8] c"fopen() lyapunov_logistic\00"
@.str.5 = [13 x i8] c"%.12f %.12f\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %0, %6
%7 = phi double [ %9, %6 ], [ 0.000000e+00, %0 ]
%8 = tail call i32 @print_iter_seq(i32* %1, double %7, i32 512, i32 128)
%9 = fadd double %7, 1.000000e-02
%10 = fcmp ugt double %9, 4.000000e+00
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = tail call i32 @fclose(i32* %1)
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 (...) @abort()
unreachable
18: ; preds = %11, %18
%19 = phi double [ %22, %18 ], [ 0.000000e+00, %11 ]
%20 = tail call double @get_lyapunov(double %19, double 7.890000e-01, double 1.000000e-02, i32 1024)
%21 = tail call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %19, double %20)
%22 = fadd double %19, 1.000000e-02
%23 = fcmp ugt double %22, 4.000000e+00
br i1 %23, label %24, label %18
24: ; preds = %18
%25 = tail call i32 @fclose(i32* %13)
ret i32 0
}