#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 */
int diameterOfBinaryTree(int /*<<< orphan*/ *);
struct TreeNode *newNode(int, struct TreeNode *, struct TreeNode *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  struct TreeNode *n15 = newNode(15, NULL, NULL);
  struct TreeNode *n7 = newNode(7, NULL, NULL);
  struct TreeNode *n20 = newNode(20, NULL, NULL);
  struct TreeNode *n9 = newNode(9, NULL, NULL);
  struct TreeNode *n3 = newNode(3, n9, n20);
  printf("%d\n", diameterOfBinaryTree(NULL));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0xf,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <newNode@plt>
mov    %rax,-0x8(%rbp)
mov    $0x7,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <newNode@plt>
mov    %rax,-0x10(%rbp)
mov    $0x14,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <newNode@plt>
mov    %rax,-0x18(%rbp)
mov    $0x9,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <newNode@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x3,%edi
call   1050 <newNode@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <diameterOfBinaryTree@plt>
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xf,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <newNode@plt>
mov    $0x7,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <newNode@plt>
mov    $0x14,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <newNode@plt>
mov    %rax,%rbx
mov    $0x9,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <newNode@plt>
mov    $0x3,%edi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1050 <newNode@plt>
xor    %edi,%edi
call   1030 <diameterOfBinaryTree@plt>
lea    0xe76(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.TreeNode = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call %struct.TreeNode* @newNode(i32 15, %struct.TreeNode* null, %struct.TreeNode* null)
%2 = tail call %struct.TreeNode* @newNode(i32 7, %struct.TreeNode* null, %struct.TreeNode* null)
%3 = tail call %struct.TreeNode* @newNode(i32 20, %struct.TreeNode* null, %struct.TreeNode* null)
%4 = tail call %struct.TreeNode* @newNode(i32 9, %struct.TreeNode* null, %struct.TreeNode* null)
%5 = tail call %struct.TreeNode* @newNode(i32 3, %struct.TreeNode* %4, %struct.TreeNode* %3)
%6 = tail call i32 @diameterOfBinaryTree(i32* null)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
ret i32 0
}