#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 num, i;
  printf("Input: \n");
  printf("Enter a positive number to find its factorial value: ");
  scanf("%d", &num);
  i = num;
  while (i != 1) {
    i--;
    num = num * i;
  }
  printf("\nOutput: \n");
  printf("Your result is %d. \n", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1183 <main+0x63>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1161 <main+0x41>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xeb2(%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    0xfe6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfb4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     13dc <main+0x2ac>
lea    -0x1(%rax),%ecx
cmp    $0x8,%ecx
jae    1178 <main+0x48>
mov    %eax,%esi
jmp    13c0 <main+0x290>
mov    %ecx,%r8d
and    $0xfffffff8,%r8d
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm8
paddd  0xe6e(%rip),%xmm8
movd   %eax,%xmm0
movaps 0xe73(%rip),%xmm1
movss  %xmm0,%xmm1
lea    -0x8(%r8),%edx
mov    %edx,%edi
shr    $0x3,%edi
add    $0x1,%edi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0x18,%edx
jae    11c4 <main+0x94>
movdqa 0xe61(%rip),%xmm2
jmp    130f <main+0x1df>
and    $0xfffffffc,%edi
movdqa 0xe51(%rip),%xmm2
movdqa 0xe58(%rip),%xmm9
movdqa 0xe5f(%rip),%xmm10
movdqa 0xe66(%rip),%xmm11
movdqa 0xe6d(%rip),%xmm12
movdqa 0xe74(%rip),%xmm13
movdqa 0xe7b(%rip),%xmm14
movdqa 0xe82(%rip),%xmm15
movdqa 0xe8a(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm8,%xmm7
paddd  0xe93(%rip),%xmm7
movdqa %xmm8,%xmm0
paddd  %xmm9,%xmm0
pshufd $0xf5,%xmm7,%xmm4
pshufd $0xf5,%xmm1,%xmm5
pmuludq %xmm4,%xmm5
pmuludq %xmm1,%xmm7
pshufd $0xf5,%xmm2,%xmm1
pshufd $0xf5,%xmm0,%xmm4
pmuludq %xmm1,%xmm4
pmuludq %xmm2,%xmm0
movdqa %xmm8,%xmm1
paddd  %xmm10,%xmm1
movdqa %xmm8,%xmm2
paddd  %xmm11,%xmm2
pmuludq %xmm1,%xmm7
pshufd $0xf5,%xmm1,%xmm1
pmuludq %xmm5,%xmm1
pmuludq %xmm2,%xmm0
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm4,%xmm2
movdqa %xmm8,%xmm4
paddd  %xmm12,%xmm4
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm1,%xmm5
movdqa %xmm8,%xmm6
paddd  %xmm13,%xmm6
pmuludq %xmm7,%xmm4
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm2,%xmm7
pmuludq %xmm0,%xmm6
movdqa %xmm8,%xmm0
paddd  %xmm14,%xmm0
pmuludq %xmm0,%xmm4
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm5,%xmm0
pshufd $0xe8,%xmm4,%xmm1
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm8,%xmm0
paddd  %xmm15,%xmm0
pmuludq %xmm0,%xmm6
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm7,%xmm0
pshufd $0xe8,%xmm6,%xmm2
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm2
paddd  %xmm3,%xmm8
add    $0xfffffffc,%edi
jne    1220 <main+0xf0>
test   %esi,%esi
je     138c <main+0x25c>
pcmpeqd %xmm3,%xmm3
movdqa 0xd11(%rip),%xmm4
movdqa 0xd89(%rip),%xmm5
nopw   0x0(%rax,%rax,1)
movdqa %xmm8,%xmm0
paddd  %xmm3,%xmm0
movdqa %xmm8,%xmm6
paddd  %xmm4,%xmm6
pshufd $0xf5,%xmm1,%xmm7
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm7,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pshufd $0xf5,%xmm2,%xmm0
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm0,%xmm6
pshufd $0xe8,%xmm6,%xmm0
punpckldq %xmm0,%xmm2
paddd  %xmm5,%xmm8
add    $0xffffffff,%esi
jne    1330 <main+0x200>
pshufd $0xf5,%xmm1,%xmm0
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm0,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xee,%xmm2,%xmm0
pmuludq %xmm2,%xmm0
pshufd $0xaa,%xmm3,%xmm1
pmuludq %xmm3,%xmm1
pmuludq %xmm0,%xmm1
movd   %xmm1,%esi
cmp    %r8d,%ecx
je     13d8 <main+0x2a8>
sub    %r8d,%eax
add    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
imul   %eax,%esi
add    $0xffffffff,%eax
jne    13d0 <main+0x2a0>
mov    %esi,0x4(%rsp)
lea    0xd43(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%esi
lea    0xd16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Input: \0A\00"
@.str.1 = [54 x i8] c"Enter a positive number to find its factorial value: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"\0AOutput: \0A\00"
@.str.4 = [21 x i8] c"Your result is %d. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
store i32 %7, i32* %3
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %2
br label %8
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %19)
ret i32 0
}

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