#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 tree_node {
  int dummy;
};
typedef int /*<<< orphan*/ numbers2;
typedef int /*<<< orphan*/ numbers1;

/* Variables and functions */
int /*<<< orphan*/ destroy_binary_tree(struct tree_node **);
struct tree_node *generate_binary_tree(int *, int);
int is_same_tree(struct tree_node *, struct tree_node *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  struct tree_node *p;
  struct tree_node *q;
  int size1;
  int size2;
  int i;
  bool is_same = false;
  int numbers1[] = {5, 8, 1, 9, 7, 2, 3};
  int numbers2[] = {5, 8, 1, 9, 7, 2};
  size1 = sizeof(numbers1) / sizeof(numbers1[0]);
  size2 = sizeof(numbers2) / sizeof(numbers2[0]);
  printf("p:\n");
  for (i = 0; i < size1; ++i)
    printf("%d ", numbers1[i]);
  printf("\n");
  printf("q:\n");
  for (i = 0; i < size2; ++i)
    printf("%d ", numbers2[i]);
  printf("\n");
  p = generate_binary_tree(numbers1, size1);
  q = generate_binary_tree(numbers2, size2);
  is_same = is_same_tree(p, q);
  printf("\nresult:\n");
  if (is_same)
    printf("p & q is the same tree.\n");
  else
    printf("p & q is not the same tree.\n");
  destroy_binary_tree(&p);
  destroy_binary_tree(&q);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x38(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x7,-0x1c(%rbp)
movl   $0x6,-0x20(%rbp)
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f4 <main+0xb4>
movslq -0x24(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c4 <main+0x84>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1247 <main+0x107>
movslq -0x24(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1217 <main+0xd7>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <generate_binary_tree@plt>
mov    %rax,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1060 <generate_binary_tree@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <is_same_tree@plt>
mov    %eax,-0x28(%rbp)
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
je     12b0 <main+0x170>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12be <main+0x17e>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1050 <destroy_binary_tree@plt>
lea    -0x18(%rbp),%rdi
call   1050 <destroy_binary_tree@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movups 0xea0(%rip),%xmm0
movups %xmm0,0x3c(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xeac(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe90(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe90(%rip),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x30(%rsp),%rdi
mov    $0x7,%esi
call   1080 <generate_binary_tree@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x6,%esi
call   1080 <generate_binary_tree@plt>
mov    %rax,(%rsp)
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <is_same_tree@plt>
mov    %eax,%ebx
lea    0xd79(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
lea    0xd74(%rip),%rax
lea    0xd89(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1070 <destroy_binary_tree@plt>
mov    %rsp,%rdi
call   1070 <destroy_binary_tree@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tree_node = type { i32 }
@__const.main.numbers1 = [7 x i32] [i32 5, i32 8, i32 1, i32 9, i32 7, i32 2, i32 3]
@__const.main.numbers2 = [6 x i32] [i32 5, i32 8, i32 1, i32 9, i32 7, i32 2]
@.str = [4 x i8] c"p:\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"q:\0A\00"
@.str.4 = [10 x i8] c"\0Aresult:\0A\00"
@.str.5 = [25 x i8] c"p & q is the same tree.\0A\00"
@.str.6 = [29 x i8] c"p & q is not the same tree.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tree_node*
%3 = alloca %struct.tree_node*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [7 x i32]
%9 = alloca [6 x i32]
store i32 0, i32* %1
store i32 0, i32* %7
%10 = bitcast [7 x i32]* %8 to i8*
%11 = bitcast [6 x i32]* %9 to i8*
store i32 7, i32* %4
store i32 6, i32* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %8, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %13
26: ; preds = %13
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %29
29: ; preds = %39, %26
%30 = load i32, i32* %6
%31 = load i32, i32* %5
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %29
42: ; preds = %29
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = getelementptr inbounds [7 x i32], [7 x i32]* %8, i64 0, i64 0
%45 = load i32, i32* %4
%46 = call %struct.tree_node* @generate_binary_tree(i32* %44, i32 %45)
store %struct.tree_node* %46, %struct.tree_node** %2
%47 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%48 = load i32, i32* %5
%49 = call %struct.tree_node* @generate_binary_tree(i32* %47, i32 %48)
store %struct.tree_node* %49, %struct.tree_node** %3
%50 = load %struct.tree_node*, %struct.tree_node** %2
%51 = load %struct.tree_node*, %struct.tree_node** %3
%52 = call i32 @is_same_tree(%struct.tree_node* %50, %struct.tree_node* %51)
store i32 %52, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%54 = load i32, i32* %7
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %42
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %60
58: ; preds = %42
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
%61 = call i32 @destroy_binary_tree(%struct.tree_node** %2)
%62 = call i32 @destroy_binary_tree(%struct.tree_node** %3)
ret i32 0
}

LLVM IR (-O2):
%struct.tree_node = type { i32 }
@__const.main.numbers1 = [7 x i32] [i32 5, i32 8, i32 1, i32 9, i32 7, i32 2, i32 3]
@__const.main.numbers2 = [6 x i32] [i32 5, i32 8, i32 1, i32 9, i32 7, i32 2]
@.str.1 = [4 x i8] c"%d \00"
@str = [3 x i8] c"p:\00"
@str.7 = [3 x i8] c"q:\00"
@str.8 = [9 x i8] c"\0Aresult:\00"
@str.9 = [28 x i8] c"p & q is not the same tree.\00"
@str.10 = [24 x i8] c"p & q is the same tree.\00"
define i32 @main() {
%1 = alloca %struct.tree_node*
%2 = alloca %struct.tree_node*
%3 = alloca [7 x i32]
%4 = alloca [6 x i32]
%5 = bitcast %struct.tree_node** %1 to i8*
%6 = bitcast %struct.tree_node** %2 to i8*
%7 = bitcast [7 x i32]* %3 to i8*
%8 = bitcast [6 x i32]* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 5)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 8)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 9)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 7)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.7, i64 0, i64 0))
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 5)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 8)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 9)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 7)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2)
%27 = tail call i32 @putchar(i32 10)
%28 = call %struct.tree_node* @generate_binary_tree(i32* %10, i32 7)
store %struct.tree_node* %28, %struct.tree_node** %1
%29 = call %struct.tree_node* @generate_binary_tree(i32* %20, i32 6)
store %struct.tree_node* %29, %struct.tree_node** %2
%30 = call i32 @is_same_tree(%struct.tree_node* %28, %struct.tree_node* %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
%32 = icmp eq i32 %30, 0
%33 = select i1 %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0)
%34 = call i32 @puts(i8* dereferenceable(1) %33)
%35 = call i32 @destroy_binary_tree(%struct.tree_node** %1)
%36 = call i32 @destroy_binary_tree(%struct.tree_node** %2)
ret i32 0
}