#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 scanf(char *, long long *);
int main() {
  long long a, b, c, ans = 1, i;
  while (scanf("%lld", &a) == 1) {
    if (a == 0) {
      printf("Underflow!\n");
      continue;
    } else if (a < 0 && a % 2 == 0) {
      printf("Underflow!\n");
      continue;
    } else if (a < 0 && a % 2 != 0) {
      printf("Overflow!\n");
      continue;
    }
    for (i = a; i > 0; i--) {
      ans *= i;
      if (i == 1 && ans < 10000) {
        printf("Underflow!\n");
        break;
      } else if (ans > 6227020800) {
        printf("Overflow!\n");
        break;
      } else if (i == 1) {
        printf("%lld\n", ans);
      }
    }
    ans = 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x28(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    12a1 <main+0x181>
cmpq   $0x0,-0x10(%rbp)
jne    116e <main+0x4e>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
cmpq   $0x0,-0x10(%rbp)
jge    11a4 <main+0x84>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11a4 <main+0x84>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
cmpq   $0x0,-0x10(%rbp)
jge    11da <main+0xba>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     11da <main+0xba>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
jmp    11df <main+0xbf>
jmp    11e4 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jle    1294 <main+0x174>
mov    -0x30(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x1,-0x30(%rbp)
jne    1230 <main+0x110>
cmpq   $0x2710,-0x28(%rbp)
jge    1230 <main+0x110>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1294 <main+0x174>
movabs $0x17328cc00,%rax
cmp    %rax,-0x28(%rbp)
jle    1257 <main+0x137>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1294 <main+0x174>
cmpq   $0x1,-0x30(%rbp)
jne    1274 <main+0x154>
mov    -0x28(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <main+0x159>
jmp    127e <main+0x15e>
jmp    1283 <main+0x163>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11ec <main+0xcc>
movq   $0x1,-0x28(%rbp)
jmp    1137 <main+0x17>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    121c <main+0xec>
lea    0xebb(%rip),%r14
lea    0xe9f(%rip),%r15
mov    %rsp,%rbx
movabs $0x8000000000000001,%rbp
movabs $0x8000000000000000,%r13
movabs $0x17328cc01,%r12
jmp    11a8 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    121c <main+0xec>
mov    (%rsp),%rax
test   %rax,%rax
je     1190 <main+0x60>
mov    %rax,%rcx
and    %rbp,%rcx
cmp    %rbp,%rcx
je     1200 <main+0xd0>
cmp    %r13,%rcx
je     1190 <main+0x60>
test   %rax,%rax
jle    1198 <main+0x68>
mov    $0x1,%esi
nopl   0x0(%rax,%rax,1)
imul   %rax,%rsi
cmp    $0x1,%rax
jne    11e3 <main+0xb3>
cmp    $0x270f,%rsi
jle    1190 <main+0x60>
cmp    %r12,%rsi
jge    1200 <main+0xd0>
cmp    $0x1,%rax
je     1209 <main+0xd9>
lea    -0x1(%rax),%rcx
cmp    $0x1,%rax
mov    %rcx,%rax
jg     11d0 <main+0xa0>
jmp    1198 <main+0x68>
nopl   (%rax)
lea    0xe04(%rip),%rdi
jmp    1193 <main+0x63>
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [12 x i8] c"Underflow!\0A\00"
@.str.2 = [11 x i8] c"Overflow!\0A\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %5
br label %7
7: ; preds = %68, %31, %22, %13, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %69
10: ; preds = %7
%11 = load i64, i64* %2
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %7
15: ; preds = %10
%16 = load i64, i64* %2
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i64, i64* %2
%20 = srem i64 %19, 2
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %7
24: ; preds = %18, %15
%25 = load i64, i64* %2
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i64, i64* %2
%29 = srem i64 %28, 2
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %7
33: ; preds = %27, %24
br label %34
34: ; preds = %33
br label %35
35: ; preds = %34
%36 = load i64, i64* %2
store i64 %36, i64* %6
br label %37
37: ; preds = %65, %35
%38 = load i64, i64* %6
%39 = icmp sgt i64 %38, 0
br i1 %39, label %40, label %68
40: ; preds = %37
%41 = load i64, i64* %6
%42 = load i64, i64* %5
%43 = mul nsw i64 %42, %41
store i64 %43, i64* %5
%44 = load i64, i64* %6
%45 = icmp eq i64 %44, 1
br i1 %45, label %46, label %51
46: ; preds = %40
%47 = load i64, i64* %5
%48 = icmp slt i64 %47, 10000
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %68
51: ; preds = %46, %40
%52 = load i64, i64* %5
%53 = icmp sgt i64 %52, 6227020800
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %68
56: ; preds = %51
%57 = load i64, i64* %6
%58 = icmp eq i64 %57, 1
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i64, i64* %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %60)
br label %62
62: ; preds = %59, %56
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
%66 = load i64, i64* %6
%67 = add nsw i64 %66, -1
store i64 %67, i64* %6
br label %37
68: ; preds = %54, %49, %37
store i64 1, i64* %5
br label %7
69: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
@str.5 = [10 x i8] c"Overflow!\00"
@str.7 = [11 x i8] c"Underflow!\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %40
5: ; preds = %0, %10
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %10
10: ; preds = %37, %35, %28, %32, %17, %8, %15, %19
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %5, label %40
13: ; preds = %5
%14 = and i64 %6, -9223372036854775807
switch i64 %14, label %17 [
i64 -9223372036854775808, label %15
i64 -9223372036854775807, label %19
]
15: ; preds = %13
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %10
17: ; preds = %13
%18 = icmp sgt i64 %6, 0
br i1 %18, label %21, label %10
19: ; preds = %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
br label %10
21: ; preds = %17, %37
%22 = phi i64 [ %38, %37 ], [ %6, %17 ]
%23 = phi i64 [ %24, %37 ], [ 1, %17 ]
%24 = mul nsw i64 %22, %23
%25 = icmp eq i64 %22, 1
%26 = icmp slt i64 %24, 10000
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %10
30: ; preds = %21
%31 = icmp sgt i64 %24, 6227020800
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
br label %10
34: ; preds = %30
br i1 %25, label %35, label %37
35: ; preds = %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %24)
br label %10
37: ; preds = %34
%38 = add nsw i64 %22, -1
%39 = icmp sgt i64 %22, 1
br i1 %39, label %21, label %10
40: ; preds = %10, %0
ret i32 0
}