#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 */
typedef int uint8_t;

/* Variables and functions */
uint8_t precedence(char o) {
  if (o == '(' || o == ')')
    return 5;
  if (o == '^')
    return 4;
  if (o == '*' || o == '/')
    return 3;
  if (o == '+' || o == '-')
    return 2;
  return 0;
}


x86 assembly (clang, -O0):
<precedence>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x28,%eax
je     1124 <precedence+0x24>
movsbl -0x5(%rbp),%eax
cmp    $0x29,%eax
jne    1130 <precedence+0x30>
movl   $0x5,-0x4(%rbp)
jmp    119c <precedence+0x9c>
movsbl -0x5(%rbp),%eax
cmp    $0x5e,%eax
jne    1149 <precedence+0x49>
movl   $0x4,-0x4(%rbp)
jmp    119c <precedence+0x9c>
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
je     1163 <precedence+0x63>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jne    116f <precedence+0x6f>
movl   $0x3,-0x4(%rbp)
jmp    119c <precedence+0x9c>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
je     1189 <precedence+0x89>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
jne    1195 <precedence+0x95>
movl   $0x2,-0x4(%rbp)
jmp    119c <precedence+0x9c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<precedence>:
mov    %edi,%ecx
and    $0xfe,%cl
mov    $0x5,%eax
cmp    $0x28,%cl
je     1141 <precedence+0x41>
lea    -0x2a(%rdi),%eax
cmp    $0x5,%al
ja     1136 <precedence+0x36>
movzbl %al,%eax
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3,%eax
ret
mov    $0x2,%eax
jmp    1141 <precedence+0x41>
mov    $0x4,%eax
cmp    $0x5e,%dil
jne    1142 <precedence+0x42>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @precedence(i8 signext %0) {
%2 = and i8 %0, -2
%3 = icmp eq i8 %2, 40
br i1 %3, label %8, label %4
4: ; preds = %1
switch i8 %0, label %5 [
i8 94, label %8
i8 47, label %6
i8 42, label %6
i8 45, label %7
i8 43, label %7
]
5: ; preds = %4
br label %8
6: ; preds = %4, %4
br label %8
7: ; preds = %4, %4
br label %8
8: ; preds = %4, %7, %6, %1, %5
%9 = phi i32 [ 0, %5 ], [ 5, %1 ], [ 4, %4 ], [ 3, %6 ], [ 2, %7 ]
ret i32 %9
}