#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 /*<<< orphan*/ err_abort(char *, char *, int);
int /*<<< orphan*/ err_warning(char *, char *);
int hand_cmp_headcorner(int hctype, int new_hctype) {
  if (hctype == -1) {
    return (1);
  }
  if ((hctype == 0) && (new_hctype == 0)) {
    err_warning("hand_cmp_headcorner", "two footnodes detected in a tree\n");
  }
  if (hctype == new_hctype) {
    return (0);
  }
  switch (hctype) {
  case 0:
    break;
  case 1:
    if (new_hctype == 0) {
      return (1);
    }
    break;
  case 3:
    if ((new_hctype == 0) || (new_hctype == 1)) {
      return (1);
    }
    break;
  case 2:
    if ((new_hctype == 0) || (new_hctype == 1) || (new_hctype == 3)) {
      return (1);
    }
    break;
  case 4:
    if ((new_hctype == 0) || (new_hctype == 1) || (new_hctype == 2) ||
        (new_hctype == 3)) {
      return (1);
    }
    break;
  default:
    err_abort("hand_cmp_headcorner", "unknown type %d\n", hctype);
    break;
  }
  return (-1);
}


x86 assembly (clang, -O0):
<hand_cmp_headcorner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1144 <hand_cmp_headcorner+0x24>
movl   $0x1,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
cmpl   $0x0,-0x8(%rbp)
jne    116b <hand_cmp_headcorner+0x4b>
cmpl   $0x0,-0xc(%rbp)
jne    116b <hand_cmp_headcorner+0x4b>
lea    0xeb5(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1040 <err_warning@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1183 <hand_cmp_headcorner+0x63>
movl   $0x0,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     1255 <hand_cmp_headcorner+0x135>
mov    -0x18(%rbp),%rax
lea    0xe61(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    126b <hand_cmp_headcorner+0x14b>
cmpl   $0x0,-0xc(%rbp)
jne    11c3 <hand_cmp_headcorner+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
jmp    126b <hand_cmp_headcorner+0x14b>
cmpl   $0x0,-0xc(%rbp)
je     11dc <hand_cmp_headcorner+0xbc>
cmpl   $0x1,-0xc(%rbp)
jne    11e8 <hand_cmp_headcorner+0xc8>
movl   $0x1,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
jmp    126b <hand_cmp_headcorner+0x14b>
cmpl   $0x0,-0xc(%rbp)
je     120b <hand_cmp_headcorner+0xeb>
cmpl   $0x1,-0xc(%rbp)
je     120b <hand_cmp_headcorner+0xeb>
cmpl   $0x3,-0xc(%rbp)
jne    1217 <hand_cmp_headcorner+0xf7>
movl   $0x1,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
jmp    126b <hand_cmp_headcorner+0x14b>
cmpl   $0x0,-0xc(%rbp)
je     1244 <hand_cmp_headcorner+0x124>
cmpl   $0x1,-0xc(%rbp)
je     1244 <hand_cmp_headcorner+0x124>
cmpl   $0x2,-0xc(%rbp)
je     1244 <hand_cmp_headcorner+0x124>
cmpl   $0x3,-0xc(%rbp)
jne    1250 <hand_cmp_headcorner+0x130>
movl   $0x1,-0x4(%rbp)
jmp    1272 <hand_cmp_headcorner+0x152>
jmp    126b <hand_cmp_headcorner+0x14b>
mov    -0x8(%rbp),%edx
lea    0xdb5(%rip),%rdi
lea    0xde4(%rip),%rsi
call   1030 <err_abort@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hand_cmp_headcorner>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0xffffffff,%edi
je     11bc <hand_cmp_headcorner+0x9c>
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%eax
or     %edi,%eax
jne    114e <hand_cmp_headcorner+0x2e>
lea    0xed2(%rip),%rdi
lea    0xedf(%rip),%rsi
call   1040 <err_warning@plt>
xor    %eax,%eax
cmp    %ebx,%ebp
je     11bc <hand_cmp_headcorner+0x9c>
cmp    $0x4,%ebp
ja     1196 <hand_cmp_headcorner+0x76>
mov    %ebp,%eax
lea    0xe9e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%eax
test   %ebx,%ebx
jne    11b7 <hand_cmp_headcorner+0x97>
jmp    11bc <hand_cmp_headcorner+0x9c>
cmp    $0x4,%ebx
jae    11b7 <hand_cmp_headcorner+0x97>
movslq %ebx,%rax
lea    0xed7(%rip),%rcx
mov    (%rcx,%rax,4),%eax
jmp    11bc <hand_cmp_headcorner+0x9c>
mov    $0x1,%eax
cmp    $0x4,%ebx
jae    11b7 <hand_cmp_headcorner+0x97>
jmp    11bc <hand_cmp_headcorner+0x9c>
lea    0xe77(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    %ebp,%edx
call   1030 <err_abort@plt>
jmp    11b7 <hand_cmp_headcorner+0x97>
mov    $0x1,%eax
cmp    $0x2,%ebx
jb     11bc <hand_cmp_headcorner+0x9c>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"hand_cmp_headcorner\00"
@.str.1 = [34 x i8] c"two footnodes detected in a tree\0A\00"
@.str.2 = [17 x i8] c"unknown type %d\0A\00"
define i32 @hand_cmp_headcorner(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %67
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @err_warning(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %12, %9
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %3
br label %67
22: ; preds = %17
%23 = load i32, i32* %4
switch i32 %23, label %63 [
i32 0, label %24
i32 1, label %25
i32 3, label %30
i32 2, label %38
i32 4, label %49
]
24: ; preds = %22
br label %66
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %3
br label %67
29: ; preds = %25
br label %66
30: ; preds = %22
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %33, %30
store i32 1, i32* %3
br label %67
37: ; preds = %33
br label %66
38: ; preds = %22
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 1
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 3
br i1 %46, label %47, label %48
47: ; preds = %44, %41, %38
store i32 1, i32* %3
br label %67
48: ; preds = %44
br label %66
49: ; preds = %22
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, 0
br i1 %51, label %61, label %52
52: ; preds = %49
%53 = load i32, i32* %5
%54 = icmp eq i32 %53, 1
br i1 %54, label %61, label %55
55: ; preds = %52
%56 = load i32, i32* %5
%57 = icmp eq i32 %56, 2
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = load i32, i32* %5
%60 = icmp eq i32 %59, 3
br i1 %60, label %61, label %62
61: ; preds = %58, %55, %52, %49
store i32 1, i32* %3
br label %67
62: ; preds = %58
br label %66
63: ; preds = %22
%64 = load i32, i32* %4
%65 = call i32 @err_abort(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %62, %48, %37, %29, %24
store i32 -1, i32* %3
br label %67
67: ; preds = %66, %61, %47, %36, %28, %21, %8
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [20 x i8] c"hand_cmp_headcorner\00"
@.str.1 = [34 x i8] c"two footnodes detected in a tree\0A\00"
@.str.2 = [17 x i8] c"unknown type %d\0A\00"
@switch.table.hand_cmp_headcorner = [4 x i32] [i32 1, i32 1, i32 -1, i32 1]
define i32 @hand_cmp_headcorner(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, -1
br i1 %3, label %27, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
%6 = or i32 %1, %0
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @err_warning(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = icmp eq i32 %0, %1
br i1 %11, label %27, label %12
12: ; preds = %10
switch i32 %0, label %20 [
i32 0, label %22
i32 1, label %13
i32 3, label %14
i32 2, label %16
i32 4, label %18
]
13: ; preds = %12
br i1 %5, label %27, label %22
14: ; preds = %12
%15 = icmp ult i32 %1, 2
br i1 %15, label %27, label %22
16: ; preds = %12
%17 = icmp ult i32 %1, 4
br i1 %17, label %23, label %22
18: ; preds = %12
%19 = icmp ult i32 %1, 4
br i1 %19, label %27, label %22
20: ; preds = %12
%21 = tail call i32 @err_abort(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %22
22: ; preds = %16, %18, %14, %13, %20, %12
br label %27
23: ; preds = %16
%24 = sext i32 %1 to i64
%25 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.hand_cmp_headcorner, i64 0, i64 %24
%26 = load i32, i32* %25
br label %27
27: ; preds = %23, %18, %14, %13, %10, %2, %22
%28 = phi i32 [ -1, %22 ], [ 1, %2 ], [ 0, %10 ], [ 1, %13 ], [ 1, %14 ], [ 1, %18 ], [ %26, %23 ]
ret i32 %28
}