int precedence(char operator1, char operator2) {
  int ret;
  int prec1 = 0;
  int prec2 = 0;
  switch (operator1) {
  case '+':
  case '-':
    prec1 = 1;
    break;
  case '*':
  case '/':
  case '^':
  case '%':
    prec1 = 2;
    break;
  }
  switch (operator2) {
  case '+':
  case '-':
    prec2 = 1;
    break;
  case '*':
  case '/':
  case '^':
  case '%':
    prec2 = 2;
    break;
  }
  if (prec1 > prec2) {
    ret = 1;
  } else if (prec1 == prec2) {
    ret = 0;
  } else if (prec1 < prec2) {
    ret = -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<precedence>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x25,%eax
je     1194 <precedence+0x94>
jmp    1133 <precedence+0x33>
mov    -0x14(%rbp),%eax
sub    $0x2a,%eax
je     1194 <precedence+0x94>
jmp    1144 <precedence+0x44>
mov    -0x14(%rbp),%eax
sub    $0x2b,%eax
je     1188 <precedence+0x88>
jmp    1155 <precedence+0x55>
mov    -0x14(%rbp),%eax
sub    $0x2d,%eax
je     1188 <precedence+0x88>
jmp    1166 <precedence+0x66>
mov    -0x14(%rbp),%eax
sub    $0x2f,%eax
je     1194 <precedence+0x94>
jmp    1177 <precedence+0x77>
mov    -0x14(%rbp),%eax
sub    $0x5e,%eax
je     1194 <precedence+0x94>
jmp    119b <precedence+0x9b>
movl   $0x1,-0xc(%rbp)
jmp    119b <precedence+0x9b>
movl   $0x2,-0xc(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x25,%eax
je     1211 <precedence+0x111>
jmp    11b0 <precedence+0xb0>
mov    -0x18(%rbp),%eax
sub    $0x2a,%eax
je     1211 <precedence+0x111>
jmp    11c1 <precedence+0xc1>
mov    -0x18(%rbp),%eax
sub    $0x2b,%eax
je     1205 <precedence+0x105>
jmp    11d2 <precedence+0xd2>
mov    -0x18(%rbp),%eax
sub    $0x2d,%eax
je     1205 <precedence+0x105>
jmp    11e3 <precedence+0xe3>
mov    -0x18(%rbp),%eax
sub    $0x2f,%eax
je     1211 <precedence+0x111>
jmp    11f4 <precedence+0xf4>
mov    -0x18(%rbp),%eax
sub    $0x5e,%eax
je     1211 <precedence+0x111>
jmp    1218 <precedence+0x118>
movl   $0x1,-0x10(%rbp)
jmp    1218 <precedence+0x118>
movl   $0x2,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1230 <precedence+0x130>
movl   $0x1,-0x8(%rbp)
jmp    1265 <precedence+0x165>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1248 <precedence+0x148>
movl   $0x0,-0x8(%rbp)
jmp    1260 <precedence+0x160>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    125b <precedence+0x15b>
movl   $0xffffffff,-0x8(%rbp)
jmp    1260 <precedence+0x160>
jmp    1265 <precedence+0x165>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<precedence>:
xor    %eax,%eax
add    $0xffffffdb,%edi
movabs $0x200000000000421,%rdx
mov    $0x0,%ecx
cmp    $0x39,%edi
ja     113b <precedence+0x3b>
bt     %rdi,%rdx
jae    1126 <precedence+0x26>
mov    $0x2,%ecx
jmp    113b <precedence+0x3b>
mov    $0x140,%ecx
bt     %rdi,%rcx
mov    $0x0,%ecx
jae    113b <precedence+0x3b>
mov    $0x1,%ecx
movsbl %sil,%esi
add    $0xffffffdb,%esi
cmp    $0x39,%esi
ja     1164 <precedence+0x64>
bt     %rsi,%rdx
jae    1154 <precedence+0x54>
mov    $0x2,%eax
jmp    1164 <precedence+0x64>
mov    $0x140,%edx
bt     %rsi,%rdx
jae    1164 <precedence+0x64>
mov    $0x1,%eax
xor    %edx,%edx
cmp    %eax,%ecx
setne  %dl
neg    %edx
cmp    %eax,%ecx
mov    $0x1,%eax
cmovbe %edx,%eax
ret

LLVM IR (-O0):
define i32 @precedence(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
switch i32 %9, label %12 [
i32 43, label %10
i32 45, label %10
i32 42, label %11
i32 47, label %11
i32 94, label %11
i32 37, label %11
]
10: ; preds = %2, %2
store i32 1, i32* %6
br label %12
11: ; preds = %2, %2, %2, %2
store i32 2, i32* %6
br label %12
12: ; preds = %2, %11, %10
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
switch i32 %14, label %17 [
i32 43, label %15
i32 45, label %15
i32 42, label %16
i32 47, label %16
i32 94, label %16
i32 37, label %16
]
15: ; preds = %12, %12
store i32 1, i32* %7
br label %17
16: ; preds = %12, %12, %12, %12
store i32 2, i32* %7
br label %17
17: ; preds = %12, %16, %15
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %5
br label %34
22: ; preds = %17
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, i32* %5
br label %33
27: ; preds = %22
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %5
br label %32
32: ; preds = %31, %27
br label %33
33: ; preds = %32, %26
br label %34
34: ; preds = %33, %21
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @precedence(i8 signext %0, i8 signext %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %6 [
i32 43, label %4
i32 45, label %4
i32 42, label %5
i32 47, label %5
i32 94, label %5
i32 37, label %5
]
4: ; preds = %2, %2
br label %6
5: ; preds = %2, %2, %2, %2
br label %6
6: ; preds = %2, %5, %4
%7 = phi i32 [ 0, %2 ], [ 2, %5 ], [ 1, %4 ]
%8 = sext i8 %1 to i32
switch i32 %8, label %11 [
i32 43, label %9
i32 45, label %9
i32 42, label %10
i32 47, label %10
i32 94, label %10
i32 37, label %10
]
9: ; preds = %6, %6
br label %11
10: ; preds = %6, %6, %6, %6
br label %11
11: ; preds = %6, %10, %9
%12 = phi i32 [ 0, %6 ], [ 2, %10 ], [ 1, %9 ]
%13 = icmp ugt i32 %7, %12
%14 = icmp ne i32 %7, %12
%15 = sext i1 %14 to i32
%16 = select i1 %13, i32 1, i32 %15
ret i32 %16
}