int PersonTreeCompare(P1, P2)
struct Person **P1;
struct Person **P2;
{
  if (((AccessPersonMsc(P1) & 3) == 0) || ((AccessPersonMsc(P2) & 3) == 0)) {
    if ((AccessPersonMsc(P1) & 3) != 0)
      return (-1);
    if ((AccessPersonMsc(P2) & 3) != 0)
      return (1);
    if (P1 < P2)
      return (-1);
    if (P1 > P2)
      return (1);
    return (0);
  } else {
    if (((AccessStudentMsc(P1) & 1) == 0) ||
        ((AccessStudentMsc(P2) & 1) == 0)) {
      if ((AccessStudentMsc(P1) & 1) != 0)
        return (-1);
      if ((AccessStudentMsc(P2) & 1) != 0)
        return (1);
      if (P1 < P2)
        return (-1);
      if (P1 > P2)
        return (1);
      return (0);
    } else {
      if (AccessGradStudentSupervisor(P1) < AccessGradStudentSupervisor(P2))
        return (-1);
      if (AccessGradStudentSupervisor(P1) > AccessGradStudentSupervisor(P2))
        return (1);
      if (P1 < P2)
        return (-1);
      if (P1 > P2)
        return (1);
      return (0);
    }
  }
}


x86 assembly (clang, -O0):
<PersonTreeCompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <AccessPersonMsc@plt>
and    $0x3,%eax
cmp    $0x0,%eax
je     116e <PersonTreeCompare+0x3e>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1040 <AccessPersonMsc@plt>
and    $0x3,%eax
cmp    $0x0,%eax
jne    11f4 <PersonTreeCompare+0xc4>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <AccessPersonMsc@plt>
and    $0x3,%eax
cmp    $0x0,%eax
je     1191 <PersonTreeCompare+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1040 <AccessPersonMsc@plt>
and    $0x3,%eax
cmp    $0x0,%eax
je     11b4 <PersonTreeCompare+0x84>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ce <PersonTreeCompare+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11e8 <PersonTreeCompare+0xb8>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
movl   $0x0,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessStudentMsc@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     1222 <PersonTreeCompare+0xf2>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessStudentMsc@plt>
and    $0x1,%eax
cmp    $0x0,%eax
jne    12a8 <PersonTreeCompare+0x178>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessStudentMsc@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     1245 <PersonTreeCompare+0x115>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessStudentMsc@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     1268 <PersonTreeCompare+0x138>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1282 <PersonTreeCompare+0x152>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    129c <PersonTreeCompare+0x16c>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
movl   $0x0,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    12da <PersonTreeCompare+0x1aa>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jle    130c <PersonTreeCompare+0x1dc>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1326 <PersonTreeCompare+0x1f6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1340 <PersonTreeCompare+0x210>
movl   $0x1,-0x4(%rbp)
jmp    1347 <PersonTreeCompare+0x217>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PersonTreeCompare>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <AccessPersonMsc@plt>
test   $0x3,%al
je     11a4 <PersonTreeCompare+0x74>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <AccessPersonMsc@plt>
test   $0x3,%al
je     11a4 <PersonTreeCompare+0x74>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <AccessStudentMsc@plt>
test   $0x1,%al
je     116f <PersonTreeCompare+0x3f>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <AccessStudentMsc@plt>
test   $0x1,%al
jne    11d2 <PersonTreeCompare+0xa2>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <AccessStudentMsc@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   $0x1,%cl
jne    1224 <PersonTreeCompare+0xf4>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <AccessStudentMsc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   $0x1,%cl
je     1214 <PersonTreeCompare+0xe4>
jmp    1224 <PersonTreeCompare+0xf4>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <AccessPersonMsc@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   $0x3,%cl
jne    1224 <PersonTreeCompare+0xf4>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <AccessPersonMsc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   $0x3,%cl
jne    1224 <PersonTreeCompare+0xf4>
jmp    1214 <PersonTreeCompare+0xe4>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%ebp
jl     1224 <PersonTreeCompare+0xf4>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <AccessGradStudentSupervisor@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%ebp
jg     1224 <PersonTreeCompare+0xf4>
mov    $0xffffffff,%eax
cmp    %r14,%rbx
jb     1224 <PersonTreeCompare+0xf4>
seta   %al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.Person = type opaque
define i32 @PersonTreeCompare(%struct.Person** %0, %struct.Person** %1) {
%3 = alloca i32
%4 = alloca %struct.Person**
%5 = alloca %struct.Person**
store %struct.Person** %0, %struct.Person*** %4
store %struct.Person** %1, %struct.Person*** %5
%6 = load %struct.Person**, %struct.Person*** %4
%7 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %6)
%8 = and i32 %7, 3
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load %struct.Person**, %struct.Person*** %5
%12 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %11)
%13 = and i32 %12, 3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %10, %2
%16 = load %struct.Person**, %struct.Person*** %4
%17 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %16)
%18 = and i32 %17, 3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %3
br label %96
21: ; preds = %15
%22 = load %struct.Person**, %struct.Person*** %5
%23 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %22)
%24 = and i32 %23, 3
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %3
br label %96
27: ; preds = %21
%28 = load %struct.Person**, %struct.Person*** %4
%29 = load %struct.Person**, %struct.Person*** %5
%30 = icmp ult %struct.Person** %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %3
br label %96
32: ; preds = %27
%33 = load %struct.Person**, %struct.Person*** %4
%34 = load %struct.Person**, %struct.Person*** %5
%35 = icmp ugt %struct.Person** %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %3
br label %96
37: ; preds = %32
store i32 0, i32* %3
br label %96
38: ; preds = %10
%39 = load %struct.Person**, %struct.Person*** %4
%40 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %39)
%41 = and i32 %40, 1
%42 = icmp eq i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = load %struct.Person**, %struct.Person*** %5
%45 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %44)
%46 = and i32 %45, 1
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %71
48: ; preds = %43, %38
%49 = load %struct.Person**, %struct.Person*** %4
%50 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %49)
%51 = and i32 %50, 1
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %48
store i32 -1, i32* %3
br label %96
54: ; preds = %48
%55 = load %struct.Person**, %struct.Person*** %5
%56 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %55)
%57 = and i32 %56, 1
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %54
store i32 1, i32* %3
br label %96
60: ; preds = %54
%61 = load %struct.Person**, %struct.Person*** %4
%62 = load %struct.Person**, %struct.Person*** %5
%63 = icmp ult %struct.Person** %61, %62
br i1 %63, label %64, label %65
64: ; preds = %60
store i32 -1, i32* %3
br label %96
65: ; preds = %60
%66 = load %struct.Person**, %struct.Person*** %4
%67 = load %struct.Person**, %struct.Person*** %5
%68 = icmp ugt %struct.Person** %66, %67
br i1 %68, label %69, label %70
69: ; preds = %65
store i32 1, i32* %3
br label %96
70: ; preds = %65
store i32 0, i32* %3
br label %96
71: ; preds = %43
%72 = load %struct.Person**, %struct.Person*** %4
%73 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %72)
%74 = load %struct.Person**, %struct.Person*** %5
%75 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %74)
%76 = icmp slt i32 %73, %75
br i1 %76, label %77, label %78
77: ; preds = %71
store i32 -1, i32* %3
br label %96
78: ; preds = %71
%79 = load %struct.Person**, %struct.Person*** %4
%80 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %79)
%81 = load %struct.Person**, %struct.Person*** %5
%82 = call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %81)
%83 = icmp sgt i32 %80, %82
br i1 %83, label %84, label %85
84: ; preds = %78
store i32 1, i32* %3
br label %96
85: ; preds = %78
%86 = load %struct.Person**, %struct.Person*** %4
%87 = load %struct.Person**, %struct.Person*** %5
%88 = icmp ult %struct.Person** %86, %87
br i1 %88, label %89, label %90
89: ; preds = %85
store i32 -1, i32* %3
br label %96
90: ; preds = %85
%91 = load %struct.Person**, %struct.Person*** %4
%92 = load %struct.Person**, %struct.Person*** %5
%93 = icmp ugt %struct.Person** %91, %92
br i1 %93, label %94, label %95
94: ; preds = %90
store i32 1, i32* %3
br label %96
95: ; preds = %90
store i32 0, i32* %3
br label %96
96: ; preds = %95, %94, %89, %84, %77, %70, %69, %64, %59, %53, %37, %36, %31, %26, %20
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
%struct.Person = type opaque
define i32 @PersonTreeCompare(%struct.Person** %0, %struct.Person** %1) {
%3 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%4 = and i32 %3, 3
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%8 = and i32 %7, 3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %6, %2
%11 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%12 = and i32 %11, 3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %57
14: ; preds = %10
%15 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessPersonMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%16 = and i32 %15, 3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %57
18: ; preds = %14
%19 = icmp ult %struct.Person** %0, %1
br i1 %19, label %57, label %20
20: ; preds = %18
%21 = icmp ugt %struct.Person** %0, %1
%22 = zext i1 %21 to i32
br label %57
23: ; preds = %6
%24 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%25 = and i32 %24, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%29 = and i32 %28, 1
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %27, %23
%32 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%33 = and i32 %32, 1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %57
35: ; preds = %31
%36 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessStudentMsc to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%37 = and i32 %36, 1
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %57
39: ; preds = %35
%40 = icmp ult %struct.Person** %0, %1
br i1 %40, label %57, label %41
41: ; preds = %39
%42 = icmp ugt %struct.Person** %0, %1
%43 = zext i1 %42 to i32
br label %57
44: ; preds = %27
%45 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%46 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%47 = icmp slt i32 %45, %46
br i1 %47, label %57, label %48
48: ; preds = %44
%49 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %0)
%50 = tail call i32 (%struct.Person**, ...) bitcast (i32 (...)* @AccessGradStudentSupervisor to i32 (%struct.Person**, ...)*)(%struct.Person** %1)
%51 = icmp sgt i32 %49, %50
br i1 %51, label %57, label %52
52: ; preds = %48
%53 = icmp ult %struct.Person** %0, %1
br i1 %53, label %57, label %54
54: ; preds = %52
%55 = icmp ugt %struct.Person** %0, %1
%56 = zext i1 %55 to i32
br label %57
57: ; preds = %54, %52, %48, %44, %41, %39, %35, %31, %20, %18, %14, %10
%58 = phi i32 [ -1, %10 ], [ 1, %14 ], [ -1, %18 ], [ %22, %20 ], [ -1, %31 ], [ 1, %35 ], [ -1, %39 ], [ %43, %41 ], [ -1, %44 ], [ 1, %48 ], [ -1, %52 ], [ %56, %54 ]
ret i32 %58
}