#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 BSTreeNode {
  int dummy;
};

/* Variables and functions */
struct BSTreeNode *BSTreeNodeInit(int);
int /*<<< orphan*/ PrintTree(struct BSTreeNode *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reverse_bstree(struct BSTreeNode *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int tree;
  struct BSTreeNode *node;
  printf("Please input number:");
  scanf("%d", &tree);
  node = BSTreeNodeInit(tree);
  PrintTree(node);
  printf("\n");
  reverse_bstree(node);
  PrintTree(node);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <BSTreeNodeInit@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <PrintTree@plt>
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <reverse_bstree@plt>
mov    -0x10(%rbp),%rdi
call   1030 <PrintTree@plt>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
call   1070 <BSTreeNodeInit@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <PrintTree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <reverse_bstree@plt>
mov    %rbx,%rdi
call   1040 <PrintTree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.BSTreeNode = type { i32 }
@.str = [21 x i8] c"Please input number:\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call %struct.BSTreeNode* @BSTreeNodeInit(i32 %5)
%7 = call i32 @PrintTree(%struct.BSTreeNode* %6)
%8 = call i32 @putchar(i32 10)
%9 = call i32 @reverse_bstree(%struct.BSTreeNode* %6)
%10 = call i32 @PrintTree(%struct.BSTreeNode* %6)
%11 = call i32 @putchar(i32 10)
ret i32 0
}