#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 fatorial(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  double valor = 0;
  double resultado = 1;
  do {
    printf("Digite o valor: ");
    scanf("%lf", &valor);
    resultado = fatorial(valor);
    printf("O fatorial de %lf é: %lf\n", valor, resultado);
  } while (valor != -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <fatorial@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe93(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1154 <main+0x24>
jp     1154 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xec1(%rip),%r14
lea    0xecb(%rip),%r15
mov    %rsp,%r12
lea    0xec5(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
call   1040 <fatorial@plt>
movaps %xmm0,%xmm1
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xe62(%rip),%xmm0
jne    1160 <main+0x30>
jp     1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Digite o valor: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"O fatorial de %lf \C3\A9: %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.000000e+00, double* %3
br label %4
4: ; preds = %12, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = load double, double* %2
%8 = call double @fatorial(double %7)
store double %8, double* %3
%9 = load double, double* %2
%10 = load double, double* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %9, double %10)
br label %12
12: ; preds = %4
%13 = load double, double* %2
%14 = fcmp une double %13, -1.000000e+00
br i1 %14, label %4, label %15
15: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Digite o valor: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"O fatorial de %lf \C3\A9: %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%6 = load double, double* %1
%7 = call double @fatorial(double %6)
%8 = load double, double* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %8, double %7)
%10 = load double, double* %1
%11 = fcmp une double %10, -1.000000e+00
br i1 %11, label %3, label %12
12: ; preds = %3
ret i32 0
}