int Calc_OperatorWeigh(char operator) {
  switch (operator) {
  case '+':
    return operator+ 2;
  case '-':
    return operator;
  case '*':
    return operator+ 0x15;
  case '/':
    return operator+ 0x10;
  case '(':
    return operator+ 0x31;
  case ')':
    return operator+ 0x30;
  case '^':
    return operator- 0x10;
  default:
    return operator;
  }
}


x86 assembly (clang, -O0):
<Calc_OperatorWeigh>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffd8,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x36,%eax
ja     119a <Calc_OperatorWeigh+0x9a>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x5(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
add    $0x15,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
add    $0x31,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <Calc_OperatorWeigh+0xa1>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Calc_OperatorWeigh>:
lea    -0x28(%rdi),%ecx
cmp    $0x36,%ecx
ja     1129 <Calc_OperatorWeigh+0x29>
mov    $0x2d,%eax
lea    0xeec(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x59,%eax
ret
mov    $0x3f,%eax
ret
mov    %edi,%eax
ret
mov    $0x4e,%eax
ret

LLVM IR (-O0):
define i32 @Calc_OperatorWeigh(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
switch i32 %5, label %33 [
i32 43, label %6
i32 45, label %10
i32 42, label %13
i32 47, label %17
i32 40, label %21
i32 41, label %25
i32 94, label %29
]
6: ; preds = %1
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = add nsw i32 %8, 2
store i32 %9, i32* %2
br label %36
10: ; preds = %1
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
store i32 %12, i32* %2
br label %36
13: ; preds = %1
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = add nsw i32 %15, 21
store i32 %16, i32* %2
br label %36
17: ; preds = %1
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = add nsw i32 %19, 16
store i32 %20, i32* %2
br label %36
21: ; preds = %1
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = add nsw i32 %23, 49
store i32 %24, i32* %2
br label %36
25: ; preds = %1
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 48
store i32 %28, i32* %2
br label %36
29: ; preds = %1
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 16
store i32 %32, i32* %2
br label %36
33: ; preds = %1
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
store i32 %35, i32* %2
br label %36
36: ; preds = %33, %29, %25, %21, %17, %13, %10, %6
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @Calc_OperatorWeigh(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %8 [
i32 43, label %9
i32 45, label %9
i32 42, label %3
i32 47, label %4
i32 40, label %5
i32 41, label %6
i32 94, label %7
]
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %1, %8, %7, %6, %5, %4, %3
%10 = phi i32 [ %2, %8 ], [ 78, %7 ], [ 89, %6 ], [ 89, %5 ], [ 63, %4 ], [ 63, %3 ], [ 45, %1 ], [ 45, %1 ]
ret i32 %10
}