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


x86 assembly (clang, -O0):
<float_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b0 <float_sequence+0xa0>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xead(%rip),%xmm0
mulsd  %xmm2,%xmm0
movss  0xe99(%rip),%xmm2
subss  -0x4(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <float_sequence+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<float_sequence>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movss  %xmm0,0x4(%rsp)
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    11a0 <float_sequence+0x80>
lea    0xec9(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x4(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
movaps %xmm0,%xmm1
mulsd  0xe98(%rip),%xmm1
movss  0xe98(%rip),%xmm2
subss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1150 <float_sequence+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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