int find_num_possible_binary_search_trees_size_n_v1(int n) {
  int num_left_tree, num_right_tree, total;
  int root;
  if (n <= 0) {
    return (0);
  }
  if (n == 1) {
    return (1);
  }
  total = 0;
  for (root = 1; root <= n; ++root) {
    num_left_tree = find_num_possible_binary_search_trees_size_n_v1(root - 1);
    num_right_tree = find_num_possible_binary_search_trees_size_n_v1(n - root);
    if ((num_left_tree > 0) && (num_right_tree > 0)) {
      total += num_left_tree * num_right_tree;
    } else if (num_left_tree > 0) {
      total += num_left_tree;
    } else if (num_right_tree > 0) {
      total += num_right_tree;
    }
  }
  return (total);
}


x86 assembly (clang, -O0):
<find_num_possible_binary_search_trees_size_n_v1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1131 <find_num_possible_binary_search_trees_size_n_v1+0x21>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <find_num_possible_binary_search_trees_size_n_v1+0xe1>
cmpl   $0x1,-0x8(%rbp)
jne    1147 <find_num_possible_binary_search_trees_size_n_v1+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11f1 <find_num_possible_binary_search_trees_size_n_v1+0xe1>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11eb <find_num_possible_binary_search_trees_size_n_v1+0xdb>
mov    -0x18(%rbp),%edi
sub    $0x1,%edi
call   1030 <find_num_possible_binary_search_trees_size_n_v1@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    -0x18(%rbp),%edi
call   1030 <find_num_possible_binary_search_trees_size_n_v1@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11a3 <find_num_possible_binary_search_trees_size_n_v1+0x93>
cmpl   $0x0,-0x10(%rbp)
jle    11a3 <find_num_possible_binary_search_trees_size_n_v1+0x93>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11d8 <find_num_possible_binary_search_trees_size_n_v1+0xc8>
cmpl   $0x0,-0xc(%rbp)
jle    11bb <find_num_possible_binary_search_trees_size_n_v1+0xab>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11d3 <find_num_possible_binary_search_trees_size_n_v1+0xc3>
cmpl   $0x0,-0x10(%rbp)
jle    11ce <find_num_possible_binary_search_trees_size_n_v1+0xbe>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11d3 <find_num_possible_binary_search_trees_size_n_v1+0xc3>
jmp    11d8 <find_num_possible_binary_search_trees_size_n_v1+0xc8>
jmp    11dd <find_num_possible_binary_search_trees_size_n_v1+0xcd>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <find_num_possible_binary_search_trees_size_n_v1+0x45>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_num_possible_binary_search_trees_size_n_v1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    117d <find_num_possible_binary_search_trees_size_n_v1+0x6d>
mov    %edi,%r15d
mov    $0x1,%r14d
cmp    $0x1,%edi
je     1180 <find_num_possible_binary_search_trees_size_n_v1+0x70>
add    $0xffffffff,%r15d
xor    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1030 <find_num_possible_binary_search_trees_size_n_v1@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1030 <find_num_possible_binary_search_trees_size_n_v1@plt>
mov    %eax,%ecx
imul   %ebx,%ecx
test   %eax,%eax
mov    $0x0,%edx
cmovg  %eax,%edx
test   %ebx,%ebx
cmovg  %ebx,%edx
test   %eax,%eax
cmovle %edx,%ecx
test   %ebx,%ebx
cmovle %edx,%ecx
add    %ecx,%r14d
add    $0x1,%ebp
add    $0xffffffff,%r15d
jb     1140 <find_num_possible_binary_search_trees_size_n_v1+0x30>
jmp    1180 <find_num_possible_binary_search_trees_size_n_v1+0x70>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %61
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %2
br label %61
15: ; preds = %11
store i32 0, i32* %6
store i32 1, i32* %7
br label %16
16: ; preds = %56, %15
%17 = load i32, i32* %7
%18 = load i32, i32* %3
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %59
20: ; preds = %16
%21 = load i32, i32* %7
%22 = sub nsw i32 %21, 1
%23 = call i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %22)
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = call i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %26)
store i32 %27, i32* %5
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %20
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, %36
store i32 %38, i32* %6
br label %55
39: ; preds = %30, %20
%40 = load i32, i32* %4
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* %4
%44 = load i32, i32* %6
%45 = add nsw i32 %44, %43
store i32 %45, i32* %6
br label %54
46: ; preds = %39
%47 = load i32, i32* %5
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = add nsw i32 %51, %50
store i32 %52, i32* %6
br label %53
53: ; preds = %49, %46
br label %54
54: ; preds = %53, %42
br label %55
55: ; preds = %54, %33
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %16
59: ; preds = %16
%60 = load i32, i32* %6
store i32 %60, i32* %2
br label %61
61: ; preds = %59, %14, %10
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
define i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1
br i1 %4, label %22, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %20, %5 ], [ 1, %3 ]
%7 = phi i32 [ %19, %5 ], [ 0, %3 ]
%8 = add nsw i32 %6, -1
%9 = tail call i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %8)
%10 = sub nsw i32 %0, %6
%11 = tail call i32 @find_num_possible_binary_search_trees_size_n_v1(i32 %10)
%12 = icmp sgt i32 %9, 0
%13 = icmp sgt i32 %11, 0
%14 = select i1 %12, i1 %13, i1 false
%15 = mul nsw i32 %11, %9
%16 = select i1 %13, i32 %11, i32 0
%17 = select i1 %12, i32 %9, i32 %16
%18 = select i1 %14, i32 %15, i32 %17
%19 = add nsw i32 %18, %7
%20 = add nuw i32 %6, 1
%21 = icmp eq i32 %6, %0
br i1 %21, label %22, label %5
22: ; preds = %5, %3, %1
%23 = phi i32 [ 0, %1 ], [ 1, %3 ], [ %19, %5 ]
ret i32 %23
}