#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 pow(int, int);
int /*<<< orphan*/ printf(char *, double);
void ex5() {
  int i = 0;
  double seq = 0;
  while (++i < 101) {
    seq += (-1. / i) * pow(-1, i);
  }
  printf("Sequencia: %.8f", seq);
}


x86 assembly (clang, -O0):
<ex5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x65,%eax
jge    118c <ex5+0x6c>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeaa(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    $0xffffffff,%edi
call   1040 <pow@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1137 <ex5+0x17>
movsd  -0x10(%rbp),%xmm0
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex5>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
movsd  0xeca(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  0xeb4(%rip),%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0xffffffff,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0xffffffff,%edi
call   1040 <pow@plt>
movsd  0x18(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0xe46(%rip),%xmm2
add    $0x2,%ebx
cmp    $0x65,%ebx
jne    1140 <ex5+0x20>
lea    0xe3b(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Sequencia: %.8f\00"
define void @ex5() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
br label %3
3: ; preds = %7, %0
%4 = load i32, i32* %1
%5 = add nsw i32 %4, 1
store i32 %5, i32* %1
%6 = icmp slt i32 %5, 101
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = load i32, i32* %1
%9 = sitofp i32 %8 to double
%10 = fdiv double -1.000000e+00, %9
%11 = load i32, i32* %1
%12 = call i32 @pow(i32 -1, i32 %11)
%13 = sitofp i32 %12 to double
%14 = load double, double* %2
%15 = call double @llvm.fmuladd.f64(double %10, double %13, double %14)
store double %15, double* %2
br label %3
16: ; preds = %3
%17 = load double, double* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %17)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Sequencia: %.8f\00"
define void @ex5() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 1, %0 ], [ %15, %1 ]
%3 = phi double [ 0.000000e+00, %0 ], [ %14, %1 ]
%4 = sitofp i32 %2 to double
%5 = fdiv double -1.000000e+00, %4
%6 = tail call i32 @pow(i32 -1, i32 %2)
%7 = sitofp i32 %6 to double
%8 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %3)
%9 = add nuw nsw i32 %2, 1
%10 = sitofp i32 %9 to double
%11 = fdiv double -1.000000e+00, %10
%12 = tail call i32 @pow(i32 -1, i32 %9)
%13 = sitofp i32 %12 to double
%14 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %8)
%15 = add nuw nsw i32 %2, 2
%16 = icmp eq i32 %15, 101
br i1 %16, label %17, label %1
17: ; preds = %1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %14)
ret void
}