int operator_priority(char op) {
  int priority = 0;
  switch (op) {
  case '/':
    priority++;
  case '*':
    priority++;
  case '%':
    priority++;
  case '+':
    priority++;
  case '-':
    priority++;
  case '&':
    priority++;
  case '|':
    priority++;
  case '\0':
    priority++;
  }
  return priority;
}


x86 assembly (clang, -O0):
<operator_priority>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     11db <operator_priority+0xdb>
jmp    1125 <operator_priority+0x25>
mov    -0xc(%rbp),%eax
sub    $0x25,%eax
je     11ae <operator_priority+0xae>
jmp    1136 <operator_priority+0x36>
mov    -0xc(%rbp),%eax
sub    $0x26,%eax
je     11c9 <operator_priority+0xc9>
jmp    1147 <operator_priority+0x47>
mov    -0xc(%rbp),%eax
sub    $0x2a,%eax
je     11a5 <operator_priority+0xa5>
jmp    1158 <operator_priority+0x58>
mov    -0xc(%rbp),%eax
sub    $0x2b,%eax
je     11b7 <operator_priority+0xb7>
jmp    1169 <operator_priority+0x69>
mov    -0xc(%rbp),%eax
sub    $0x2d,%eax
je     11c0 <operator_priority+0xc0>
jmp    117a <operator_priority+0x7a>
mov    -0xc(%rbp),%eax
sub    $0x2f,%eax
je     119c <operator_priority+0x9c>
jmp    118b <operator_priority+0x8b>
mov    -0xc(%rbp),%eax
sub    $0x7c,%eax
je     11d2 <operator_priority+0xd2>
jmp    11e4 <operator_priority+0xe4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<operator_priority>:
xor    %eax,%eax
cmp    $0x2f,%edi
ja     1152 <operator_priority+0x52>
mov    $0x1,%edx
mov    $0x3,%ecx
mov    $0x4,%r11d
mov    $0x5,%r8d
mov    $0x6,%r10d
mov    $0x7,%r9d
mov    %edi,%edi
lea    0xece(%rip),%rsi
movslq (%rsi,%rdi,4),%rdi
add    %rsi,%rdi
jmp    *%rdi
mov    $0x8,%r9d
mov    %r9d,%r10d
mov    %r10d,%r8d
mov    %r8d,%r11d
mov    %r11d,%ecx
mov    %ecx,%edx
mov    %edx,%eax
ret
mov    $0x2,%ecx
cmp    $0x7c,%edi
je     114d <operator_priority+0x4d>
jmp    1151 <operator_priority+0x51>

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

LLVM IR (-O2):
define i32 @operator_priority(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %18 [
i32 47, label %3
i32 42, label %4
i32 37, label %6
i32 43, label %8
i32 45, label %10
i32 38, label %12
i32 124, label %14
i32 0, label %16
]
3: ; preds = %1
br label %4
4: ; preds = %1, %3
%5 = phi i32 [ 7, %1 ], [ 8, %3 ]
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ 6, %1 ], [ %5, %4 ]
br label %8
8: ; preds = %1, %6
%9 = phi i32 [ 5, %1 ], [ %7, %6 ]
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ 4, %1 ], [ %9, %8 ]
br label %12
12: ; preds = %1, %10
%13 = phi i32 [ 3, %1 ], [ %11, %10 ]
br label %14
14: ; preds = %1, %12
%15 = phi i32 [ 2, %1 ], [ %13, %12 ]
br label %16
16: ; preds = %1, %14
%17 = phi i32 [ 1, %1 ], [ %15, %14 ]
br label %18
18: ; preds = %16, %1
%19 = phi i32 [ 0, %1 ], [ %17, %16 ]
ret i32 %19
}