#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_s(char *, int *);
int /*<<< orphan*/ system(char *);
main() {
  int number, i, result, f = 1;
  printf("Enter a number : ");
  scanf_s("%d", &number);
  for (i = 1; i <= number; i++) {
    f = f * i;
  }
  i = i - 1;
  printf("Result is : %d\n", f);
  printf("Top number is : %d\n", i);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf_s@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118f <main+0x5f>
mov    -0x14(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x3b>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf64(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf66(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf_s@plt>
mov    0xc(%rsp),%eax
mov    $0x1,%esi
test   %eax,%eax
jle    139c <main+0x26c>
mov    $0x1,%ecx
cmp    $0x8,%eax
jb     1384 <main+0x254>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%edi
mov    %edi,%esi
shr    $0x3,%esi
add    $0x1,%esi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%edi
jae    11a8 <main+0x78>
movdqa 0xe69(%rip),%xmm0
movdqa 0xe71(%rip),%xmm1
movdqa %xmm1,%xmm2
jmp    12e1 <main+0x1b1>
and    $0xfffffffc,%esi
movdqa 0xe4d(%rip),%xmm0
movdqa 0xe55(%rip),%xmm1
movdqa 0xe6c(%rip),%xmm9
movdqa 0xe73(%rip),%xmm10
movdqa 0xe7a(%rip),%xmm11
movdqa 0xe81(%rip),%xmm12
movdqa 0xe88(%rip),%xmm13
movdqa 0xe8f(%rip),%xmm14
movdqa 0xe96(%rip),%xmm15
movdqa %xmm1,%xmm2
xchg   %ax,%ax
movdqa %xmm0,%xmm6
paddd  0xe14(%rip),%xmm6
pshufd $0xf5,%xmm0,%xmm7
pshufd $0xf5,%xmm1,%xmm3
pmuludq %xmm7,%xmm3
pmuludq %xmm0,%xmm1
pshufd $0xf5,%xmm2,%xmm7
pshufd $0xf5,%xmm6,%xmm4
pmuludq %xmm7,%xmm4
pmuludq %xmm2,%xmm6
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm7
paddd  %xmm10,%xmm7
pmuludq %xmm2,%xmm1
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm3,%xmm2
pmuludq %xmm7,%xmm6
pshufd $0xf5,%xmm7,%xmm3
pmuludq %xmm4,%xmm3
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm7
paddd  %xmm12,%xmm7
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm2,%xmm5
pmuludq %xmm1,%xmm4
pshufd $0xf5,%xmm7,%xmm8
pmuludq %xmm3,%xmm8
pmuludq %xmm6,%xmm7
movdqa %xmm0,%xmm2
paddd  %xmm13,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm14,%xmm3
pmuludq %xmm2,%xmm4
pshufd $0xe8,%xmm4,%xmm1
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm5,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pmuludq %xmm3,%xmm7
pshufd $0xe8,%xmm7,%xmm2
pshufd $0xf5,%xmm3,%xmm3
pmuludq %xmm8,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
paddd  %xmm15,%xmm0
add    $0xfffffffc,%esi
jne    1200 <main+0xd0>
test   %edx,%edx
je     1351 <main+0x221>
movdqa 0xd33(%rip),%xmm3
movdqa 0xd3b(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm0,%xmm5
paddd  %xmm3,%xmm5
pshufd $0xf5,%xmm1,%xmm6
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm6
punpckldq %xmm6,%xmm1
pshufd $0xf5,%xmm2,%xmm6
pmuludq %xmm5,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshufd $0xf5,%xmm5,%xmm5
pmuludq %xmm6,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
paddd  %xmm4,%xmm0
add    $0xffffffff,%edx
jne    1300 <main+0x1d0>
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    %ecx,%eax
je     139a <main+0x26a>
or     $0x1,%ecx
lea    0x1(%rax),%edx
nopw   0x0(%rax,%rax,1)
imul   %ecx,%esi
add    $0x1,%ecx
cmp    %ecx,%edx
jne    1390 <main+0x260>
mov    %eax,%ebx
lea    0xd12(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd14(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd18(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Result is : %d\0A\00"
@.str.3 = [20 x i8] c"Top number is : %d\0A\00"
@.str.4 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = mul nsw i32 %13, %14
store i32 %15, i32* %5
br label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %8
19: ; preds = %8
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32, i32* %1
ret i32 %27
}

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