#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 argc, char *argv[]) {
  int i, result, N;
  printf("Nhap vao mot so N tu 1 den 10\n");
  scanf("%d", &N);
  if (N > 10 || N == 0) {
    printf("%d qua to hoac qua nho", N);
    return 0;
  }
  result = 1;
  for (i = 1; i <= N; i++) {
    result = result * i;
  }
  printf("N giai thua = %d", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xa,-0x1c(%rbp)
jg     1168 <main+0x48>
cmpl   $0x0,-0x1c(%rbp)
jne    1185 <main+0x65>
mov    -0x1c(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cf <main+0xaf>
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11b7 <main+0x97>
mov    -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <main+0x73>
mov    -0x18(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf50(%rip),%rdi
call   1030 <puts@plt>
lea    0xf41(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0xa,%esi
jg     1190 <main+0x60>
test   %esi,%esi
je     1190 <main+0x60>
jle    1199 <main+0x69>
lea    0x3(%rsi),%eax
and    $0xfffffffc,%eax
add    $0xffffffff,%esi
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm0
cmp    $0x4,%eax
je     11a0 <main+0x70>
cmp    $0x8,%eax
jne    11b4 <main+0x84>
movdqa 0xe9f(%rip),%xmm1
movdqa 0xe77(%rip),%xmm2
mov    $0x4,%eax
jmp    11c9 <main+0x99>
lea    0xec9(%rip),%rdi
jmp    1218 <main+0xe8>
mov    $0x1,%esi
jmp    1211 <main+0xe1>
movdqa 0xe58(%rip),%xmm1
movdqa 0xe60(%rip),%xmm2
xor    %eax,%eax
jmp    11c9 <main+0x99>
movdqa 0xe74(%rip),%xmm1
movdqa 0xe5c(%rip),%xmm2
mov    $0x8,%eax
movd   %eax,%xmm3
pshufd $0x0,%xmm3,%xmm3
pxor   0xe66(%rip),%xmm0
por    0xe6e(%rip),%xmm3
pcmpgtd %xmm0,%xmm3
pand   %xmm3,%xmm2
pandn  %xmm1,%xmm3
por    %xmm2,%xmm3
pshufd $0xee,%xmm3,%xmm0
pshufd $0xff,%xmm3,%xmm1
pshufd $0xf5,%xmm3,%xmm2
pmuludq %xmm1,%xmm2
pmuludq %xmm3,%xmm0
pmuludq %xmm2,%xmm0
movd   %xmm0,%esi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Nhap vao mot so N tu 1 den 10\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d qua to hoac qua nho\00"
@.str.3 = [17 x i8] c"N giai thua = %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%11 = load i32, i32* %8
%12 = icmp sgt i32 %11, 10
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %8
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %2
%17 = load i32, i32* %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %17)
store i32 0, i32* %3
br label %34
19: ; preds = %13
store i32 1, i32* %7
store i32 1, i32* %6
br label %20
20: ; preds = %28, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %8
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = mul nsw i32 %25, %26
store i32 %27, i32* %7
br label %28
28: ; preds = %24
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %20
31: ; preds = %20
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %32)
store i32 0, i32* %3
br label %34
34: ; preds = %31, %16
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d qua to hoac qua nho\00"
@.str.3 = [17 x i8] c"N giai thua = %d\00"
@str = [30 x i8] c"Nhap vao mot so N tu 1 den 10\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 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* %3)
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 10
%9 = icmp eq i32 %7, 0
%10 = or i1 %8, %9
br i1 %10, label %31, label %11
11: ; preds = %2
%12 = icmp slt i32 %7, 1
br i1 %12, label %33, label %13
13: ; preds = %11
%14 = add i32 %7, 3
%15 = and i32 %14, -4
%16 = add i32 %7, -1
%17 = insertelement <4 x i32> poison, i32 %16, i64 0
%18 = shufflevector <4 x i32> %17, <4 x i32> poison, <4 x i32> zeroinitializer
switch i32 %15, label %19 [
i32 4, label %21
i32 8, label %20
]
19: ; preds = %13
br label %21
20: ; preds = %13
br label %21
21: ; preds = %13, %20, %19
%22 = phi i32 [ 0, %13 ], [ 8, %19 ], [ 4, %20 ]
%23 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %13 ], [ <i32 5, i32 12, i32 21, i32 32>, %19 ], [ <i32 1, i32 2, i32 3, i32 4>, %20 ]
%24 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %13 ], [ <i32 45, i32 120, i32 231, i32 384>, %19 ], [ <i32 5, i32 12, i32 21, i32 32>, %20 ]
%25 = insertelement <4 x i32> poison, i32 %22, i64 0
%26 = shufflevector <4 x i32> %25, <4 x i32> poison, <4 x i32> zeroinitializer
%27 = or <4 x i32> %26, <i32 0, i32 1, i32 2, i32 3>
%28 = icmp ugt <4 x i32> %27, %18
%29 = select <4 x i1> %28, <4 x i32> %23, <4 x i32> %24
%30 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %29)
br label %33
31: ; preds = %2
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %36
33: ; preds = %21, %11
%34 = phi i32 [ 1, %11 ], [ %30, %21 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %31
ret i32 0
}