#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 */
double fat(long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double som(long long);
void main() {
  printf("Este programa foi escrito por Jessica Cristina Cacau Patricio.\n\n");
  double num, total = 0.0;
  long long int i;
  printf("Digite um inteiro positivo: ");
  scanf("%lf", &num);
  for (i = 1; i <= num; i++) {
    if (i % 2 == 0)
      total -= som(i) / fat(i);
    else
      total += som(i) / fat(i);
  }
  printf("\nTotal = %.15lf\n", total);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movq   $0x1,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1227 <main+0xe7>
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11e4 <main+0xa4>
mov    -0x18(%rbp),%rdi
call   1030 <som@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fat@plt>
movsd  -0x20(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1211 <main+0xd1>
mov    -0x18(%rbp),%rdi
call   1030 <som@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fat@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1216 <main+0xd6>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1184 <main+0x44>
movsd  -0x10(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd 0xe6c(%rip),%xmm1
jae    11ac <main+0x5c>
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
xorpd  %xmm0,%xmm0
mov    $0x2,%ebx
jmp    11e1 <main+0x91>
nopw   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
movsd  0x8(%rsp),%xmm1
add    $0x1,%rbx
ucomisd %xmm2,%xmm1
jb     1196 <main+0x46>
movsd  %xmm0,(%rsp)
lea    -0x1(%rbx),%r14
mov    %r14,%rdi
call   1040 <som@plt>
movapd %xmm0,0x10(%rsp)
mov    %r14,%rdi
call   1070 <fat@plt>
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
test   $0x1,%r14b
jne    11c0 <main+0x70>
xorpd  0xdf8(%rip),%xmm1
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@.str = [65 x i8] c"Este programa foi escrito por Jessica Cristina Cacau Patricio.\0A\0A\00"
@.str.1 = [29 x i8] c"Digite um inteiro positivo: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [17 x i8] c"\0ATotal = %.15lf\0A\00"
define void @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i64
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
store i64 1, i64* %3
br label %7
7: ; preds = %33, %0
%8 = load i64, i64* %3
%9 = sitofp i64 %8 to double
%10 = load double, double* %1
%11 = fcmp ole double %9, %10
br i1 %11, label %12, label %36
12: ; preds = %7
%13 = load i64, i64* %3
%14 = srem i64 %13, 2
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i64, i64* %3
%18 = call double @som(i64 %17)
%19 = load i64, i64* %3
%20 = call double @fat(i64 %19)
%21 = fdiv double %18, %20
%22 = load double, double* %2
%23 = fsub double %22, %21
store double %23, double* %2
br label %32
24: ; preds = %12
%25 = load i64, i64* %3
%26 = call double @som(i64 %25)
%27 = load i64, i64* %3
%28 = call double @fat(i64 %27)
%29 = fdiv double %26, %28
%30 = load double, double* %2
%31 = fadd double %30, %29
store double %31, double* %2
br label %32
32: ; preds = %24, %16
br label %33
33: ; preds = %32
%34 = load i64, i64* %3
%35 = add nsw i64 %34, 1
store i64 %35, i64* %3
br label %7
36: ; preds = %7
%37 = load double, double* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %37)
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"Digite um inteiro positivo: \00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [17 x i8] c"\0ATotal = %.15lf\0A\00"
@str = [64 x i8] c"Este programa foi escrito por Jessica Cristina Cacau Patricio.\0A\00"
define void @main() {
%1 = alloca double
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%3 = bitcast double* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%6 = load double, double* %1
%7 = fcmp ult double %6, 1.000000e+00
br i1 %7, label %23, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %19, %8 ], [ 1, %0 ]
%10 = phi double [ %18, %8 ], [ 0.000000e+00, %0 ]
%11 = and i64 %9, 1
%12 = icmp eq i64 %11, 0
%13 = call double @som(i64 %9)
%14 = call double @fat(i64 %9)
%15 = fdiv double %13, %14
%16 = fneg double %15
%17 = select i1 %12, double %16, double %15
%18 = fadd double %10, %17
%19 = add nuw nsw i64 %9, 1
%20 = sitofp i64 %19 to double
%21 = load double, double* %1
%22 = fcmp ult double %21, %20
br i1 %22, label %23, label %8
23: ; preds = %8, %0
%24 = phi double [ 0.000000e+00, %0 ], [ %18, %8 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %24)
ret void
}