#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, j, a, n, k;
  printf("Enter no. of rows needed");
  scanf("%d", &a);
  for (i = 0; i <= a; i++) {
    for (j = 0; j <= i; j++) {
      if (i == 0 || j == 0) {
        printf("1");
      } else {
        int nf, rf, n_rf;
        for (nf = 1, k = 1; k <= n; k++) {
          nf = nf * k;
        }
        for (rf = 1, k = 1; k <= n; k++) {
          rf = rf * k;
        }
        for (n_rf = 1, k = 1; k <= n; k++) {
          n_rf = n_rf * k;
        }
        printf("%d", nf / rf * n_rf);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     127a <main+0x15a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     125e <main+0x13e>
cmpl   $0x0,-0x8(%rbp)
je     1187 <main+0x67>
cmpl   $0x0,-0xc(%rbp)
jne    119a <main+0x7a>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124b <main+0x12b>
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11cc <main+0xac>
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a8 <main+0x88>
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11fe <main+0xde>
mov    -0x20(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11da <main+0xba>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1230 <main+0x110>
mov    -0x24(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120c <main+0xec>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,%esi
imul   -0x24(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1250 <main+0x130>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <main+0x47>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
js     11ac <main+0x7c>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
add    $0x1,%ebp
cmp    0xc(%rsp),%r14d
mov    %eax,%r14d
jl     1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter no. of rows needed\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
br label %12
12: ; preds = %78, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %81
16: ; preds = %12
store i32 0, i32* %3
br label %17
17: ; preds = %73, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %76
21: ; preds = %17
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %72
29: ; preds = %24
store i32 1, i32* %7
store i32 1, i32* %6
br label %30
30: ; preds = %38, %29
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = mul nsw i32 %35, %36
store i32 %37, i32* %7
br label %38
38: ; preds = %34
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %30
41: ; preds = %30
store i32 1, i32* %8
store i32 1, i32* %6
br label %42
42: ; preds = %50, %41
%43 = load i32, i32* %6
%44 = load i32, i32* %5
%45 = icmp sle i32 %43, %44
br i1 %45, label %46, label %53
46: ; preds = %42
%47 = load i32, i32* %8
%48 = load i32, i32* %6
%49 = mul nsw i32 %47, %48
store i32 %49, i32* %8
br label %50
50: ; preds = %46
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %42
53: ; preds = %42
store i32 1, i32* %9
store i32 1, i32* %6
br label %54
54: ; preds = %62, %53
%55 = load i32, i32* %6
%56 = load i32, i32* %5
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %65
58: ; preds = %54
%59 = load i32, i32* %9
%60 = load i32, i32* %6
%61 = mul nsw i32 %59, %60
store i32 %61, i32* %9
br label %62
62: ; preds = %58
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %54
65: ; preds = %54
%66 = load i32, i32* %7
%67 = load i32, i32* %8
%68 = sdiv i32 %66, %67
%69 = load i32, i32* %9
%70 = mul nsw i32 %68, %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %65, %27
br label %73
73: ; preds = %72
%74 = load i32, i32* %3
%75 = add nsw i32 %74, 1
store i32 %75, i32* %3
br label %17
76: ; preds = %17
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %76
%79 = load i32, i32* %2
%80 = add nsw i32 %79, 1
store i32 %80, i32* %2
br label %12
81: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter no. of rows needed\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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 slt i32 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %0, %18
%8 = phi i32 [ %23, %18 ], [ 1, %0 ]
%9 = phi i32 [ %20, %18 ], [ 0, %0 ]
%10 = icmp eq i32 %9, 0
br label %11
11: ; preds = %7, %11
%12 = phi i32 [ 0, %7 ], [ %16, %11 ]
%13 = icmp eq i32 %12, 0
%14 = select i1 %10, i1 true, i1 %13
%15 = call i32 @putchar(i32 49)
%16 = add nuw i32 %12, 1
%17 = icmp eq i32 %16, %8
br i1 %17, label %18, label %11
18: ; preds = %11
%19 = call i32 @putchar(i32 10)
%20 = add nuw nsw i32 %9, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %9, %21
%23 = add nuw i32 %8, 1
br i1 %22, label %7, label %24
24: ; preds = %18, %0
ret i32 0
}