#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;
  int i;
  int factorial = 1;
  printf("Enter an integer number: ");
  scanf("%d", &num);
  if (num < 0)
    printf("Out of range");
  else if (num == 0)
    printf("The factorial of 0 is 1");
  else {
    for (i = 1; i <= num; i++) {
      factorial = factorial * i;
    }
    printf("The factorial of %d is %d", num, factorial);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1171 <main+0x51>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0xb2>
cmpl   $0x0,-0x8(%rbp)
jne    118e <main+0x6e>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <main+0xad>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b9 <main+0x99>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x75>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0xb2>
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    0xfc0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     1190 <main+0x70>
je     1199 <main+0x79>
mov    $0x1,%edx
mov    $0x1,%eax
cmp    $0x8,%esi
jb     1394 <main+0x274>
mov    %esi,%eax
and    $0xfffffff8,%eax
lea    -0x8(%rax),%edi
mov    %edi,%edx
shr    $0x3,%edx
add    $0x1,%edx
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x18,%edi
jae    11ac <main+0x8c>
movdqa 0xe81(%rip),%xmm0
movdqa 0xe89(%rip),%xmm1
movdqa %xmm1,%xmm2
jmp    12f1 <main+0x1d1>
lea    0xf23(%rip),%rdi
jmp    11a0 <main+0x80>
lea    0xf27(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    13b8 <main+0x298>
and    $0xfffffffc,%edx
movdqa 0xe49(%rip),%xmm0
movdqa 0xe51(%rip),%xmm1
movdqa 0xe68(%rip),%xmm9
movdqa 0xe6f(%rip),%xmm10
movdqa 0xe76(%rip),%xmm11
movdqa 0xe7d(%rip),%xmm12
movdqa 0xe84(%rip),%xmm13
movdqa 0xe8b(%rip),%xmm14
movdqa 0xe92(%rip),%xmm15
movdqa %xmm1,%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa %xmm0,%xmm6
paddd  0xe04(%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,%edx
jne    1210 <main+0xf0>
test   %ecx,%ecx
je     1361 <main+0x241>
movdqa 0xd23(%rip),%xmm3
movdqa 0xd2b(%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,%ecx
jne    1310 <main+0x1f0>
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,%edx
cmp    %eax,%esi
je     13aa <main+0x28a>
or     $0x1,%eax
lea    0x1(%rsi),%ecx
nopw   0x0(%rax,%rax,1)
imul   %eax,%edx
add    $0x1,%eax
cmp    %eax,%ecx
jne    13a0 <main+0x280>
lea    0xd2e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter an integer number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Out of range\00"
@.str.3 = [24 x i8] c"The factorial of 0 is 1\00"
@.str.4 = [26 x i8] c"The factorial of %d is %d\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* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %33
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %32
16: ; preds = %11
store i32 1, i32* %3
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %4
br label %25
25: ; preds = %21
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %17
28: ; preds = %17
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %28, %14
br label %33
33: ; preds = %32, %9
ret i32 0
}

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