int main() {
  int **edges;
  int ansSize, *ans, i;
  edges = (int **)malloc(3 * sizeof(int *));
  for (i = 0; i < 3; i++) {
    edges[i] = (int *)malloc(2 * sizeof(int));
  }
  edges[0][0] = 1;
  edges[0][1] = 0;
  edges[1][0] = 1;
  edges[1][1] = 2;
  edges[2][0] = 1;
  edges[2][1] = 3;
  ans = findMinHeightTrees(4, edges, 3, 2, &ansSize);
  for (i = 0; i < ansSize; i++) {
    printf("Ans %d\n", *(ans + i));
  }
  for (i = 0; i < 3; i++) {
    free(edges[i]);
  }
  free(edges);
  free(ans);
  edges = (int **)malloc(5 * sizeof(int *));
  for (i = 0; i < 5; i++) {
    edges[i] = (int *)malloc(2 * sizeof(int));
  }
  edges[0][0] = 0;
  edges[0][1] = 3;
  edges[1][0] = 1;
  edges[1][1] = 3;
  edges[2][0] = 2;
  edges[2][1] = 3;
  edges[3][0] = 4;
  edges[3][1] = 3;
  edges[4][0] = 5;
  edges[4][1] = 4;
  ans = findMinHeightTrees(6, edges, 5, 2, &ansSize);
  for (i = 0; i < ansSize; i++) {
    printf("Ans %d\n", *(ans + i));
  }
  for (i = 0; i < 5; i++) {
    free(edges[i]);
  }
  free(edges);
  printf("Free ans %p\n", ans);
  free(ans);
  edges = (int **)malloc(5 * sizeof(int *));
  assert(edges);
  for (i = 0; i < 5; i++) {
    edges[i] = (int *)malloc(2 * sizeof(int));
    assert(edges[i]);
  }
  edges[0][0] = 3;
  edges[0][1] = 0;
  edges[1][0] = 3;
  edges[1][1] = 1;
  edges[2][0] = 3;
  edges[2][1] = 2;
  edges[3][0] = 3;
  edges[3][1] = 4;
  edges[4][0] = 5;
  edges[4][1] = 4;
  ans = findMinHeightTrees(6, edges, 5, 2, &ansSize);
  for (i = 0; i < ansSize; i++) {
    printf("Ans %d\n", *(ans + i));
  }
  for (i = 0; i < 5; i++) {
    free(edges[i]);
  }
  free(edges);
  free(ans);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11a5 <main+0x55>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <main+0x24>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rsi
mov    $0x4,%edi
mov    $0x3,%edx
mov    $0x2,%ecx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1070 <findMinHeightTrees@plt>
cltq
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1258 <main+0x108>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1225 <main+0xd5>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1288 <main+0x138>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    125f <main+0x10f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    12e0 <main+0x190>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12af <main+0x15f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x5,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rsi
mov    $0x6,%edi
mov    $0x5,%edx
mov    $0x2,%ecx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1070 <findMinHeightTrees@plt>
cltq
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13cd <main+0x27d>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    139a <main+0x24a>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    13fd <main+0x2ad>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13d4 <main+0x284>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rsi
lea    0xbf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    1485 <main+0x335>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1441 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x5,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rsi
mov    $0x6,%edi
mov    $0x5,%edx
mov    $0x2,%ecx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1070 <findMinHeightTrees@plt>
cltq
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1572 <main+0x422>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xaa3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    153f <main+0x3ef>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    15a2 <main+0x452>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1579 <main+0x429>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%r14)
movq   $0x1,(%r15)
movabs $0x200000001,%rcx
mov    %rcx,(%rbx)
movabs $0x300000001,%rcx
mov    %rcx,(%rax)
lea    0x4(%rsp),%r8
mov    $0x4,%edi
mov    %r14,%rsi
mov    $0x3,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1070 <findMinHeightTrees@plt>
movslq %eax,%rbx
cmpl   $0x0,0x4(%rsp)
jle    120b <main+0xbb>
lea    0xe19(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
cmp    %rax,%rbp
jl     11f0 <main+0xa0>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    0x8(%r14),%rdi
call   1030 <free@plt>
mov    0x10(%r14),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,0x8(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    %rax,0x10(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x18(%r14)
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%r14)
movabs $0x300000000,%rcx
mov    %rcx,(%r15)
movabs $0x300000001,%rcx
mov    %rcx,(%r12)
movabs $0x300000002,%rcx
mov    %rcx,0x0(%r13)
movabs $0x300000004,%rcx
mov    %rcx,(%rbx)
movabs $0x400000005,%r12
mov    %r12,(%rax)
lea    0x4(%rsp),%r8
mov    $0x6,%edi
mov    %r14,%rsi
mov    $0x5,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1070 <findMinHeightTrees@plt>
movslq %eax,%rbx
cmpl   $0x0,0x4(%rsp)
jle    132b <main+0x1db>
lea    0xcfb(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
cmp    %rax,%rbp
jl     1310 <main+0x1c0>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    0x8(%r14),%rdi
call   1030 <free@plt>
mov    0x10(%r14),%rdi
call   1030 <free@plt>
mov    0x18(%r14),%rdi
call   1030 <free@plt>
mov    0x20(%r14),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xca2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%r14)
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%r14)
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x18(%r14)
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%r14)
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    (%r14),%rax
movq   $0x3,(%rax)
mov    0x8(%r14),%rax
movabs $0x100000003,%rcx
mov    %rcx,(%rax)
mov    0x10(%r14),%rax
movabs $0x200000003,%rcx
mov    %rcx,(%rax)
mov    0x18(%r14),%rax
movabs $0x400000003,%rcx
mov    %rcx,(%rax)
mov    0x20(%r14),%rax
mov    %r12,(%rax)
lea    0x4(%rsp),%r8
mov    $0x6,%edi
mov    %r14,%rsi
mov    $0x5,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1070 <findMinHeightTrees@plt>
movslq %eax,%rbx
cmpl   $0x0,0x4(%rsp)
jle    149b <main+0x34b>
lea    0xb87(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
cmp    %rax,%rbp
jl     1480 <main+0x330>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    0x8(%r14),%rdi
call   1030 <free@plt>
mov    0x10(%r14),%rdi
call   1030 <free@plt>
mov    0x18(%r14),%rdi
call   1030 <free@plt>
mov    0x20(%r14),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%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 = [8 x i8] c"Ans %d\0A\00"
@.str.1 = [13 x i8] c"Free ans %p\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
%6 = call i8* @malloc(i64 24)
%7 = bitcast i8* %6 to i32**
store i32** %7, i32*** %2
store i32 0, i32* %5
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = call i8* @malloc(i64 8)
%13 = bitcast i8* %12 to i32*
%14 = load i32**, i32*** %2
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32*, i32** %14, i64 %16
store i32* %13, i32** %17
br label %18
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%22 = load i32**, i32*** %2
%23 = getelementptr inbounds i32*, i32** %22, i64 0
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 1, i32* %25
%26 = load i32**, i32*** %2
%27 = getelementptr inbounds i32*, i32** %26, i64 0
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 1
store i32 0, i32* %29
%30 = load i32**, i32*** %2
%31 = getelementptr inbounds i32*, i32** %30, i64 1
%32 = load i32*, i32** %31
%33 = getelementptr inbounds i32, i32* %32, i64 0
store i32 1, i32* %33
%34 = load i32**, i32*** %2
%35 = getelementptr inbounds i32*, i32** %34, i64 1
%36 = load i32*, i32** %35
%37 = getelementptr inbounds i32, i32* %36, i64 1
store i32 2, i32* %37
%38 = load i32**, i32*** %2
%39 = getelementptr inbounds i32*, i32** %38, i64 2
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 0
store i32 1, i32* %41
%42 = load i32**, i32*** %2
%43 = getelementptr inbounds i32*, i32** %42, i64 2
%44 = load i32*, i32** %43
%45 = getelementptr inbounds i32, i32* %44, i64 1
store i32 3, i32* %45
%46 = load i32**, i32*** %2
%47 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 4, i32** %46, i32 3, i32 2, i32* %3)
%48 = sext i32 %47 to i64
%49 = inttoptr i64 %48 to i32*
store i32* %49, i32** %4
store i32 0, i32* %5
br label %50
50: ; preds = %61, %21
%51 = load i32, i32* %5
%52 = load i32, i32* %3
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %64
54: ; preds = %50
%55 = load i32*, i32** %4
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %54
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %50
64: ; preds = %50
store i32 0, i32* %5
br label %65
65: ; preds = %75, %64
%66 = load i32, i32* %5
%67 = icmp slt i32 %66, 3
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = load i32**, i32*** %2
%70 = load i32, i32* %5
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32*, i32** %69, i64 %71
%73 = load i32*, i32** %72
%74 = bitcast i32* %73 to i8*
br label %75
75: ; preds = %68
%76 = load i32, i32* %5
%77 = add nsw i32 %76, 1
store i32 %77, i32* %5
br label %65
78: ; preds = %65
%79 = load i32**, i32*** %2
%80 = bitcast i32** %79 to i8*
%81 = load i32*, i32** %4
%82 = bitcast i32* %81 to i8*
%83 = call i8* @malloc(i64 40)
%84 = bitcast i8* %83 to i32**
store i32** %84, i32*** %2
store i32 0, i32* %5
br label %85
85: ; preds = %95, %78
%86 = load i32, i32* %5
%87 = icmp slt i32 %86, 5
br i1 %87, label %88, label %98
88: ; preds = %85
%89 = call i8* @malloc(i64 8)
%90 = bitcast i8* %89 to i32*
%91 = load i32**, i32*** %2
%92 = load i32, i32* %5
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32*, i32** %91, i64 %93
store i32* %90, i32** %94
br label %95
95: ; preds = %88
%96 = load i32, i32* %5
%97 = add nsw i32 %96, 1
store i32 %97, i32* %5
br label %85
98: ; preds = %85
%99 = load i32**, i32*** %2
%100 = getelementptr inbounds i32*, i32** %99, i64 0
%101 = load i32*, i32** %100
%102 = getelementptr inbounds i32, i32* %101, i64 0
store i32 0, i32* %102
%103 = load i32**, i32*** %2
%104 = getelementptr inbounds i32*, i32** %103, i64 0
%105 = load i32*, i32** %104
%106 = getelementptr inbounds i32, i32* %105, i64 1
store i32 3, i32* %106
%107 = load i32**, i32*** %2
%108 = getelementptr inbounds i32*, i32** %107, i64 1
%109 = load i32*, i32** %108
%110 = getelementptr inbounds i32, i32* %109, i64 0
store i32 1, i32* %110
%111 = load i32**, i32*** %2
%112 = getelementptr inbounds i32*, i32** %111, i64 1
%113 = load i32*, i32** %112
%114 = getelementptr inbounds i32, i32* %113, i64 1
store i32 3, i32* %114
%115 = load i32**, i32*** %2
%116 = getelementptr inbounds i32*, i32** %115, i64 2
%117 = load i32*, i32** %116
%118 = getelementptr inbounds i32, i32* %117, i64 0
store i32 2, i32* %118
%119 = load i32**, i32*** %2
%120 = getelementptr inbounds i32*, i32** %119, i64 2
%121 = load i32*, i32** %120
%122 = getelementptr inbounds i32, i32* %121, i64 1
store i32 3, i32* %122
%123 = load i32**, i32*** %2
%124 = getelementptr inbounds i32*, i32** %123, i64 3
%125 = load i32*, i32** %124
%126 = getelementptr inbounds i32, i32* %125, i64 0
store i32 4, i32* %126
%127 = load i32**, i32*** %2
%128 = getelementptr inbounds i32*, i32** %127, i64 3
%129 = load i32*, i32** %128
%130 = getelementptr inbounds i32, i32* %129, i64 1
store i32 3, i32* %130
%131 = load i32**, i32*** %2
%132 = getelementptr inbounds i32*, i32** %131, i64 4
%133 = load i32*, i32** %132
%134 = getelementptr inbounds i32, i32* %133, i64 0
store i32 5, i32* %134
%135 = load i32**, i32*** %2
%136 = getelementptr inbounds i32*, i32** %135, i64 4
%137 = load i32*, i32** %136
%138 = getelementptr inbounds i32, i32* %137, i64 1
store i32 4, i32* %138
%139 = load i32**, i32*** %2
%140 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 6, i32** %139, i32 5, i32 2, i32* %3)
%141 = sext i32 %140 to i64
%142 = inttoptr i64 %141 to i32*
store i32* %142, i32** %4
store i32 0, i32* %5
br label %143
143: ; preds = %154, %98
%144 = load i32, i32* %5
%145 = load i32, i32* %3
%146 = icmp slt i32 %144, %145
br i1 %146, label %147, label %157
147: ; preds = %143
%148 = load i32*, i32** %4
%149 = load i32, i32* %5
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i32, i32* %148, i64 %150
%152 = load i32, i32* %151
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %152)
br label %154
154: ; preds = %147
%155 = load i32, i32* %5
%156 = add nsw i32 %155, 1
store i32 %156, i32* %5
br label %143
157: ; preds = %143
store i32 0, i32* %5
br label %158
158: ; preds = %168, %157
%159 = load i32, i32* %5
%160 = icmp slt i32 %159, 5
br i1 %160, label %161, label %171
161: ; preds = %158
%162 = load i32**, i32*** %2
%163 = load i32, i32* %5
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32*, i32** %162, i64 %164
%166 = load i32*, i32** %165
%167 = bitcast i32* %166 to i8*
br label %168
168: ; preds = %161
%169 = load i32, i32* %5
%170 = add nsw i32 %169, 1
store i32 %170, i32* %5
br label %158
171: ; preds = %158
%172 = load i32**, i32*** %2
%173 = bitcast i32** %172 to i8*
%174 = load i32*, i32** %4
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %174)
%176 = load i32*, i32** %4
%177 = bitcast i32* %176 to i8*
%178 = call i8* @malloc(i64 40)
%179 = bitcast i8* %178 to i32**
store i32** %179, i32*** %2
%180 = load i32**, i32*** %2
%181 = call i32 (i32**, ...) bitcast (i32 (...)* @assert to i32 (i32**, ...)*)(i32** %180)
store i32 0, i32* %5
br label %182
182: ; preds = %198, %171
%183 = load i32, i32* %5
%184 = icmp slt i32 %183, 5
br i1 %184, label %185, label %201
185: ; preds = %182
%186 = call i8* @malloc(i64 8)
%187 = bitcast i8* %186 to i32*
%188 = load i32**, i32*** %2
%189 = load i32, i32* %5
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i32*, i32** %188, i64 %190
store i32* %187, i32** %191
%192 = load i32**, i32*** %2
%193 = load i32, i32* %5
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i32*, i32** %192, i64 %194
%196 = load i32*, i32** %195
%197 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %196)
br label %198
198: ; preds = %185
%199 = load i32, i32* %5
%200 = add nsw i32 %199, 1
store i32 %200, i32* %5
br label %182
201: ; preds = %182
%202 = load i32**, i32*** %2
%203 = getelementptr inbounds i32*, i32** %202, i64 0
%204 = load i32*, i32** %203
%205 = getelementptr inbounds i32, i32* %204, i64 0
store i32 3, i32* %205
%206 = load i32**, i32*** %2
%207 = getelementptr inbounds i32*, i32** %206, i64 0
%208 = load i32*, i32** %207
%209 = getelementptr inbounds i32, i32* %208, i64 1
store i32 0, i32* %209
%210 = load i32**, i32*** %2
%211 = getelementptr inbounds i32*, i32** %210, i64 1
%212 = load i32*, i32** %211
%213 = getelementptr inbounds i32, i32* %212, i64 0
store i32 3, i32* %213
%214 = load i32**, i32*** %2
%215 = getelementptr inbounds i32*, i32** %214, i64 1
%216 = load i32*, i32** %215
%217 = getelementptr inbounds i32, i32* %216, i64 1
store i32 1, i32* %217
%218 = load i32**, i32*** %2
%219 = getelementptr inbounds i32*, i32** %218, i64 2
%220 = load i32*, i32** %219
%221 = getelementptr inbounds i32, i32* %220, i64 0
store i32 3, i32* %221
%222 = load i32**, i32*** %2
%223 = getelementptr inbounds i32*, i32** %222, i64 2
%224 = load i32*, i32** %223
%225 = getelementptr inbounds i32, i32* %224, i64 1
store i32 2, i32* %225
%226 = load i32**, i32*** %2
%227 = getelementptr inbounds i32*, i32** %226, i64 3
%228 = load i32*, i32** %227
%229 = getelementptr inbounds i32, i32* %228, i64 0
store i32 3, i32* %229
%230 = load i32**, i32*** %2
%231 = getelementptr inbounds i32*, i32** %230, i64 3
%232 = load i32*, i32** %231
%233 = getelementptr inbounds i32, i32* %232, i64 1
store i32 4, i32* %233
%234 = load i32**, i32*** %2
%235 = getelementptr inbounds i32*, i32** %234, i64 4
%236 = load i32*, i32** %235
%237 = getelementptr inbounds i32, i32* %236, i64 0
store i32 5, i32* %237
%238 = load i32**, i32*** %2
%239 = getelementptr inbounds i32*, i32** %238, i64 4
%240 = load i32*, i32** %239
%241 = getelementptr inbounds i32, i32* %240, i64 1
store i32 4, i32* %241
%242 = load i32**, i32*** %2
%243 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 6, i32** %242, i32 5, i32 2, i32* %3)
%244 = sext i32 %243 to i64
%245 = inttoptr i64 %244 to i32*
store i32* %245, i32** %4
store i32 0, i32* %5
br label %246
246: ; preds = %257, %201
%247 = load i32, i32* %5
%248 = load i32, i32* %3
%249 = icmp slt i32 %247, %248
br i1 %249, label %250, label %260
250: ; preds = %246
%251 = load i32*, i32** %4
%252 = load i32, i32* %5
%253 = sext i32 %252 to i64
%254 = getelementptr inbounds i32, i32* %251, i64 %253
%255 = load i32, i32* %254
%256 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %255)
br label %257
257: ; preds = %250
%258 = load i32, i32* %5
%259 = add nsw i32 %258, 1
store i32 %259, i32* %5
br label %246
260: ; preds = %246
store i32 0, i32* %5
br label %261
261: ; preds = %271, %260
%262 = load i32, i32* %5
%263 = icmp slt i32 %262, 5
br i1 %263, label %264, label %274
264: ; preds = %261
%265 = load i32**, i32*** %2
%266 = load i32, i32* %5
%267 = sext i32 %266 to i64
%268 = getelementptr inbounds i32*, i32** %265, i64 %267
%269 = load i32*, i32** %268
%270 = bitcast i32* %269 to i8*
br label %271
271: ; preds = %264
%272 = load i32, i32* %5
%273 = add nsw i32 %272, 1
store i32 %273, i32* %5
br label %261
274: ; preds = %261
%275 = load i32**, i32*** %2
%276 = bitcast i32** %275 to i8*
%277 = load i32*, i32** %4
%278 = bitcast i32* %277 to i8*
%279 = load i32, i32* %1
ret i32 %279
}

