#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 *, ...);
void factorial_for_big_number(int n) {
  int a[300] = {0, 0, 6, 1, 0, 0, 9, 7, 4};
  int array[300] = {0};
  int m = 13;
  int i, j, k;
  int x = 0;
  int remain = 0;
  int hold = n;
  int number = 1;
  while (n > 12) {
    for (i = 0; i < 300 - 1; i++) {
      x = remain + a[i] * m;
      remain = x / 10;
      if (remain > 0) {
        array[i] = x % 10;
        array[i + 1] += remain;
      }
    }
    for (k = 0; k <= 300 - 1; k++)
      a[k] = array[k];
    n--;
    m++;
  }
  printf("%d!:", hold);
  for (j = 300 - 1; j >= 0;) {
    if (number <= 1) {
      while (array[j] == 0)
        j--;
      number++;
    }
    printf("%d", array[j]);
    if (j % 3 == 0 && j != 0)
      printf(",");
    j--;
  }
}


x86 assembly (clang, -O0):
<factorial_for_big_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x990,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x4b0,%edx
call   1040 <memset@plt>
movl   $0x6,-0x4b8(%rbp)
movl   $0x1,-0x4b4(%rbp)
movl   $0x9,-0x4a8(%rbp)
movl   $0x7,-0x4a4(%rbp)
movl   $0x4,-0x4a0(%rbp)
lea    -0x970(%rbp),%rdi
xor    %esi,%esi
mov    $0x4b0,%edx
call   1040 <memset@plt>
movl   $0xd,-0x974(%rbp)
movl   $0x0,-0x984(%rbp)
movl   $0x0,-0x988(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x98c(%rbp)
movl   $0x1,-0x990(%rbp)
cmpl   $0xc,-0x4(%rbp)
jle    12da <factorial_for_big_number+0x1ba>
movl   $0x0,-0x978(%rbp)
cmpl   $0x12b,-0x978(%rbp)
jge    1273 <factorial_for_big_number+0x153>
mov    -0x988(%rbp),%eax
movslq -0x978(%rbp),%rcx
mov    -0x4c0(%rbp,%rcx,4),%ecx
imul   -0x974(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x984(%rbp)
mov    -0x984(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x988(%rbp)
cmpl   $0x0,-0x988(%rbp)
jle    125a <factorial_for_big_number+0x13a>
mov    -0x984(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x978(%rbp),%rax
mov    %edx,-0x970(%rbp,%rax,4)
mov    -0x988(%rbp),%ecx
mov    -0x978(%rbp),%eax
add    $0x1,%eax
cltq
add    -0x970(%rbp,%rax,4),%ecx
mov    %ecx,-0x970(%rbp,%rax,4)
jmp    125f <factorial_for_big_number+0x13f>
mov    -0x978(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x978(%rbp)
jmp    11cb <factorial_for_big_number+0xab>
movl   $0x0,-0x980(%rbp)
cmpl   $0x12b,-0x980(%rbp)
jg     12bd <factorial_for_big_number+0x19d>
movslq -0x980(%rbp),%rax
mov    -0x970(%rbp,%rax,4),%ecx
movslq -0x980(%rbp),%rax
mov    %ecx,-0x4c0(%rbp,%rax,4)
mov    -0x980(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x980(%rbp)
jmp    127d <factorial_for_big_number+0x15d>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x974(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x974(%rbp)
jmp    11b7 <factorial_for_big_number+0x97>
mov    -0x98c(%rbp),%esi
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x12b,-0x97c(%rbp)
cmpl   $0x0,-0x97c(%rbp)
jl     13b1 <factorial_for_big_number+0x291>
cmpl   $0x1,-0x990(%rbp)
jg     134f <factorial_for_big_number+0x22f>
jmp    1317 <factorial_for_big_number+0x1f7>
movslq -0x97c(%rbp),%rax
cmpl   $0x0,-0x970(%rbp,%rax,4)
jne    1340 <factorial_for_big_number+0x220>
mov    -0x97c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x97c(%rbp)
jmp    1317 <factorial_for_big_number+0x1f7>
mov    -0x990(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x990(%rbp)
movslq -0x97c(%rbp),%rax
mov    -0x970(%rbp,%rax,4),%esi
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x97c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    139d <factorial_for_big_number+0x27d>
cmpl   $0x0,-0x97c(%rbp)
je     139d <factorial_for_big_number+0x27d>
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x97c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x97c(%rbp)
jmp    12f8 <factorial_for_big_number+0x1d8>
add    $0x990,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorial_for_big_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x968,%rsp
mov    %edi,%r12d
lea    0x4b0(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x4b0,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movabs $0x100000006,%rax
mov    %rax,0x4b8(%rsp)
movabs $0x700000009,%rax
mov    %rax,0x4c8(%rsp)
movl   $0x4,0x4d0(%rsp)
mov    %rsp,%rdi
mov    $0x4b0,%edx
xor    %esi,%esi
call   1050 <memset@plt>
cmp    $0xd,%r12d
jl     123e <factorial_for_big_number+0xfe>
mov    $0xd,%ebp
mov    $0xcccccccd,%r13d
lea    0x4b0(%rsp),%r14
mov    %rsp,%r15
jmp    11ea <factorial_for_big_number+0xaa>
nopw   0x0(%rax,%rax,1)
mov    $0x4b0,%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <memcpy@plt>
lea    0x1(%rbp),%eax
cmp    %r12d,%ebp
mov    %eax,%ebp
je     123e <factorial_for_big_number+0xfe>
xor    %eax,%eax
jmp    11fc <factorial_for_big_number+0xbc>
xchg   %ax,%ax
add    $0x1,%rax
cmp    $0x12b,%rax
je     11d0 <factorial_for_big_number+0x90>
mov    0x4b0(%rsp,%rax,4),%ecx
imul   %ebp,%ecx
add    %ebx,%ecx
movslq %ecx,%rdx
imul   $0x66666667,%rdx,%rbx
mov    %rbx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rbx
add    %esi,%ebx
cmp    $0x9,%edx
jle    11f0 <factorial_for_big_number+0xb0>
mov    %ecx,%edx
imul   %r13,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
mov    %ecx,(%rsp,%rax,4)
add    %ebx,0x4(%rsp,%rax,4)
jmp    11f0 <factorial_for_big_number+0xb0>
lea    0xdbb(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x12b,%ebx
mov    $0x1,%r15d
lea    0xda4(%rip),%r14
jmp    1279 <factorial_for_big_number+0x139>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbx),%eax
test   %ebx,%ebx
mov    %eax,%ebx
jle    12dc <factorial_for_big_number+0x19c>
cmp    $0x1,%r15d
jg     12a1 <factorial_for_big_number+0x161>
mov    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,(%rsp,%rbx,4)
lea    -0x1(%rbx),%rbx
je     1290 <factorial_for_big_number+0x150>
add    $0x1,%ebx
add    $0x1,%r15d
movslq %ebx,%rbp
mov    (%rsp,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     1270 <factorial_for_big_number+0x130>
imul   $0x55555556,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebp
jne    1270 <factorial_for_big_number+0x130>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    1270 <factorial_for_big_number+0x130>
add    $0x968,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d!:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c",\00"
define void @factorial_for_big_number(i32 %0) {
%2 = alloca i32
%3 = alloca [300 x i32]
%4 = alloca [300 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %2
%13 = bitcast [300 x i32]* %3 to i8*
%14 = bitcast i8* %13 to <{ [9 x i32], [291 x i32] }>*
%15 = getelementptr inbounds <{ [9 x i32], [291 x i32] }>, <{ [9 x i32], [291 x i32] }>* %14, i32 0, i32 0
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 2
store i32 6, i32* %16
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 3
store i32 1, i32* %17
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 6
store i32 9, i32* %18
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 7
store i32 7, i32* %19
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %15, i32 0, i32 8
store i32 4, i32* %20
%21 = bitcast [300 x i32]* %4 to i8*
store i32 13, i32* %5
store i32 0, i32* %9
store i32 0, i32* %10
%22 = load i32, i32* %2
store i32 %22, i32* %11
store i32 1, i32* %12
br label %23
23: ; preds = %75, %1
%24 = load i32, i32* %2
%25 = icmp sgt i32 %24, 12
br i1 %25, label %26, label %80
26: ; preds = %23
store i32 0, i32* %6
br label %27
27: ; preds = %57, %26
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 299
br i1 %29, label %30, label %60
30: ; preds = %27
%31 = load i32, i32* %10
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [300 x i32], [300 x i32]* %3, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* %5
%37 = mul nsw i32 %35, %36
%38 = add nsw i32 %31, %37
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = sdiv i32 %39, 10
store i32 %40, i32* %10
%41 = load i32, i32* %10
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %30
%44 = load i32, i32* %9
%45 = srem i32 %44, 10
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %47
store i32 %45, i32* %48
%49 = load i32, i32* %10
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = add nsw i32 %54, %49
store i32 %55, i32* %53
br label %56
56: ; preds = %43, %30
br label %57
57: ; preds = %56
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %27
60: ; preds = %27
store i32 0, i32* %8
br label %61
61: ; preds = %72, %60
%62 = load i32, i32* %8
%63 = icmp sle i32 %62, 299
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [300 x i32], [300 x i32]* %3, i64 0, i64 %70
store i32 %68, i32* %71
br label %72
72: ; preds = %64
%73 = load i32, i32* %8
%74 = add nsw i32 %73, 1
store i32 %74, i32* %8
br label %61
75: ; preds = %61
%76 = load i32, i32* %2
%77 = add nsw i32 %76, -1
store i32 %77, i32* %2
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 1
store i32 %79, i32* %5
br label %23
80: ; preds = %23
%81 = load i32, i32* %11
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %81)
store i32 299, i32* %7
br label %83
83: ; preds = %116, %80
%84 = load i32, i32* %7
%85 = icmp sge i32 %84, 0
br i1 %85, label %86, label %119
86: ; preds = %83
%87 = load i32, i32* %12
%88 = icmp sle i32 %87, 1
br i1 %88, label %89, label %102
89: ; preds = %86
br label %90
90: ; preds = %96, %89
%91 = load i32, i32* %7
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %92
%94 = load i32, i32* %93
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %90
%97 = load i32, i32* %7
%98 = add nsw i32 %97, -1
store i32 %98, i32* %7
br label %90
99: ; preds = %90
%100 = load i32, i32* %12
%101 = add nsw i32 %100, 1
store i32 %101, i32* %12
br label %102
102: ; preds = %99, %86
%103 = load i32, i32* %7
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %104
%106 = load i32, i32* %105
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %7
%109 = srem i32 %108, 3
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %116
111: ; preds = %102
%112 = load i32, i32* %7
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %111
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %116
116: ; preds = %114, %111, %102
%117 = load i32, i32* %7
%118 = add nsw i32 %117, -1
store i32 %118, i32* %7
br label %83
119: ; preds = %83
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d!:\00"
@.str.1 = [3 x i8] c"%d\00"
define void @factorial_for_big_number(i32 %0) {
%2 = alloca [300 x i32]
%3 = bitcast [300 x i32]* %2 to i8*
%4 = alloca [300 x i32]
%5 = bitcast [300 x i32]* %4 to i8*
%6 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 2
store i32 6, i32* %6
%7 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 3
store i32 1, i32* %7
%8 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 6
store i32 9, i32* %8
%9 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 7
store i32 7, i32* %9
%10 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 8
store i32 4, i32* %10
%11 = icmp sgt i32 %0, 12
br i1 %11, label %12, label %39
12: ; preds = %1, %15
%13 = phi i32 [ %25, %15 ], [ 0, %1 ]
%14 = phi i32 [ %16, %15 ], [ 13, %1 ]
br label %18
15: ; preds = %36
%16 = add nuw i32 %14, 1
%17 = icmp eq i32 %14, %0
br i1 %17, label %39, label %12
18: ; preds = %12, %36
%19 = phi i64 [ 0, %12 ], [ %37, %36 ]
%20 = phi i32 [ %13, %12 ], [ %25, %36 ]
%21 = getelementptr inbounds [300 x i32], [300 x i32]* %2, i64 0, i64 %19
%22 = load i32, i32* %21
%23 = mul nsw i32 %22, %14
%24 = add nsw i32 %23, %20
%25 = sdiv i32 %24, 10
%26 = icmp sgt i32 %24, 9
br i1 %26, label %29, label %27
27: ; preds = %18
%28 = add nuw nsw i64 %19, 1
br label %36
29: ; preds = %18
%30 = urem i32 %24, 10
%31 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %19
store i32 %30, i32* %31
%32 = add nuw nsw i64 %19, 1
%33 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = add nsw i32 %34, %25
store i32 %35, i32* %33
br label %36
36: ; preds = %27, %29
%37 = phi i64 [ %28, %27 ], [ %32, %29 ]
%38 = icmp eq i64 %37, 299
br i1 %38, label %15, label %18
39: ; preds = %15, %1
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %41
41: ; preds = %39, %69
%42 = phi i32 [ 1, %39 ], [ %58, %69 ]
%43 = phi i32 [ 299, %39 ], [ %70, %69 ]
%44 = icmp slt i32 %42, 2
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = zext i32 %43 to i64
br label %47
47: ; preds = %45, %47
%48 = phi i64 [ %46, %45 ], [ %52, %47 ]
%49 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 0
%52 = add i64 %48, -1
br i1 %51, label %47, label %53
53: ; preds = %47
%54 = trunc i64 %48 to i32
%55 = add nsw i32 %42, 1
br label %56
56: ; preds = %53, %41
%57 = phi i32 [ %54, %53 ], [ %43, %41 ]
%58 = phi i32 [ %55, %53 ], [ %42, %41 ]
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [300 x i32], [300 x i32]* %4, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = srem i32 %57, 3
%64 = icmp eq i32 %63, 0
%65 = icmp ne i32 %57, 0
%66 = and i1 %65, %64
br i1 %66, label %67, label %69
67: ; preds = %56
%68 = tail call i32 @putchar(i32 44)
br label %69
69: ; preds = %67, %56
%70 = add nsw i32 %57, -1
%71 = icmp sgt i32 %57, 0
br i1 %71, label %41, label %72
72: ; preds = %69
ret void
}