#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*/ printf(char *, ...);
void double_sequence(double x0, int q) {
  double tmp, tmp2;
  int i;
  printf("double\n");
  for (i = 0; i < q; ++i) {
    tmp = x0 + 3.0 * x0 * (1 - x0);
    printf("%e\n", tmp);
    x0 = tmp;
  }
}


x86 assembly (clang, -O0):
<double_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1198 <double_sequence+0x88>
movsd  -0x8(%rbp),%xmm1
movsd  0xeba(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xea5(%rip),%xmm2
subsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe9f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1135 <double_sequence+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_sequence>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movsd  %xmm0,(%rsp)
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    1189 <double_sequence+0x69>
lea    0xece(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
mulsd  0xe9f(%rip),%xmm2
movsd  0xe9f(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    %r14,%rdi
movsd  %xmm0,(%rsp)
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1150 <double_sequence+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"double\0A\00"
@.str.1 = [4 x i8] c"%e\0A\00"
define void @double_sequence(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load double, double* %3
%15 = load double, double* %3
%16 = fmul double 3.000000e+00, %15
%17 = load double, double* %3
%18 = fsub double 1.000000e+00, %17
%19 = call double @llvm.fmuladd.f64(double %16, double %18, double %14)
store double %19, double* %5
%20 = load double, double* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = load double, double* %5
store double %22, double* %3
br label %23
23: ; preds = %13
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %9
26: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%e\0A\00"
@str = [7 x i8] c"double\00"
define void @double_sequence(double %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %14
5: ; preds = %2, %5
%6 = phi i32 [ %12, %5 ], [ 0, %2 ]
%7 = phi double [ %10, %5 ], [ %0, %2 ]
%8 = fmul double %7, 3.000000e+00
%9 = fsub double 1.000000e+00, %7
%10 = tail call double @llvm.fmuladd.f64(double %8, double %9, double %7)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %5
14: ; preds = %5, %2
ret void
}