#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 */
scalar_t__ strcmp(char const *, char *);
int calc_operator_precedence(const char *oper) {
  if (!oper)
    return 0;
  if ((strcmp(oper, "*") == 0) || (strcmp(oper, "/") == 0) ||
      (strcmp(oper, "//") == 0) || (strcmp(oper, "%") == 0) ||
      (strcmp(oper, "**") == 0)) {
    return 2;
  }
  if ((strcmp(oper, "+") == 0) || (strcmp(oper, "-") == 0)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<calc_operator_precedence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <calc_operator_precedence+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1208 <calc_operator_precedence+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xec8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b5 <calc_operator_precedence+0xa5>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b5 <calc_operator_precedence+0xa5>
mov    -0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b5 <calc_operator_precedence+0xa5>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b5 <calc_operator_precedence+0xa5>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <calc_operator_precedence+0xb1>
movl   $0x2,-0x4(%rbp)
jmp    1208 <calc_operator_precedence+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11f5 <calc_operator_precedence+0xe5>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1201 <calc_operator_precedence+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1208 <calc_operator_precedence+0xf8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_operator_precedence>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     11b7 <calc_operator_precedence+0xa7>
mov    %rdi,%rbx
lea    0xee0(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11b9 <calc_operator_precedence+0xa9>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b9 <calc_operator_precedence+0xa9>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b9 <calc_operator_precedence+0xa9>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b9 <calc_operator_precedence+0xa9>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b9 <calc_operator_precedence+0xa9>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <calc_operator_precedence+0xb2>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    11b9 <calc_operator_precedence+0xa9>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%ebp
jmp    11b9 <calc_operator_precedence+0xa9>

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"//\00"
@.str.3 = [2 x i8] c"%\00"
@.str.4 = [3 x i8] c"**\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [2 x i8] c"-\00"
define i32 @calc_operator_precedence(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i32 0, i32* %2
br label %38
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19, %15, %11, %7
store i32 2, i32* %2
br label %38
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8*, i8** %3
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32, %28
store i32 1, i32* %2
br label %38
37: ; preds = %32
store i32 0, i32* %2
br label %38
38: ; preds = %37, %36, %27, %6
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"//\00"
@.str.3 = [2 x i8] c"%\00"
@.str.4 = [3 x i8] c"**\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [2 x i8] c"-\00"
define i32 @calc_operator_precedence(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %25, label %3
3: ; preds = %1
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %18, %3, %6, %9, %12, %15, %1
%26 = phi i32 [ 0, %1 ], [ 2, %15 ], [ 2, %12 ], [ 2, %9 ], [ 2, %6 ], [ 2, %3 ], [ 1, %18 ], [ %24, %21 ]
ret i32 %26
}