#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*/ fatorial(double);
int /*<<< orphan*/ printf(char *, ...);
double soma(double, int /*<<< orphan*/);
void main() {
  printf("Este programa foi escrito por Jessica Cristina Cacau Patricio.\n\n");
  double som = 0, i;
  for (i = 2; i <= 10; i++) {
    som = soma(som, fatorial(i));
    printf("Fatorial de %.0lf: %.0lf\t\tSoma parcial: %.0lf.\n", i, fatorial(i),
           som);
  }
  printf("\nSoma final: %.0lf.\n", som);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xea5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11d8 <main+0xa8>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fatorial@plt>
movsd  -0x20(%rbp),%xmm0
mov    %eax,%edi
call   1040 <soma@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fatorial@plt>
movsd  -0x18(%rbp),%xmm0
mov    %eax,%esi
movsd  -0x8(%rbp),%xmm1
lea    0xe9f(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0xe47(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    115b <main+0x2b>
movsd  -0x8(%rbp),%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
movsd  0xea7(%rip),%xmm0
call   1060 <fatorial@plt>
xorps  %xmm0,%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe8a(%rip),%xmm0
call   1060 <fatorial@plt>
lea    0xec6(%rip),%rbx
mov    %rbx,%rdi
movsd  0xe73(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xe64(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe44(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xe34(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xe25(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe05(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xdf5(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xde6(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xdc6(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xdb6(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xda7(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd87(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xd77(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xd68(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd48(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xd38(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xd29(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd09(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xcf9(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xcea(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xcca(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xcba(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xcab(%rip),%xmm0
call   1060 <fatorial@plt>
movsd  0x8(%rsp),%xmm0
mov    %eax,%edi
call   1050 <soma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xc8b(%rip),%xmm0
call   1060 <fatorial@plt>
mov    %rbx,%rdi
movsd  0xc7b(%rip),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xc9d(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
add    $0x10,%rsp
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"Este programa foi escrito por Jessica Cristina Cacau Patricio.\0A\0A\00"
@.str.1 = [48 x i8] c"Fatorial de %.0lf: %.0lf\09\09Soma parcial: %.0lf.\0A\00"
@.str.2 = [21 x i8] c"\0ASoma final: %.0lf.\0A\00"
define void @main() {
%1 = alloca double
%2 = alloca double
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %1
store double 2.000000e+00, double* %2
br label %4
4: ; preds = %17, %0
%5 = load double, double* %2
%6 = fcmp ole double %5, 1.000000e+01
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load double, double* %1
%9 = load double, double* %2
%10 = call i32 @fatorial(double %9)
%11 = call double @soma(double %8, i32 %10)
store double %11, double* %1
%12 = load double, double* %2
%13 = load double, double* %2
%14 = call i32 @fatorial(double %13)
%15 = load double, double* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double %12, i32 %14, double %15)
br label %17
17: ; preds = %7
%18 = load double, double* %2
%19 = fadd double %18, 1.000000e+00
store double %19, double* %2
br label %4
20: ; preds = %4
%21 = load double, double* %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %21)
ret void
}

LLVM IR (-O2):
@.str.1 = [48 x i8] c"Fatorial de %.0lf: %.0lf\09\09Soma parcial: %.0lf.\0A\00"
@.str.2 = [21 x i8] c"\0ASoma final: %.0lf.\0A\00"
@str = [64 x i8] c"Este programa foi escrito por Jessica Cristina Cacau Patricio.\0A\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @fatorial(double 2.000000e+00)
%3 = tail call double @soma(double 0.000000e+00, i32 %2)
%4 = tail call i32 @fatorial(double 2.000000e+00)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+00, i32 %4, double %3)
%6 = tail call i32 @fatorial(double 3.000000e+00)
%7 = tail call double @soma(double %3, i32 %6)
%8 = tail call i32 @fatorial(double 3.000000e+00)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+00, i32 %8, double %7)
%10 = tail call i32 @fatorial(double 4.000000e+00)
%11 = tail call double @soma(double %7, i32 %10)
%12 = tail call i32 @fatorial(double 4.000000e+00)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+00, i32 %12, double %11)
%14 = tail call i32 @fatorial(double 5.000000e+00)
%15 = tail call double @soma(double %11, i32 %14)
%16 = tail call i32 @fatorial(double 5.000000e+00)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 5.000000e+00, i32 %16, double %15)
%18 = tail call i32 @fatorial(double 6.000000e+00)
%19 = tail call double @soma(double %15, i32 %18)
%20 = tail call i32 @fatorial(double 6.000000e+00)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 6.000000e+00, i32 %20, double %19)
%22 = tail call i32 @fatorial(double 7.000000e+00)
%23 = tail call double @soma(double %19, i32 %22)
%24 = tail call i32 @fatorial(double 7.000000e+00)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 7.000000e+00, i32 %24, double %23)
%26 = tail call i32 @fatorial(double 8.000000e+00)
%27 = tail call double @soma(double %23, i32 %26)
%28 = tail call i32 @fatorial(double 8.000000e+00)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 8.000000e+00, i32 %28, double %27)
%30 = tail call i32 @fatorial(double 9.000000e+00)
%31 = tail call double @soma(double %27, i32 %30)
%32 = tail call i32 @fatorial(double 9.000000e+00)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 9.000000e+00, i32 %32, double %31)
%34 = tail call i32 @fatorial(double 1.000000e+01)
%35 = tail call double @soma(double %31, i32 %34)
%36 = tail call i32 @fatorial(double 1.000000e+01)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+01, i32 %36, double %35)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %35)
ret void
}