LLVM IR (-O2):
@.str = [8 x i8] c"Ans %d\0A\00"
@.str.1 = [13 x i8] c"Free ans %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%4 = bitcast i8* %3 to i32**
%5 = tail call dereferenceable_or_null(8) i8* @malloc(i64 8)
%6 = bitcast i8* %3 to i8**
store i8* %5, i8** %6
%7 = tail call dereferenceable_or_null(8) i8* @malloc(i64 8)
%8 = getelementptr inbounds i32*, i32** %4, i64 1
%9 = bitcast i32** %8 to i8**
store i8* %7, i8** %9
%10 = tail call dereferenceable_or_null(8) i8* @malloc(i64 8)
%11 = getelementptr inbounds i32*, i32** %4, i64 2
%12 = bitcast i32** %11 to i8**
store i8* %10, i8** %12
%13 = bitcast i8* %5 to i32*
store i32 1, i32* %13
%14 = getelementptr inbounds i32, i32* %13, i64 1
store i32 0, i32* %14
%15 = bitcast i8* %7 to i32*
store i32 1, i32* %15
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 2, i32* %16
%17 = bitcast i8* %10 to i32*
store i32 1, i32* %17
%18 = getelementptr inbounds i32, i32* %17, i64 1
store i32 3, i32* %18
%19 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 4, i32** %4, i32 3, i32 2, i32* %1)
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, 0
br i1 %23, label %60, label %24
24: ; preds = %60, %0
%25 = load i8*, i8** %6
%26 = load i8*, i8** %9
%27 = load i8*, i8** %12
%28 = inttoptr i64 %20 to i8*
%29 = call dereferenceable_or_null(40) i8* @malloc(i64 40)
%30 = bitcast i8* %29 to i32**
%31 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%32 = bitcast i8* %29 to i8**
store i8* %31, i8** %32
%33 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%34 = getelementptr inbounds i32*, i32** %30, i64 1
%35 = bitcast i32** %34 to i8**
store i8* %33, i8** %35
%36 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%37 = getelementptr inbounds i32*, i32** %30, i64 2
%38 = bitcast i32** %37 to i8**
store i8* %36, i8** %38
%39 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%40 = getelementptr inbounds i32*, i32** %30, i64 3
%41 = bitcast i32** %40 to i8**
store i8* %39, i8** %41
%42 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%43 = getelementptr inbounds i32*, i32** %30, i64 4
%44 = bitcast i32** %43 to i8**
store i8* %42, i8** %44
%45 = bitcast i8* %31 to i32*
store i32 0, i32* %45
%46 = getelementptr inbounds i32, i32* %45, i64 1
store i32 3, i32* %46
%47 = bitcast i8* %33 to i32*
store i32 1, i32* %47
%48 = getelementptr inbounds i32, i32* %47, i64 1
store i32 3, i32* %48
%49 = bitcast i8* %36 to i32*
store i32 2, i32* %49
%50 = getelementptr inbounds i32, i32* %49, i64 1
store i32 3, i32* %50
%51 = bitcast i8* %39 to i32*
store i32 4, i32* %51
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32 3, i32* %52
%53 = bitcast i8* %42 to i32*
store i32 5, i32* %53
%54 = getelementptr inbounds i32, i32* %53, i64 1
store i32 4, i32* %54
%55 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 6, i32** %30, i32 5, i32 2, i32* %1)
%56 = sext i32 %55 to i64
%57 = inttoptr i64 %56 to i32*
%58 = load i32, i32* %1
%59 = icmp sgt i32 %58, 0
br i1 %59, label %119, label %69
60: ; preds = %0, %60
%61 = phi i64 [ %65, %60 ], [ 0, %0 ]
%62 = getelementptr inbounds i32, i32* %21, i64 %61
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = add nuw nsw i64 %61, 1
%66 = load i32, i32* %1
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %65, %67
br i1 %68, label %60, label %24
69: ; preds = %119, %24
%70 = load i8*, i8** %32
%71 = load i8*, i8** %35
%72 = load i8*, i8** %38
%73 = load i8*, i8** %41
%74 = load i8*, i8** %44
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %57)
%76 = inttoptr i64 %56 to i8*
%77 = call dereferenceable_or_null(40) i8* @malloc(i64 40)
%78 = bitcast i8* %77 to i32**
%79 = call i32 (i32**, ...) bitcast (i32 (...)* @assert to i32 (i32**, ...)*)(i32** %78)
%80 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%81 = bitcast i8* %80 to i32*
%82 = bitcast i8* %77 to i8**
store i8* %80, i8** %82
%83 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %81)
%84 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%85 = bitcast i8* %84 to i32*
%86 = getelementptr inbounds i32*, i32** %78, i64 1
%87 = bitcast i32** %86 to i8**
store i8* %84, i8** %87
%88 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %85)
%89 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%90 = bitcast i8* %89 to i32*
%91 = getelementptr inbounds i32*, i32** %78, i64 2
%92 = bitcast i32** %91 to i8**
store i8* %89, i8** %92
%93 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %90)
%94 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%95 = bitcast i8* %94 to i32*
%96 = getelementptr inbounds i32*, i32** %78, i64 3
%97 = bitcast i32** %96 to i8**
store i8* %94, i8** %97
%98 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %95)
%99 = call dereferenceable_or_null(8) i8* @malloc(i64 8)
%100 = bitcast i8* %99 to i32*
%101 = getelementptr inbounds i32*, i32** %78, i64 4
%102 = bitcast i32** %101 to i8**
store i8* %99, i8** %102
%103 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %100)
%104 = load i32*, i32** %78
store i32 3, i32* %104
%105 = getelementptr inbounds i32, i32* %104, i64 1
store i32 0, i32* %105
%106 = load i32*, i32** %86
store i32 3, i32* %106
%107 = getelementptr inbounds i32, i32* %106, i64 1
store i32 1, i32* %107
%108 = load i32*, i32** %91
store i32 3, i32* %108
%109 = getelementptr inbounds i32, i32* %108, i64 1
store i32 2, i32* %109
%110 = load i32*, i32** %96
store i32 3, i32* %110
%111 = getelementptr inbounds i32, i32* %110, i64 1
store i32 4, i32* %111
%112 = load i32*, i32** %101
store i32 5, i32* %112
%113 = getelementptr inbounds i32, i32* %112, i64 1
store i32 4, i32* %113
%114 = call i32 (i32, i32**, i32, i32, i32*, ...) bitcast (i32 (...)* @findMinHeightTrees to i32 (i32, i32**, i32, i32, i32*, ...)*)(i32 6, i32** %78, i32 5, i32 2, i32* %1)
%115 = sext i32 %114 to i64
%116 = inttoptr i64 %115 to i32*
%117 = load i32, i32* %1
%118 = icmp sgt i32 %117, 0
br i1 %118, label %135, label %128
119: ; preds = %24, %119
%120 = phi i64 [ %124, %119 ], [ 0, %24 ]
%121 = getelementptr inbounds i32, i32* %57, i64 %120
%122 = load i32, i32* %121
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %122)
%124 = add nuw nsw i64 %120, 1
%125 = load i32, i32* %1
%126 = sext i32 %125 to i64
%127 = icmp slt i64 %124, %126
br i1 %127, label %119, label %69
128: ; preds = %135, %69
%129 = load i8*, i8** %82
%130 = load i8*, i8** %87
%131 = load i8*, i8** %92
%132 = load i8*, i8** %97
%133 = load i8*, i8** %102
%134 = inttoptr i64 %115 to i8*
ret i32 0
135: ; preds = %69, %135
%136 = phi i64 [ %140, %135 ], [ 0, %69 ]
%137 = getelementptr inbounds i32, i32* %116, i64 %136
%138 = load i32, i32* %137
%139 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %138)
%140 = add nuw nsw i64 %136, 1
%141 = load i32, i32* %1
%142 = sext i32 %141 to i64
%143 = icmp slt i64 %140, %142
br i1 %143, label %135, label %128
}