#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n;
  float sum = 0.0, x = 0.9;
  printf("Enter the number of terms you want to sum up: ");
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    sum += x;
    x = 0.9 + (x * 0.1);
  }
  printf("\nThe sum of the series is %.2f", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xec1(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bc <main+0x9c>
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe73(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <main+0x49>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    1165 <main+0x45>
lea    -0x1(%rcx),%edx
mov    %ecx,%eax
and    $0x3,%eax
cmp    $0x3,%edx
jae    116d <main+0x4d>
xorps  %xmm0,%xmm0
movss  0xea0(%rip),%xmm1
jmp    11f1 <main+0xd1>
xorps  %xmm0,%xmm0
jmp    122d <main+0x10d>
and    $0xfffffffc,%ecx
xorps  %xmm0,%xmm0
movss  0xe85(%rip),%xmm1
movsd  0xe85(%rip),%xmm2
movsd  0xe85(%rip),%xmm3
nopl   0x0(%rax,%rax,1)
xorps  %xmm4,%xmm4
cvtss2sd %xmm1,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
cvtsd2ss %xmm4,%xmm4
addss  %xmm1,%xmm0
addss  %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm4,%xmm4
cvtss2sd %xmm1,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
cvtsd2ss %xmm4,%xmm4
addss  %xmm1,%xmm0
addss  %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
cvtsd2ss %xmm1,%xmm1
add    $0xfffffffc,%ecx
jne    1190 <main+0x70>
test   %eax,%eax
je     1229 <main+0x109>
movsd  0xe0b(%rip),%xmm2
movsd  0xe0b(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nop
addss  %xmm1,%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
cvtsd2ss %xmm1,%xmm1
add    $0xffffffff,%eax
jne    1210 <main+0xf0>
cvtss2sd %xmm0,%xmm0
lea    0xe16(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Enter the number of terms you want to sum up: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"\0AThe sum of the series is %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %3
store float 0x3FECCCCCC0000000, float* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %5
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load float, float* %4
%14 = load float, float* %3
%15 = fadd float %14, %13
store float %15, float* %3
%16 = load float, float* %4
%17 = fpext float %16 to double
%18 = call double @llvm.fmuladd.f64(double %17, double 1.000000e-01, double 9.000000e-01)
%19 = fptrunc double %18 to float
store float %19, float* %4
br label %20
20: ; preds = %12
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
%24 = load float, float* %3
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Enter the number of terms you want to sum up: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"\0AThe sum of the series is %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %31, label %7
7: ; preds = %0
%8 = add i32 %5, -1
%9 = and i32 %5, 3
%10 = icmp ult i32 %8, 3
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = and i32 %5, -4
br label %34
13: ; preds = %34, %7
%14 = phi float [ undef, %7 ], [ %50, %34 ]
%15 = phi float [ 0x3FECCCCCC0000000, %7 ], [ %53, %34 ]
%16 = phi float [ 0.000000e+00, %7 ], [ %50, %34 ]
%17 = icmp eq i32 %9, 0
br i1 %17, label %28, label %18
18: ; preds = %13, %18
%19 = phi float [ %25, %18 ], [ %15, %13 ]
%20 = phi float [ %22, %18 ], [ %16, %13 ]
%21 = phi i32 [ %26, %18 ], [ 0, %13 ]
%22 = fadd float %20, %19
%23 = fpext float %19 to double
%24 = call double @llvm.fmuladd.f64(double %23, double 1.000000e-01, double 9.000000e-01)
%25 = fptrunc double %24 to float
%26 = add i32 %21, 1
%27 = icmp eq i32 %26, %9
br i1 %27, label %28, label %18
28: ; preds = %18, %13
%29 = phi float [ %14, %13 ], [ %22, %18 ]
%30 = fpext float %29 to double
br label %31
31: ; preds = %28, %0
%32 = phi double [ 0.000000e+00, %0 ], [ %30, %28 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %32)
ret i32 0
34: ; preds = %34, %11
%35 = phi float [ 0x3FECCCCCC0000000, %11 ], [ %53, %34 ]
%36 = phi float [ 0.000000e+00, %11 ], [ %50, %34 ]
%37 = phi i32 [ 0, %11 ], [ %54, %34 ]
%38 = fadd float %36, %35
%39 = fpext float %35 to double
%40 = call double @llvm.fmuladd.f64(double %39, double 1.000000e-01, double 9.000000e-01)
%41 = fptrunc double %40 to float
%42 = fadd float %38, %41
%43 = fpext float %41 to double
%44 = call double @llvm.fmuladd.f64(double %43, double 1.000000e-01, double 9.000000e-01)
%45 = fptrunc double %44 to float
%46 = fadd float %42, %45
%47 = fpext float %45 to double
%48 = call double @llvm.fmuladd.f64(double %47, double 1.000000e-01, double 9.000000e-01)
%49 = fptrunc double %48 to float
%50 = fadd float %46, %49
%51 = fpext float %49 to double
%52 = call double @llvm.fmuladd.f64(double %51, double 1.000000e-01, double 9.000000e-01)
%53 = fptrunc double %52 to float
%54 = add i32 %37, 4
%55 = icmp eq i32 %54, %12
br i1 %55, label %13, label %34
}