#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 */
struct TreeNode {
  int dummy;
};

/* Variables and functions */
struct TreeNode **generateTrees(int, int *);
int numTrees(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  struct TreeNode **roots;
  int r, i;
  for (i = 0; i < 5; i++) {
    roots = generateTrees(i, &r);
    printf("%d, %d\n", numTrees(i), r);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    1187 <main+0x57>
mov    -0x18(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   1050 <generateTrees@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <numTrees@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <generateTrees@plt>
xor    %edi,%edi
call   1040 <numTrees@plt>
mov    0x4(%rsp),%edx
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
mov    %r14,%rsi
call   1050 <generateTrees@plt>
mov    $0x1,%edi
call   1040 <numTrees@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x2,%edi
mov    %r14,%rsi
call   1050 <generateTrees@plt>
mov    $0x2,%edi
call   1040 <numTrees@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x3,%edi
mov    %r14,%rsi
call   1050 <generateTrees@plt>
mov    $0x3,%edi
call   1040 <numTrees@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x4,%edi
mov    %r14,%rsi
call   1050 <generateTrees@plt>
mov    $0x4,%edi
call   1040 <numTrees@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TreeNode = type { i32 }
@.str = [8 x i8] c"%d, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.TreeNode**
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %4
%10 = call %struct.TreeNode** @generateTrees(i32 %9, i32* %3)
store %struct.TreeNode** %10, %struct.TreeNode*** %2
%11 = load i32, i32* %4
%12 = call i32 @numTrees(i32 %11)
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %15
15: ; preds = %8
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %5
18: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
%struct.TreeNode = type { i32 }
@.str = [8 x i8] c"%d, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call %struct.TreeNode** @generateTrees(i32 0, i32* %1)
%4 = call i32 @numTrees(i32 0)
%5 = load i32, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = call %struct.TreeNode** @generateTrees(i32 1, i32* %1)
%8 = call i32 @numTrees(i32 1)
%9 = load i32, i32* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = call %struct.TreeNode** @generateTrees(i32 2, i32* %1)
%12 = call i32 @numTrees(i32 2)
%13 = load i32, i32* %1
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = call %struct.TreeNode** @generateTrees(i32 3, i32* %1)
%16 = call i32 @numTrees(i32 3)
%17 = load i32, i32* %1
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
%19 = call %struct.TreeNode** @generateTrees(i32 4, i32* %1)
%20 = call i32 @numTrees(i32 4)
%21 = load i32, i32* %1
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
ret i32 0
}