#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;
};
typedef int /*<<< orphan*/ postorder;
typedef int /*<<< orphan*/ inorder;

/* Variables and functions */
struct TreeNode *buildTree(int *, int, int *, int);
int /*<<< orphan*/ dump(struct TreeNode *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int postorder[] = {3, 2, 1};
  int inorder[] = {1, 2, 3};
  int post_size = sizeof(postorder) / sizeof(*postorder);
  int in_size = sizeof(inorder) / sizeof(*inorder);
  struct TreeNode *root = buildTree(inorder, in_size, postorder, post_size);
  dump(root);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xeb0(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x3,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1050 <buildTree@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <dump@plt>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0xece(%rip),%eax
mov    %eax,0x20(%rsp)
mov    0xebb(%rip),%rax
mov    %rax,0x18(%rsp)
mov    0xec4(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xeb1(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rdx
mov    $0x3,%esi
mov    $0x3,%ecx
call   1050 <buildTree@plt>
mov    %rax,%rdi
call   1040 <dump@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.TreeNode = type { i32 }
@__const.main.postorder = [3 x i32] [i32 3, i32 2, i32 1]
@__const.main.inorder = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [3 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.TreeNode*
store i32 0, i32* %1
%7 = bitcast [3 x i32]* %2 to i8*
%8 = bitcast [3 x i32]* %3 to i8*
store i32 3, i32* %4
store i32 3, i32* %5
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%10 = load i32, i32* %5
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %4
%13 = call %struct.TreeNode* @buildTree(i32* %9, i32 %10, i32* %11, i32 %12)
store %struct.TreeNode* %13, %struct.TreeNode** %6
%14 = load %struct.TreeNode*, %struct.TreeNode** %6
%15 = call i32 @dump(%struct.TreeNode* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.TreeNode = type { i32 }
@__const.main.postorder = [3 x i32] [i32 3, i32 2, i32 1]
@__const.main.inorder = [3 x i32] [i32 1, i32 2, i32 3]
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%7 = call %struct.TreeNode* @buildTree(i32* %5, i32 3, i32* %6, i32 3)
%8 = call i32 @dump(%struct.TreeNode* %7)
%9 = call i32 @putchar(i32 10)
ret i32 0
}