#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double input = 0;
  printf("Enter a number (0-170): ");
  scanf("%lf", &input);
  double fac = 1;
  double i;
  for (i = 1; i <= input; i++) {
    fac = fac * i;
  }
  printf("%.0lf! = %.0lf", input, fac);
  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)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11a9 <main+0x89>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe66(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    116f <main+0x4f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe6b(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0xead(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     117e <main+0x5e>
movsd  0xe9f(%rip),%xmm2
movapd %xmm2,%xmm3
movapd %xmm2,%xmm1
nopl   0x0(%rax)
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm0
jae    1170 <main+0x50>
lea    0xea0(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter a number (0-170): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [15 x i8] c"%.0lf! = %.0lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 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)
store double 1.000000e+00, double* %3
store double 1.000000e+00, double* %4
br label %7
7: ; preds = %15, %0
%8 = load double, double* %4
%9 = load double, double* %2
%10 = fcmp ole double %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load double, double* %3
%13 = load double, double* %4
%14 = fmul double %12, %13
store double %14, double* %3
br label %15
15: ; preds = %11
%16 = load double, double* %4
%17 = fadd double %16, 1.000000e+00
store double %17, double* %4
br label %7
18: ; preds = %7
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %19, double %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter a number (0-170): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [15 x i8] c"%.0lf! = %.0lf\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ult double %5, 1.000000e+00
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = phi double [ %11, %7 ], [ 1.000000e+00, %0 ]
%9 = phi double [ %10, %7 ], [ 1.000000e+00, %0 ]
%10 = fmul double %9, %8
%11 = fadd double %8, 1.000000e+00
%12 = fcmp ugt double %11, %5
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = phi double [ 1.000000e+00, %0 ], [ %10, %7 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %5, double %14)
ret i32 0
}