#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 *, int *);
int main() {
  int n, fact = 1, i;
  printf("Enter the number to get factorial of it: ");
  scanf("%d", &n);
  for (i = n; i >= 1; i--)
    fact *= i;
  printf("\nThe factorial of %d is %d \n", n, fact);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     117c <main+0x5c>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <main+0x3a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf78(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf94(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x1,%edx
test   %esi,%esi
jle    139d <main+0x27d>
mov    %esi,%eax
cmp    $0x8,%esi
jb     1390 <main+0x270>
mov    %esi,%eax
and    $0xfffffff8,%eax
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm6
paddd  0xe8e(%rip),%xmm6
lea    -0x8(%rax),%edi
mov    %edi,%edx
shr    $0x3,%edx
add    $0x1,%edx
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x18,%edi
jae    1198 <main+0x78>
movdqa 0xe81(%rip),%xmm1
movdqa %xmm1,%xmm4
jmp    12d1 <main+0x1b1>
and    $0xfffffffc,%edx
movdqa 0xe6d(%rip),%xmm1
movdqa 0xe84(%rip),%xmm9
movdqa 0xe8b(%rip),%xmm10
movdqa 0xe92(%rip),%xmm11
movdqa 0xe99(%rip),%xmm12
movdqa 0xea0(%rip),%xmm13
movdqa 0xea7(%rip),%xmm14
movdqa 0xeae(%rip),%xmm15
movdqa %xmm1,%xmm4
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm6,%xmm0
paddd  0xe24(%rip),%xmm0
pshufd $0xf5,%xmm1,%xmm5
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm5,%xmm7
pmuludq %xmm6,%xmm1
pshufd $0xf5,%xmm4,%xmm5
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm5,%xmm2
pmuludq %xmm4,%xmm0
movdqa %xmm6,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm6,%xmm5
paddd  %xmm10,%xmm5
pmuludq %xmm4,%xmm1
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm7,%xmm4
pmuludq %xmm5,%xmm0
pshufd $0xf5,%xmm5,%xmm5
pmuludq %xmm2,%xmm5
movdqa %xmm6,%xmm2
paddd  %xmm11,%xmm2
movdqa %xmm6,%xmm7
paddd  %xmm12,%xmm7
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm4,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xf5,%xmm7,%xmm8
pmuludq %xmm5,%xmm8
pmuludq %xmm0,%xmm7
movdqa %xmm6,%xmm0
paddd  %xmm13,%xmm0
movdqa %xmm6,%xmm5
paddd  %xmm14,%xmm5
pmuludq %xmm0,%xmm2
pshufd $0xe8,%xmm2,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm3,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pmuludq %xmm5,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pshufd $0xf5,%xmm5,%xmm0
pmuludq %xmm8,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm4
paddd  %xmm15,%xmm6
add    $0xfffffffc,%edx
jne    11f0 <main+0xd0>
movdqa %xmm1,%xmm5
movdqa %xmm4,%xmm0
test   %ecx,%ecx
je     134d <main+0x22d>
movdqa 0xd3b(%rip),%xmm2
movdqa 0xd43(%rip),%xmm3
nopl   (%rax)
movdqa %xmm6,%xmm0
paddd  %xmm2,%xmm0
movdqa %xmm6,%xmm5
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm1,%xmm1
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm1,%xmm7
pshufd $0xe8,%xmm7,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm4,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm3,%xmm6
movdqa %xmm5,%xmm1
movdqa %xmm0,%xmm4
add    $0xffffffff,%ecx
jne    12f0 <main+0x1d0>
pshufd $0xf5,%xmm5,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm1,%xmm2
pmuludq %xmm5,%xmm0
pshufd $0xee,%xmm0,%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xaa,%xmm2,%xmm0
pmuludq %xmm2,%xmm0
pmuludq %xmm1,%xmm0
movd   %xmm0,%edx
cmp    %eax,%esi
je     139d <main+0x27d>
mov    %esi,%eax
and    $0x7,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
imul   %eax,%edx
lea    -0x1(%rax),%ecx
cmp    $0x1,%eax
mov    %ecx,%eax
ja     1390 <main+0x270>
lea    0xd29(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter the number to get factorial of it: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AThe factorial of %d is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
store i32 %7, i32* %4
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, %12
store i32 %14, i32* %3
br label %15
15: ; preds = %11
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
br label %8
18: ; preds = %8
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Enter the number to get factorial of it: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AThe factorial of %d is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %78
7: ; preds = %0
%8 = icmp ult i32 %5, 8
br i1 %8, label %69, label %9
9: ; preds = %7
%10 = and i32 %5, -8
%11 = and i32 %5, 7
%12 = insertelement <4 x i32> poison, i32 %5, i64 0
%13 = shufflevector <4 x i32> %12, <4 x i32> poison, <4 x i32> zeroinitializer
%14 = add <4 x i32> %13, <i32 0, i32 -1, i32 -2, i32 -3>
%15 = add i32 %10, -8
%16 = lshr exact i32 %15, 3
%17 = add nuw nsw i32 %16, 1
%18 = and i32 %17, 3
%19 = icmp ult i32 %15, 24
br i1 %19, label %45, label %20
20: ; preds = %9
%21 = and i32 %17, 1073741820
br label %22
22: ; preds = %22, %20
%23 = phi <4 x i32> [ %14, %20 ], [ %42, %22 ]
%24 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %20 ], [ %40, %22 ]
%25 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %20 ], [ %41, %22 ]
%26 = phi i32 [ 0, %20 ], [ %43, %22 ]
%27 = add <4 x i32> %23, <i32 -4, i32 -4, i32 -4, i32 -4>
%28 = mul <4 x i32> %23, %24
%29 = mul <4 x i32> %27, %25
%30 = add <4 x i32> %23, <i32 -8, i32 -8, i32 -8, i32 -8>
%31 = add <4 x i32> %23, <i32 -12, i32 -12, i32 -12, i32 -12>
%32 = mul <4 x i32> %30, %28
%33 = mul <4 x i32> %31, %29
%34 = add <4 x i32> %23, <i32 -16, i32 -16, i32 -16, i32 -16>
%35 = add <4 x i32> %23, <i32 -20, i32 -20, i32 -20, i32 -20>
%36 = mul <4 x i32> %34, %32
%37 = mul <4 x i32> %35, %33
%38 = add <4 x i32> %23, <i32 -24, i32 -24, i32 -24, i32 -24>
%39 = add <4 x i32> %23, <i32 -28, i32 -28, i32 -28, i32 -28>
%40 = mul <4 x i32> %38, %36
%41 = mul <4 x i32> %39, %37
%42 = add <4 x i32> %23, <i32 -32, i32 -32, i32 -32, i32 -32>
%43 = add i32 %26, 4
%44 = icmp eq i32 %43, %21
br i1 %44, label %45, label %22
45: ; preds = %22, %9
%46 = phi <4 x i32> [ undef, %9 ], [ %40, %22 ]
%47 = phi <4 x i32> [ undef, %9 ], [ %41, %22 ]
%48 = phi <4 x i32> [ %14, %9 ], [ %42, %22 ]
%49 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %9 ], [ %40, %22 ]
%50 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %9 ], [ %41, %22 ]
%51 = icmp eq i32 %18, 0
br i1 %51, label %63, label %52
52: ; preds = %45, %52
%53 = phi <4 x i32> [ %60, %52 ], [ %48, %45 ]
%54 = phi <4 x i32> [ %58, %52 ], [ %49, %45 ]
%55 = phi <4 x i32> [ %59, %52 ], [ %50, %45 ]
%56 = phi i32 [ %61, %52 ], [ 0, %45 ]
%57 = add <4 x i32> %53, <i32 -4, i32 -4, i32 -4, i32 -4>
%58 = mul <4 x i32> %53, %54
%59 = mul <4 x i32> %57, %55
%60 = add <4 x i32> %53, <i32 -8, i32 -8, i32 -8, i32 -8>
%61 = add i32 %56, 1
%62 = icmp eq i32 %61, %18
br i1 %62, label %63, label %52
63: ; preds = %52, %45
%64 = phi <4 x i32> [ %46, %45 ], [ %58, %52 ]
%65 = phi <4 x i32> [ %47, %45 ], [ %59, %52 ]
%66 = mul <4 x i32> %65, %64
%67 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %66)
%68 = icmp eq i32 %5, %10
br i1 %68, label %78, label %69
69: ; preds = %7, %63
%70 = phi i32 [ %5, %7 ], [ %11, %63 ]
%71 = phi i32 [ 1, %7 ], [ %67, %63 ]
br label %72
72: ; preds = %69, %72
%73 = phi i32 [ %76, %72 ], [ %70, %69 ]
%74 = phi i32 [ %75, %72 ], [ %71, %69 ]
%75 = mul nsw i32 %73, %74
%76 = add nsw i32 %73, -1
%77 = icmp ugt i32 %73, 1
br i1 %77, label %72, label %78
78: ; preds = %72, %63, %0
%79 = phi i32 [ 1, %0 ], [ %67, %63 ], [ %75, %72 ]
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %79)
ret i32 0
}