#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 /*<<< orphan*/ reverse(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ store_back_inorder(struct treenode *, char *, int *,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ store_inorder(struct treenode *, char *, int *,
                                 int /*<<< orphan*/);
void reverse_alternate(struct treenode *root) {
  char a[100];
  int index = 0;
  store_inorder(root, a, &index, 0);
  reverse(a, 0, index - 1);
  index = 0;
  store_back_inorder(root, a, &index, 0);
}


x86 assembly (clang, -O0):
<reverse_alternate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x74(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <store_inorder@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <reverse@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x74(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <store_back_inorder@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_alternate>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%r15
mov    %r14,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1050 <store_inorder@plt>
mov    0xc(%rsp),%edx
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
movl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1040 <store_back_inorder@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.treenode = type { i32 }
define void @reverse_alternate(%struct.treenode* %0) {
%2 = alloca %struct.treenode*
%3 = alloca [100 x i8]
%4 = alloca i32
store %struct.treenode* %0, %struct.treenode** %2
store i32 0, i32* %4
%5 = load %struct.treenode*, %struct.treenode** %2
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 @store_inorder(%struct.treenode* %5, i8* %6, i32* %4, i32 0)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = call i32 @reverse(i8* %8, i32 0, i32 %10)
store i32 0, i32* %4
%12 = load %struct.treenode*, %struct.treenode** %2
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @store_back_inorder(%struct.treenode* %12, i8* %13, i32* %4, i32 0)
ret void
}

LLVM IR (-O2):
%struct.treenode = type { i32 }
define void @reverse_alternate(%struct.treenode* %0) {
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 @store_inorder(%struct.treenode* %0, i8* %4, i32* %3, i32 0)
%7 = load i32, i32* %3
%8 = add nsw i32 %7, -1
%9 = call i32 @reverse(i8* %4, i32 0, i32 %8)
store i32 0, i32* %3
%10 = call i32 @store_back_inorder(%struct.treenode* %0, i8* %4, i32* %3, i32 0)
ret void
}