#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*/ array_multiplication(char *, int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char);
void print_factorial(int num) {
  char result[200];
  int start = 0;
  int i, len = 200;
  memset(result, 0, 200);
  result[0] = 1;
  for (i = 2; i <= num; i++) {
    array_multiplication(result, 200, i);
  }
  while (len--) {
    if (start) {
      printf("%d", result[len]);
      continue;
    }
    if (result[len] != 0) {
      printf("%d", result[len]);
      start = 1;
    }
  }
}


x86 assembly (clang, -O0):
<print_factorial>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0xc8,-0xdc(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
movb   $0x1,-0xd0(%rbp)
movl   $0x2,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b0 <print_factorial+0x80>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%edx
mov    $0xc8,%esi
call   1040 <array_multiplication@plt>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1176 <print_factorial+0x46>
jmp    11b5 <print_factorial+0x85>
mov    -0xdc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xdc(%rbp)
cmp    $0x0,%eax
je     123e <print_factorial+0x10e>
cmpl   $0x0,-0xd4(%rbp)
je     11fc <print_factorial+0xcc>
movslq -0xdc(%rbp),%rax
lea    0xe16(%rip),%rdi
movsbl -0xd0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
jmp    11b5 <print_factorial+0x85>
movslq -0xdc(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1239 <print_factorial+0x109>
movslq -0xdc(%rbp),%rax
lea    0xdde(%rip),%rdi
movsbl -0xd0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
movl   $0x1,-0xd4(%rbp)
jmp    11b5 <print_factorial+0x85>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_factorial>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
mov    %edi,%r15d
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
movb   $0x1,(%rsp)
cmp    $0x2,%r15d
jl     1192 <print_factorial+0x62>
neg    %r15d
mov    $0x2,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0xc8,%esi
mov    %ebx,%edx
call   1040 <array_multiplication@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <print_factorial+0x40>
mov    $0xc8,%ebx
lea    0xe62(%rip),%r14
jmp    11b6 <print_factorial+0x86>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
je     11c7 <print_factorial+0x97>
movzbl -0x1(%rsp,%rbx,1),%eax
test   %ebp,%ebp
jne    11a0 <print_factorial+0x70>
xor    %ebp,%ebp
test   %al,%al
je     11b0 <print_factorial+0x80>
jmp    11a0 <print_factorial+0x70>
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @print_factorial(i32 %0) {
%2 = alloca i32
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
store i32 200, i32* %6
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 200)
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
store i8 1, i8* %9
store i32 2, i32* %5
br label %10
10: ; preds = %18, %1
%11 = load i32, i32* %5
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%16 = load i32, i32* %5
%17 = call i32 @array_multiplication(i8* %15, i32 200, i32 %16)
br label %18
18: ; preds = %14
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %10
21: ; preds = %10
br label %22
22: ; preds = %48, %29, %21
%23 = load i32, i32* %6
%24 = add nsw i32 %23, -1
store i32 %24, i32* %6
%25 = icmp ne i32 %23, 0
br i1 %25, label %26, label %49
26: ; preds = %22
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
br label %22
35: ; preds = %26
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %46)
store i32 1, i32* %4
br label %48
48: ; preds = %42, %35
br label %22
49: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_factorial(i32 %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 200)
store i8 1, i8* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ 2, %1 ]
%8 = call i32 @array_multiplication(i8* %3, i32 200, i32 %7)
%9 = add nuw i32 %7, 1
%10 = icmp eq i32 %7, %0
br i1 %10, label %11, label %6
11: ; preds = %6, %1
br label %12
12: ; preds = %11, %22
%13 = phi i64 [ %24, %22 ], [ 199, %11 ]
%14 = phi i32 [ %23, %22 ], [ 0, %11 ]
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %13
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = select i1 %15, i1 %18, i1 false
br i1 %19, label %22, label %20
20: ; preds = %12
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %17)
br label %22
22: ; preds = %12, %20
%23 = phi i32 [ 1, %20 ], [ 0, %12 ]
%24 = add nsw i64 %13, -1
%25 = icmp eq i64 %13, 0
br i1 %25, label %26, label %12
26: ; preds = %22
ret void
}