#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 *, ...);
void print_pascal_triangle(int dimension) {
  int k, i;
  for (k = 0; k < dimension; k++) {
    for (i = 0; i <= k; i++)
      printf("%d ", factorial(k) / (factorial(i) * factorial(k - i)));
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_pascal_triangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ba <print_pascal_triangle+0x9a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119e <print_pascal_triangle+0x7e>
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    -0x14(%rbp),%ecx
mov    %eax,%edx
mov    -0x10(%rbp),%eax
imul   %edx,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <print_pascal_triangle+0x25>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <print_pascal_triangle+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pascal_triangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
test   %edi,%edi
jle    11b1 <print_pascal_triangle+0x81>
lea    0xeb6(%rip),%r15
xor    %r12d,%r12d
nopl   (%rax)
mov    %r12d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
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     1160 <print_pascal_triangle+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    0x4(%rsp),%r12d
jne    1150 <print_pascal_triangle+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_pascal_triangle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %31, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %34
9: ; preds = %5
store i32 0, i32* %4
br label %10
10: ; preds = %26, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32 @factorial(i32 %15)
%17 = load i32, i32* %4
%18 = call i32 @factorial(i32 %17)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = call i32 @factorial(i32 %21)
%23 = mul nsw i32 %18, %22
%24 = sdiv i32 %16, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %14
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %10
29: ; preds = %10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %5
34: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @print_pascal_triangle(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %22
3: ; preds = %1, %17
%4 = phi i32 [ %20, %17 ], [ 1, %1 ]
%5 = phi i32 [ %19, %17 ], [ 0, %1 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %15, %6 ]
%8 = tail call i32 @factorial(i32 %5)
%9 = tail call i32 @factorial(i32 %7)
%10 = sub nsw i32 %5, %7
%11 = tail call i32 @factorial(i32 %10)
%12 = mul nsw i32 %11, %9
%13 = sdiv i32 %8, %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, %4
br i1 %16, label %17, label %6
17: ; preds = %6
%18 = tail call i32 @putchar(i32 10)
%19 = add nuw nsw i32 %5, 1
%20 = add nuw i32 %4, 1
%21 = icmp eq i32 %19, %0
br i1 %21, label %22, label %3
22: ; preds = %17, %1
ret void
}