#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 number;
  int factorial = 1;
  scanf("%d", &number);
  if (number < 0 || number > 12) {
    printf("-1\n");
  } else if (number == 0) {
    printf("1\n");
  } else {
    for (char i = 1; i <= number; i++) {
      factorial *= i;
    }
    printf("%d\n", factorial);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     115a <main+0x3a>
cmpl   $0xc,-0x8(%rbp)
jle    116d <main+0x4d>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
cmpl   $0x0,-0x8(%rbp)
jne    118a <main+0x6a>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c4 <main+0xa4>
movb   $0x1,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b3 <main+0x93>
movsbl -0xd(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xd(%rbp),%al
add    $0x1,%al
mov    %al,-0xd(%rbp)
jmp    118e <main+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xd,%eax
jb     1154 <main+0x24>
lea    0xeb5(%rip),%rdi
jmp    1194 <main+0x64>
test   %eax,%eax
je     118d <main+0x5d>
mov    $0x1,%ecx
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
imul   %ecx,%esi
add    $0x1,%cl
movsbl %cl,%ecx
cmp    %ecx,%eax
jge    1170 <main+0x40>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1199 <main+0x69>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"1\00"
@str.4 = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp ugt i32 %4, 12
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.4, i64 0, i64 0))
br label %22
8: ; preds = %0
%9 = icmp eq i32 %4, 0
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %22
12: ; preds = %14
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %22
14: ; preds = %8, %14
%15 = phi i32 [ %20, %14 ], [ 1, %8 ]
%16 = phi i32 [ %17, %14 ], [ 1, %8 ]
%17 = mul nsw i32 %15, %16
%18 = shl nsw i32 %15, 24
%19 = add i32 %18, 16777216
%20 = ashr exact i32 %19, 24
%21 = icmp slt i32 %4, %20
br i1 %21, label %12, label %14
22: ; preds = %10, %12, %6
ret i32 0
}