#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 i, n, c;
  printf("Enter the number of rows you wish to see in pascal triangle\n");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (c = 0; c <= (n - i - 2); c++)
      printf(" ");
    for (c = 0; c <= i; c++)
      printf("%ld ", factorial(i) / (factorial(c) * factorial(i - c)));
    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    0xee9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1223 <main+0xf3>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     11a7 <main+0x77>
lea    0xeb1(%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    -0x8(%rbp),%eax
jg     1207 <main+0xd7>
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%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    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ae <main+0x7e>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%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    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1227 <main+0xd7>
lea    0xe78(%rip),%r14
xor    %r15d,%r15d
xchg   %ax,%ax
mov    $0xfffffffe,%ebx
sub    %r15d,%ebx
add    %ebx,%eax
js     11c7 <main+0x77>
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
add    %ebx,%eax
add    $0x1,%ebp
cmp    %eax,%ebp
jl     11b0 <main+0x60>
xor    %ebx,%ebx
mov    %r15d,%ebp
nopl   0x0(%rax)
mov    %r15d,%edi
call   1050 <factorial@plt>
mov    %eax,%r12d
mov    %ebx,%edi
call   1050 <factorial@plt>
mov    %eax,%r13d
mov    %ebp,%edi
call   1050 <factorial@plt>
mov    %eax,%ecx
imul   %r13d,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jb     11d0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
mov    0x4(%rsp),%eax
cmp    %eax,%r15d
jl     1190 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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