#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 factorial(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, i, j;
  printf("Enter the numbers of rows ");
  scanf("%d", &num);
  for (i = 0; i < num; i++) {
    for (j = 0; j < num - i; j++)
      printf("  ");
    for (j = 0; j <= i; j++)
      printf(" %3d", factorial(i) / (factorial(j) * factorial(i - j)));
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1220 <main+0xf0>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11a4 <main+0x74>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <main+0x47>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1204 <main+0xd4>
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1030 <factorial@plt>
mov    -0x18(%rbp),%ecx
mov    %eax,%edx
mov    -0x14(%rbp),%eax
imul   %edx,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ab <main+0x7b>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x34>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    121e <main+0xde>
lea    0xea1(%rip),%rbp
lea    0xe9d(%rip),%r15
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
cmp    %r12d,%eax
jle    11b8 <main+0x78>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
sub    %r12d,%eax
cmp    %eax,%ebx
jl     11a0 <main+0x60>
xor    %ebx,%ebx
mov    %r12d,%ebp
nopl   (%rax)
mov    %r12d,%edi
call   1040 <factorial@plt>
mov    %eax,%r13d
mov    %ebx,%edi
call   1040 <factorial@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1040 <factorial@plt>
mov    %eax,%ecx
imul   %r14d,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jb     11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
mov    0x4(%rsp),%eax
cmp    %eax,%r12d
lea    0xe06(%rip),%rbp
jl     1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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