int TeacherTreeCompare(P1, P2)
struct Teacher **P1;
struct Teacher **P2;
{
  if (((AccessTeacherMsc(P1) & 4) == 0) || ((AccessTeacherMsc(P2) & 4) == 0)) {
    if ((AccessTeacherMsc(P1) & 4) != 0)
      return (-1);
    if ((AccessTeacherMsc(P2) & 4) != 0)
      return (1);
    if (P1 < P2)
      return (-1);
    if (P1 > P2)
      return (1);
    return (0);
  } else {
    if (P1 < P2)
      return (-1);
    if (P1 > P2)
      return (1);
    return (0);
  }
}


x86 assembly (clang, -O0):
<TeacherTreeCompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessTeacherMsc@plt>
and    $0x4,%eax
cmp    $0x0,%eax
je     114e <TeacherTreeCompare+0x3e>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessTeacherMsc@plt>
and    $0x4,%eax
cmp    $0x0,%eax
jne    11d4 <TeacherTreeCompare+0xc4>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessTeacherMsc@plt>
and    $0x4,%eax
cmp    $0x0,%eax
je     1171 <TeacherTreeCompare+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <AccessTeacherMsc@plt>
and    $0x4,%eax
cmp    $0x0,%eax
je     1194 <TeacherTreeCompare+0x84>
movl   $0x1,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ae <TeacherTreeCompare+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11c8 <TeacherTreeCompare+0xb8>
movl   $0x1,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
movl   $0x0,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ee <TeacherTreeCompare+0xde>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1208 <TeacherTreeCompare+0xf8>
movl   $0x1,-0x4(%rbp)
jmp    120f <TeacherTreeCompare+0xff>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TeacherTreeCompare>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <AccessTeacherMsc@plt>
test   $0x4,%al
je     1133 <TeacherTreeCompare+0x23>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <AccessTeacherMsc@plt>
test   $0x4,%al
jne    115f <TeacherTreeCompare+0x4f>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <AccessTeacherMsc@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   $0x4,%cl
jne    116f <TeacherTreeCompare+0x5f>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <AccessTeacherMsc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   $0x4,%cl
jne    116f <TeacherTreeCompare+0x5f>
mov    $0xffffffff,%eax
cmp    %r14,%rbx
jb     116f <TeacherTreeCompare+0x5f>
seta   %al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Teacher = type opaque
define i32 @TeacherTreeCompare(%struct.Teacher** %0, %struct.Teacher** %1) {
%3 = alloca i32
%4 = alloca %struct.Teacher**
%5 = alloca %struct.Teacher**
store %struct.Teacher** %0, %struct.Teacher*** %4
store %struct.Teacher** %1, %struct.Teacher*** %5
%6 = load %struct.Teacher**, %struct.Teacher*** %4
%7 = call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %6)
%8 = and i32 %7, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load %struct.Teacher**, %struct.Teacher*** %5
%12 = call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %11)
%13 = and i32 %12, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %10, %2
%16 = load %struct.Teacher**, %struct.Teacher*** %4
%17 = call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %16)
%18 = and i32 %17, 4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %3
br label %49
21: ; preds = %15
%22 = load %struct.Teacher**, %struct.Teacher*** %5
%23 = call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %22)
%24 = and i32 %23, 4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %3
br label %49
27: ; preds = %21
%28 = load %struct.Teacher**, %struct.Teacher*** %4
%29 = load %struct.Teacher**, %struct.Teacher*** %5
%30 = icmp ult %struct.Teacher** %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %3
br label %49
32: ; preds = %27
%33 = load %struct.Teacher**, %struct.Teacher*** %4
%34 = load %struct.Teacher**, %struct.Teacher*** %5
%35 = icmp ugt %struct.Teacher** %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %3
br label %49
37: ; preds = %32
store i32 0, i32* %3
br label %49
38: ; preds = %10
%39 = load %struct.Teacher**, %struct.Teacher*** %4
%40 = load %struct.Teacher**, %struct.Teacher*** %5
%41 = icmp ult %struct.Teacher** %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 -1, i32* %3
br label %49
43: ; preds = %38
%44 = load %struct.Teacher**, %struct.Teacher*** %4
%45 = load %struct.Teacher**, %struct.Teacher*** %5
%46 = icmp ugt %struct.Teacher** %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 1, i32* %3
br label %49
48: ; preds = %43
store i32 0, i32* %3
br label %49
49: ; preds = %48, %47, %42, %37, %36, %31, %26, %20
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.Teacher = type opaque
define i32 @TeacherTreeCompare(%struct.Teacher** %0, %struct.Teacher** %1) {
%3 = tail call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %0)
%4 = and i32 %3, 4
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %1)
%8 = and i32 %7, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %6, %2
%11 = tail call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %0)
%12 = and i32 %11, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = tail call i32 (%struct.Teacher**, ...) bitcast (i32 (...)* @AccessTeacherMsc to i32 (%struct.Teacher**, ...)*)(%struct.Teacher** %1)
%16 = and i32 %15, 4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = icmp ult %struct.Teacher** %0, %1
br i1 %19, label %28, label %20
20: ; preds = %18
%21 = icmp ugt %struct.Teacher** %0, %1
%22 = zext i1 %21 to i32
br label %28
23: ; preds = %6
%24 = icmp ult %struct.Teacher** %0, %1
br i1 %24, label %28, label %25
25: ; preds = %23
%26 = icmp ugt %struct.Teacher** %0, %1
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %25, %23, %20, %18, %14, %10
%29 = phi i32 [ -1, %10 ], [ 1, %14 ], [ -1, %18 ], [ %22, %20 ], [ -1, %23 ], [ %27, %25 ]
ret i32 %29
}