#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(void) {
  int number = 0;
  int factorial = 1;
  int counter = 0;
  float eular = 2;
  printf("Please Enter integer Number:");
  scanf("%d", &number);
  if (number == 0) {
    printf("The factorial of [%d] is :%d", number, factorial);
  } else {
    while (number != 0) {
      factorial = factorial * number;
      printf("%d\n", factorial);
      --number;
      ++counter;
    }
  }
  printf("\nThe factorial of [%d] is :%d", number + counter, factorial);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1192 <main+0x72>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xb8>
jmp    1197 <main+0x77>
cmpl   $0x0,-0x8(%rbp)
je     11d3 <main+0xb3>
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <main+0x77>
jmp    11d8 <main+0xb8>
mov    -0x8(%rbp),%esi
add    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeca(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1191 <main+0x71>
mov    $0x1,%ebx
lea    0xeb9(%rip),%r14
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
imul   %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
add    $0x1,%ebp
add    $0xffffffff,%eax
mov    %eax,0x4(%rsp)
jne    1170 <main+0x50>
jmp    11b2 <main+0x92>
lea    0xe8a(%rip),%rdi
xor    %ebp,%ebp
mov    $0x1,%ebx
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%r15d
add    %ebp,%r15d
lea    0xe65(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Please Enter integer Number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"The factorial of [%d] is :%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [30 x i8] c"\0AThe factorial of [%d] is :%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
store float 2.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12)
br label %29
14: ; preds = %0
br label %15
15: ; preds = %18, %14
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = mul nsw i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = add nsw i32 %24, -1
store i32 %25, i32* %2
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28, %10
%30 = load i32, i32* %2
%31 = load i32, i32* %4
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Please Enter integer Number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"The factorial of [%d] is :%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [30 x i8] c"\0AThe factorial of [%d] is :%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 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 eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%9 = load i32, i32* %1
br label %20
10: ; preds = %0, %10
%11 = phi i32 [ %14, %10 ], [ 1, %0 ]
%12 = phi i32 [ %18, %10 ], [ 0, %0 ]
%13 = phi i32 [ %17, %10 ], [ %5, %0 ]
%14 = mul nsw i32 %11, %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -1
store i32 %17, i32* %1
%18 = add nuw nsw i32 %12, 1
%19 = icmp eq i32 %17, 0
br i1 %19, label %20, label %10
20: ; preds = %10, %7
%21 = phi i32 [ %9, %7 ], [ 0, %10 ]
%22 = phi i32 [ 0, %7 ], [ %18, %10 ]
%23 = phi i32 [ 1, %7 ], [ %14, %10 ]
%24 = add nsw i32 %21, %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %23)
ret i32 0
}