#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 */

/* Variables and functions */
int compare_tree_entry(void *, unsigned long, void *, unsigned long,
                       char const *);
int /*<<< orphan*/ show_file(char *, void *, unsigned long, char const *);
int /*<<< orphan*/ update_tree_entry(void **, unsigned long *);
int /*<<< orphan*/ usage(char *);
int diff_tree(void *tree1, unsigned long size1, void *tree2,
              unsigned long size2, const char *base) {
  while (size1 | size2) {
    if (!size1) {
      show_file("+", tree2, size2, base);
      update_tree_entry(&tree2, &size2);
      continue;
    }
    if (!size2) {
      show_file("-", tree1, size1, base);
      update_tree_entry(&tree1, &size1);
      continue;
    }
    switch (compare_tree_entry(tree1, size1, tree2, size2, base)) {
    case -1:
      update_tree_entry(&tree1, &size1);
      continue;
    case 0:
      update_tree_entry(&tree1, &size1);
    case 1:
      update_tree_entry(&tree2, &size2);
      continue;
    }
    usage("diff-tree: internal error");
  }
  return 0;
}


x86 assembly (clang, -O0):
<diff_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
or     -0x20(%rbp),%rax
cmp    $0x0,%rax
je     1267 <diff_tree+0x127>
cmpq   $0x0,-0x10(%rbp)
jne    11a3 <diff_tree+0x63>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe74(%rip),%rdi
call   1030 <show_file@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <update_tree_entry@plt>
jmp    115c <diff_tree+0x1c>
cmpq   $0x0,-0x20(%rbp)
jne    11d8 <diff_tree+0x98>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe41(%rip),%rdi
call   1030 <show_file@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <update_tree_entry@plt>
jmp    115c <diff_tree+0x1c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <compare_tree_entry@plt>
mov    %eax,%ecx
mov    %ecx,-0x2c(%rbp)
sub    $0xffffffff,%eax
je     1225 <diff_tree+0xe5>
jmp    1204 <diff_tree+0xc4>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
je     1237 <diff_tree+0xf7>
jmp    1214 <diff_tree+0xd4>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
je     1244 <diff_tree+0x104>
jmp    1256 <diff_tree+0x116>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <update_tree_entry@plt>
jmp    115c <diff_tree+0x1c>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <update_tree_entry@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <update_tree_entry@plt>
jmp    115c <diff_tree+0x1c>
lea    0xda7(%rip),%rdi
call   1060 <usage@plt>
jmp    115c <diff_tree+0x1c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff_tree>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rsi,%rdx
or     %rcx,%rdx
je     123a <diff_tree+0xfa>
mov    %r8,%rbx
mov    %rsi,%rax
lea    0xe85(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x20(%rsp),%rbp
lea    0x18(%rsp),%r13
jmp    11d0 <diff_tree+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    %rcx,%rdx
mov    %rbx,%rcx
call   1030 <show_file@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <update_tree_entry@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
je     123a <diff_tree+0xfa>
test   %rax,%rax
je     11a0 <diff_tree+0x60>
mov    0x20(%rsp),%rsi
test   %rcx,%rcx
je     1210 <diff_tree+0xd0>
mov    0x8(%rsp),%rdx
mov    %rsi,%rdi
mov    %rax,%rsi
mov    %rbx,%r8
call   1040 <compare_tree_entry@plt>
cmp    $0x1,%eax
je     11b3 <diff_tree+0x73>
test   %eax,%eax
je     122a <diff_tree+0xea>
cmp    $0xffffffff,%eax
je     1222 <diff_tree+0xe2>
lea    0xdfd(%rip),%rdi
call   1060 <usage@plt>
jmp    11be <diff_tree+0x7e>
xchg   %ax,%ax
lea    0xdeb(%rip),%rdi
mov    %rax,%rdx
mov    %rbx,%rcx
call   1030 <show_file@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
jmp    11b9 <diff_tree+0x79>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <update_tree_entry@plt>
jmp    11b3 <diff_tree+0x73>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [26 x i8] c"diff-tree: internal error\00"
define i32 @diff_tree(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
br label %11
11: ; preds = %47, %45, %41, %28, %19, %5
%12 = load i64, i64* %7
%13 = load i64, i64* %9
%14 = or i64 %12, %13
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %49
16: ; preds = %11
%17 = load i64, i64* %7
%18 = icmp ne i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = load i8*, i8** %8
%21 = load i64, i64* %9
%22 = load i8*, i8** %10
%23 = call i32 @show_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %20, i64 %21, i8* %22)
%24 = call i32 @update_tree_entry(i8** %8, i64* %9)
br label %11
25: ; preds = %16
%26 = load i64, i64* %9
%27 = icmp ne i64 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i8*, i8** %6
%30 = load i64, i64* %7
%31 = load i8*, i8** %10
%32 = call i32 @show_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %29, i64 %30, i8* %31)
%33 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %11
34: ; preds = %25
%35 = load i8*, i8** %6
%36 = load i64, i64* %7
%37 = load i8*, i8** %8
%38 = load i64, i64* %9
%39 = load i8*, i8** %10
%40 = call i32 @compare_tree_entry(i8* %35, i64 %36, i8* %37, i64 %38, i8* %39)
switch i32 %40, label %47 [
i32 -1, label %41
i32 0, label %43
i32 1, label %45
]
41: ; preds = %34
%42 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %11
43: ; preds = %34
%44 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %45
45: ; preds = %34, %43
%46 = call i32 @update_tree_entry(i8** %8, i64* %9)
br label %11
47: ; preds = %34
%48 = call i32 @usage(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %11
49: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [26 x i8] c"diff-tree: internal error\00"
define i32 @diff_tree(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%10 = or i64 %1, %3
%11 = icmp eq i64 %10, 0
br i1 %11, label %42, label %17
12: ; preds = %21, %28, %34, %38, %40
%13 = load i64, i64* %7
%14 = load i64, i64* %9
%15 = or i64 %13, %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %42, label %17
17: ; preds = %5, %12
%18 = phi i64 [ %13, %12 ], [ %1, %5 ]
%19 = phi i64 [ %14, %12 ], [ %3, %5 ]
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** %8
%23 = call i32 @show_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %22, i64 %19, i8* %4)
%24 = call i32 @update_tree_entry(i8** %8, i64* %9)
br label %12
25: ; preds = %17
%26 = icmp eq i64 %19, 0
%27 = load i8*, i8** %6
br i1 %26, label %28, label %31
28: ; preds = %25
%29 = call i32 @show_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %27, i64 %18, i8* %4)
%30 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %12
31: ; preds = %25
%32 = load i8*, i8** %8
%33 = call i32 @compare_tree_entry(i8* %27, i64 %18, i8* %32, i64 %19, i8* %4)
switch i32 %33, label %40 [
i32 -1, label %34
i32 0, label %36
i32 1, label %38
]
34: ; preds = %31
%35 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %12
36: ; preds = %31
%37 = call i32 @update_tree_entry(i8** %6, i64* %7)
br label %38
38: ; preds = %31, %36
%39 = call i32 @update_tree_entry(i8** %8, i64* %9)
br label %12
40: ; preds = %31
%41 = call i32 @usage(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %12
42: ; preds = %12, %5
ret i32 0
}