#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 EXIT_SUCCESS;
int /*<<< orphan*/ factorial(int);
int /*<<< orphan*/ inputRequest();
int /*<<< orphan*/ invalidInputError();
int /*<<< orphan*/ printApproximationHeader();
int /*<<< orphan*/ printAppxRow(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printFactRow(int, int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ printHeaderWithFactorial();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stirlingsApproximation1(int);
int /*<<< orphan*/ stirlingsApproximation2(int);
int main() {
  int input;
  inputRequest();
  for (scanf("%d", &input); input != 99999; scanf("%d", &input)) {
    if (input <= 0) {
      invalidInputError();
    } else {
      int i;
      if (input <= 12) {
        printHeaderWithFactorial();
        for (i = 1; i <= input; i++) {
          printFactRow(i, factorial(i), stirlingsApproximation1(i),
                       stirlingsApproximation2(i));
        }
      } else {
        printApproximationHeader();
        printAppxRow(1, stirlingsApproximation1(1), stirlingsApproximation2(1));
        for (i = 5; i < input; i += 5) {
          printAppxRow(i, stirlingsApproximation1(i),
                       stirlingsApproximation2(i));
        }
        printAppxRow(input, stirlingsApproximation1(input),
                     stirlingsApproximation2(input));
      }
    }
    inputRequest();
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <inputRequest@plt>
lea    0xe43(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
cmpl   $0x1869f,-0x8(%rbp)
je     130f <main+0x16f>
cmpl   $0x0,-0x8(%rbp)
jg     11e9 <main+0x49>
mov    $0x0,%al
call   1060 <invalidInputError@plt>
jmp    12f3 <main+0x153>
cmpl   $0xc,-0x8(%rbp)
jg     1254 <main+0xb4>
mov    $0x0,%al
call   1080 <printHeaderWithFactorial@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     124f <main+0xaf>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <stirlingsApproximation2@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
call   10c0 <printFactRow@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1201 <main+0x61>
jmp    12ee <main+0x14e>
mov    $0x0,%al
call   1050 <printApproximationHeader@plt>
mov    $0x1,%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1,%edi
call   1070 <stirlingsApproximation2@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
mov    $0x1,%edi
call   1090 <printAppxRow@plt>
movl   $0x5,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c8 <main+0x128>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <stirlingsApproximation2@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    %eax,%edx
call   1090 <printAppxRow@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1288 <main+0xe8>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <stirlingsApproximation2@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    %eax,%edx
call   1090 <printAppxRow@plt>
jmp    12f3 <main+0x153>
mov    $0x0,%al
call   10a0 <inputRequest@plt>
lea    0xcff(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
jmp    11c6 <main+0x26>
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   10a0 <inputRequest@plt>
lea    0xe46(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1869f,%eax
jne    11e5 <main+0x45>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe14(%rip),%r14
lea    0xc(%rsp),%r15
jmp    1224 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <invalidInputError@plt>
xor    %eax,%eax
call   10a0 <inputRequest@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1869f,%eax
je     11cf <main+0x2f>
test   %eax,%eax
jle    1200 <main+0x60>
cmp    $0xc,%eax
ja     1280 <main+0xe0>
xor    %eax,%eax
call   1080 <printHeaderWithFactorial@plt>
cmpl   $0x0,0xc(%rsp)
jle    1207 <main+0x67>
xor    %ebp,%ebp
nopl   (%rax)
add    $0x1,%ebp
mov    %ebp,%edi
call   1040 <factorial@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1070 <stirlingsApproximation2@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   10c0 <printFactRow@plt>
cmp    0xc(%rsp),%ebp
jl     1240 <main+0xa0>
jmp    1207 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <printApproximationHeader@plt>
mov    $0x1,%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1070 <stirlingsApproximation2@plt>
mov    $0x1,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1090 <printAppxRow@plt>
mov    0xc(%rsp),%ebx
cmp    $0x6,%ebx
jl     12e6 <main+0x146>
mov    $0x5,%ebp
nopl   0x0(%rax)
mov    %ebp,%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1070 <stirlingsApproximation2@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1090 <printAppxRow@plt>
add    $0x5,%ebp
mov    0xc(%rsp),%ebx
cmp    %ebx,%ebp
jl     12c0 <main+0x120>
mov    %ebx,%edi
call   1030 <stirlingsApproximation1@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
call   1070 <stirlingsApproximation2@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1090 <printAppxRow@plt>
jmp    1207 <main+0x67>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @inputRequest()
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 99999
br i1 %6, label %53, label %7
7: ; preds = %0, %48
%8 = phi i32 [ %51, %48 ], [ %5, %0 ]
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 (...) @invalidInputError()
br label %48
12: ; preds = %7
%13 = icmp ult i32 %8, 13
br i1 %13, label %14, label %27
14: ; preds = %12
%15 = call i32 (...) @printHeaderWithFactorial()
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 1
br i1 %17, label %48, label %18
18: ; preds = %14, %18
%19 = phi i32 [ %24, %18 ], [ 1, %14 ]
%20 = call i32 @factorial(i32 %19)
%21 = call i32 @stirlingsApproximation1(i32 %19)
%22 = call i32 @stirlingsApproximation2(i32 %19)
%23 = call i32 @printFactRow(i32 %19, i32 %20, i32 %21, i32 %22)
%24 = add nuw nsw i32 %19, 1
%25 = load i32, i32* %1
%26 = icmp slt i32 %19, %25
br i1 %26, label %18, label %48
27: ; preds = %12
%28 = call i32 (...) @printApproximationHeader()
%29 = call i32 @stirlingsApproximation1(i32 1)
%30 = call i32 @stirlingsApproximation2(i32 1)
%31 = call i32 @printAppxRow(i32 1, i32 %29, i32 %30)
%32 = load i32, i32* %1
%33 = icmp sgt i32 %32, 5
br i1 %33, label %34, label %42
34: ; preds = %27, %34
%35 = phi i32 [ %39, %34 ], [ 5, %27 ]
%36 = call i32 @stirlingsApproximation1(i32 %35)
%37 = call i32 @stirlingsApproximation2(i32 %35)
%38 = call i32 @printAppxRow(i32 %35, i32 %36, i32 %37)
%39 = add nuw nsw i32 %35, 5
%40 = load i32, i32* %1
%41 = icmp slt i32 %39, %40
br i1 %41, label %34, label %42
42: ; preds = %34, %27
%43 = phi i32 [ %32, %27 ], [ %40, %34 ]
%44 = call i32 @stirlingsApproximation1(i32 %43)
%45 = load i32, i32* %1
%46 = call i32 @stirlingsApproximation2(i32 %45)
%47 = call i32 @printAppxRow(i32 %43, i32 %44, i32 %46)
br label %48
48: ; preds = %18, %14, %42, %10
%49 = call i32 (...) @inputRequest()
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%51 = load i32, i32* %1
%52 = icmp eq i32 %51, 99999
br i1 %52, label %53, label %7
53: ; preds = %48, %0
%54 = load i32, i32* @EXIT_SUCCESS
ret i32 %54
}