#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 *bellTriangle(int const);
int /*<<< orphan*/ free(int *);
int getBell(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  const int rows = 15;
  int *bt = bellTriangle(rows);
  int i, j;
  printf("First fifteen Bell numbers:\n");
  for (i = 1; i <= rows; ++i) {
    printf("%2d: %d\n", i, getBell(bt, i, 0));
  }
  printf("\nThe first ten rows of Bell's triangle:\n");
  for (i = 1; i <= 10; ++i) {
    printf("%d", getBell(bt, i, 0));
    for (j = 1; j < i; ++j) {
      printf(", %d", getBell(bt, i, j));
    }
    printf("\n");
  }
  free(bt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x8(%rbp)
mov    $0xf,%edi
call   1050 <bellTriangle@plt>
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xf,-0x14(%rbp)
jg     11b8 <main+0x78>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1060 <getBell@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x39>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jg     1251 <main+0x111>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1060 <getBell@plt>
mov    %eax,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1235 <main+0xf5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <getBell@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fc <main+0xbc>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cd <main+0x8d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
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
mov    $0xf,%edi
call   1070 <bellTriangle@plt>
mov    %rax,%r15
lea    0xe8f(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r12d
mov    %r15,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
lea    0xe60(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x3,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x5,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x6,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x7,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x8,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x9,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xa,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xb,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xb,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xc,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xd,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xd,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xe,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xe,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0xf,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    $0xf,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcb2(%rip),%rdi
call   1050 <puts@plt>
lea    0xc87(%rip),%r14
lea    0xc7e(%rip),%r13
xor    %ebx,%ebx
jmp    13a7 <main+0x247>
nop
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r12d
add    $0xffffffff,%ebx
cmp    $0xb,%r12d
je     13fd <main+0x29d>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %edx,%edx
call   1080 <getBell@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%r12d
jb     1390 <main+0x230>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
call   1080 <getBell@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    13d0 <main+0x270>
jmp    1390 <main+0x230>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%2d: %d\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c", %d\00"
@str = [28 x i8] c"First fifteen Bell numbers:\00"
@str.6 = [40 x i8] c"\0AThe first ten rows of Bell's triangle:\00"
define i32 @main() {
%1 = tail call i32* @bellTriangle(i32 15)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @getBell(i32* %1, i32 1, i32 0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %3)
%5 = tail call i32 @getBell(i32* %1, i32 2, i32 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %5)
%7 = tail call i32 @getBell(i32* %1, i32 3, i32 0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %7)
%9 = tail call i32 @getBell(i32* %1, i32 4, i32 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %9)
%11 = tail call i32 @getBell(i32* %1, i32 5, i32 0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %11)
%13 = tail call i32 @getBell(i32* %1, i32 6, i32 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %13)
%15 = tail call i32 @getBell(i32* %1, i32 7, i32 0)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %15)
%17 = tail call i32 @getBell(i32* %1, i32 8, i32 0)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %17)
%19 = tail call i32 @getBell(i32* %1, i32 9, i32 0)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %19)
%21 = tail call i32 @getBell(i32* %1, i32 10, i32 0)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 %21)
%23 = tail call i32 @getBell(i32* %1, i32 11, i32 0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 11, i32 %23)
%25 = tail call i32 @getBell(i32* %1, i32 12, i32 0)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 12, i32 %25)
%27 = tail call i32 @getBell(i32* %1, i32 13, i32 0)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 13, i32 %27)
%29 = tail call i32 @getBell(i32* %1, i32 14, i32 0)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 14, i32 %29)
%31 = tail call i32 @getBell(i32* %1, i32 15, i32 0)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 15, i32 %31)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
br label %34
34: ; preds = %0, %45
%35 = phi i32 [ 1, %0 ], [ %47, %45 ]
%36 = tail call i32 @getBell(i32* %1, i32 %35, i32 0)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = icmp ugt i32 %35, 1
br i1 %38, label %39, label %45
39: ; preds = %34, %39
%40 = phi i32 [ %43, %39 ], [ 1, %34 ]
%41 = tail call i32 @getBell(i32* %1, i32 %35, i32 %40)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = add nuw nsw i32 %40, 1
%44 = icmp eq i32 %43, %35
br i1 %44, label %45, label %39
45: ; preds = %39, %34
%46 = tail call i32 @putchar(i32 10)
%47 = add nuw nsw i32 %35, 1
%48 = icmp eq i32 %47, 11
br i1 %48, label %49, label %34
49: ; preds = %45
%50 = tail call i32 @free(i32* %1)
ret i32 0
}