#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 rows, coef = 1, space, i, j;
  printf("Enter number of rows: ");
  scanf("%d", &rows);
  for (i = 0; i < rows; i++) {
    for (space = 1; space <= rows - i; space++)
      printf(" ");
    for (j = 0; j <= i; j++) {
      if (j == 0 || i == 0)
        coef = 1;
      else
        coef = coef * (i - j + 1) / j;
      printf("%4d", coef);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121f <main+0xff>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jg     119b <main+0x7b>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116e <main+0x4e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1203 <main+0xe3>
cmpl   $0x0,-0x18(%rbp)
je     11c2 <main+0xa2>
cmpl   $0x0,-0x14(%rbp)
jne    11ce <main+0xae>
movl   $0x1,-0xc(%rbp)
jmp    11e4 <main+0xc4>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a2 <main+0x82>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x3b>
mov    -0x4(%rbp),%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    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
jle    1210 <main+0xe0>
mov    $0x1,%r12d
lea    0xeaa(%rip),%r15
xor    %r13d,%r13d
mov    $0x1,%ebp
jmp    119c <main+0x6c>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
add    $0x1,%r12d
mov    0x4(%rsp),%ecx
mov    %ecx,%r13d
cmp    %eax,%ecx
jge    1210 <main+0xe0>
cmp    %r13d,%eax
jle    11c7 <main+0x97>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
sub    %r13d,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     11b0 <main+0x80>
lea    0x1(%r13),%eax
mov    %eax,0x4(%rsp)
xor    %ebx,%ebx
mov    %r12d,%r14d
jmp    11f5 <main+0xc5>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
add    $0xffffffff,%r14d
je     1180 <main+0x50>
mov    %ebp,%eax
mov    $0x1,%ebp
test   %ebx,%ebx
je     11e0 <main+0xb0>
test   %r13d,%r13d
je     11e0 <main+0xb0>
imul   %r14d,%eax
cltd
idiv   %ebx
mov    %eax,%ebp
jmp    11e0 <main+0xb0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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