#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 */
long fact(int);
double falling_fact(double, int);
double pow(double, int);
int /*<<< orphan*/ printf(char *, int, double, double, double, long);
double sav_serie(double x) {
  int n;
  double accumulator = 1, productory = 1;
  for (n = 1; n <= 8; n++) {
    productory = falling_fact(0.5, n);
    double pot = pow(x, n);
    long denominator = fact(n);
    double slice = (productory * pot) / denominator;
    printf("Slice %d: %lf <=> (* %lf * %.2lf) / %li\n", n, slice, productory,
           pot, denominator);
    accumulator += slice;
  }
  return accumulator;
}


x86 assembly (clang, -O0):
<sav_serie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jg     1203 <sav_serie+0xc3>
mov    -0xc(%rbp),%edi
movsd  0xe85(%rip),%xmm0
call   1030 <falling_fact@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1060 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <fact@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvtsi2sdq -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%esi
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x30(%rbp),%rdx
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <sav_serie+0x2e>
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sav_serie>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,(%rsp)
movsd  0xeac(%rip),%xmm0
mov    $0x1,%ebx
lea    0xeb0(%rip),%r14
movsd  %xmm0,0x20(%rsp)
movsd  0xe9a(%rip),%xmm0
mov    %ebx,%edi
call   1030 <falling_fact@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1060 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1050 <fact@plt>
movsd  0x18(%rsp),%xmm1
movapd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
xorps  %xmm3,%xmm3
cvtsi2sd %rax,%xmm3
divsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x1,%ebx
cmp    $0x9,%ebx
jne    1160 <sav_serie+0x20>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Slice %d: %lf <=> (* %lf * %.2lf) / %li\0A\00"
define double @sav_serie(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i64
%8 = alloca double
store double %0, double* %2
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
store i32 1, i32* %3
br label %9
9: ; preds = %35, %1
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 8
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call double @falling_fact(double 5.000000e-01, i32 %13)
store double %14, double* %5
%15 = load double, double* %2
%16 = load i32, i32* %3
%17 = call double @pow(double %15, i32 %16)
store double %17, double* %6
%18 = load i32, i32* %3
%19 = call i64 @fact(i32 %18)
store i64 %19, i64* %7
%20 = load double, double* %5
%21 = load double, double* %6
%22 = fmul double %20, %21
%23 = load i64, i64* %7
%24 = sitofp i64 %23 to double
%25 = fdiv double %22, %24
store double %25, double* %8
%26 = load i32, i32* %3
%27 = load double, double* %8
%28 = load double, double* %5
%29 = load double, double* %6
%30 = load i64, i64* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %26, double %27, double %28, double %29, i64 %30)
%32 = load double, double* %8
%33 = load double, double* %4
%34 = fadd double %33, %32
store double %34, double* %4
br label %35
35: ; preds = %12
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %9
38: ; preds = %9
%39 = load double, double* %4
ret double %39
}

LLVM IR (-O2):
@.str = [41 x i8] c"Slice %d: %lf <=> (* %lf * %.2lf) / %li\0A\00"
define double @sav_serie(double %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 1, %1 ], [ %13, %2 ]
%4 = phi double [ 1.000000e+00, %1 ], [ %12, %2 ]
%5 = tail call double @falling_fact(double 5.000000e-01, i32 %3)
%6 = tail call double @pow(double %0, i32 %3)
%7 = tail call i64 @fact(i32 %3)
%8 = fmul double %5, %6
%9 = sitofp i64 %7 to double
%10 = fdiv double %8, %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %3, double %10, double %5, double %6, i64 %7)
%12 = fadd double %4, %10
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 9
br i1 %14, label %15, label %2
15: ; preds = %2
ret double %12
}