#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 priority(char);
int tpriority(char op1, char op2) {
  int p1 = priority(op1), p2 = priority(op2);
  if (p1 == -1 || p2 == -1)
    return -1;
  else if (p1 > p2)
    return 1;
  else if (p2 > p1)
    return 2;
  else
    return 0;
}


x86 assembly (clang, -O0):
<tpriority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <priority@plt>
mov    %eax,-0xc(%rbp)
movsbl -0x6(%rbp),%edi
call   1030 <priority@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1150 <tpriority+0x40>
cmpl   $0xffffffff,-0x10(%rbp)
jne    115c <tpriority+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <tpriority+0x83>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1174 <tpriority+0x64>
movl   $0x1,-0x4(%rbp)
jmp    1193 <tpriority+0x83>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    118c <tpriority+0x7c>
movl   $0x2,-0x4(%rbp)
jmp    1193 <tpriority+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tpriority>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <priority@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <priority@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0xffffffff,%ebx
je     1145 <tpriority+0x35>
cmp    $0xffffffff,%ecx
je     1145 <tpriority+0x35>
mov    $0x1,%eax
cmp    %ecx,%ebx
jg     1145 <tpriority+0x35>
setl   %al
movzbl %al,%eax
add    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tpriority(i8 signext %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %4
store i8 %1, i8* %5
%8 = load i8, i8* %4
%9 = call i32 @priority(i8 signext %8)
store i32 %9, i32* %6
%10 = load i8, i8* %5
%11 = call i32 @priority(i8 signext %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %14, %2
store i32 -1, i32* %3
br label %29
18: ; preds = %14
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %3
br label %29
23: ; preds = %18
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 2, i32* %3
br label %29
28: ; preds = %23
store i32 0, i32* %3
br label %29
29: ; preds = %28, %27, %22, %17
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @tpriority(i8 signext %0, i8 signext %1) {
%3 = tail call i32 @priority(i8 signext %0)
%4 = tail call i32 @priority(i8 signext %1)
%5 = icmp eq i32 %3, -1
%6 = icmp eq i32 %4, -1
%7 = select i1 %5, i1 true, i1 %6
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = icmp sgt i32 %3, %4
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = icmp sgt i32 %4, %3
%12 = select i1 %11, i32 2, i32 0
br label %13
13: ; preds = %10, %8, %2
%14 = phi i32 [ -1, %2 ], [ 1, %8 ], [ %12, %10 ]
ret i32 %14
}