#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 /*<<< orphan*/ event;

/* Variables and functions */
int find_symb_pos(char const *, char);
int /*<<< orphan*/ isdigit(int);
int get_prio(const char *event) {
  int ret, prio_position, first_colon;
  if (!event)
    return -1;
  prio_position = find_symb_pos(event, '>') + 1;
  if (event[prio_position] == ':' || !isdigit((int)(event[prio_position])))
    return -1;
  first_colon = find_symb_pos(event, ':');
  if (first_colon - prio_position > 1)
    return -1;
  ret = (int)(event[prio_position]) - 48;
  return ret < 4 ? ret : -1;
}


x86 assembly (clang, -O0):
<get_prio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <get_prio+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <get_prio+0xd8>
mov    -0x10(%rbp),%rdi
mov    $0x3e,%esi
call   1040 <find_symb_pos@plt>
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     1186 <get_prio+0x66>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1192 <get_prio+0x72>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <get_prio+0xd8>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <find_symb_pos@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
cmp    $0x1,%eax
jle    11be <get_prio+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <get_prio+0xd8>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11e5 <get_prio+0xc5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11f2 <get_prio+0xd2>
mov    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11f2 <get_prio+0xd2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prio>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     116d <get_prio+0x5d>
mov    %rdi,%rbx
mov    $0x3e,%esi
call   1030 <find_symb_pos@plt>
movslq %eax,%rbp
movsbl 0x1(%rbx,%rbp,1),%eax
cmp    $0x3a,%eax
je     116d <get_prio+0x5d>
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     116d <get_prio+0x5d>
add    $0x1,%rbp
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <find_symb_pos@plt>
sub    %ebp,%eax
cmp    $0x1,%eax
jg     116d <get_prio+0x5d>
movsbl (%rbx,%rbp,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x34,%eax
mov    $0xffffffff,%r14d
cmovl  %ecx,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_prio(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 -1, i32* %2
br label %54
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @find_symb_pos(i8* %11, i8 signext 62)
%13 = add nsw i32 %12, 1
store i32 %13, i32* %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 58
br i1 %20, label %30, label %21
21: ; preds = %10
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 @isdigit(i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %21, %10
store i32 -1, i32* %2
br label %54
31: ; preds = %21
%32 = load i8*, i8** %3
%33 = call i32 @find_symb_pos(i8* %32, i8 signext 58)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = sub nsw i32 %34, %35
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %39
38: ; preds = %31
store i32 -1, i32* %2
br label %54
39: ; preds = %31
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 48
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 4
br i1 %48, label %49, label %51
49: ; preds = %39
%50 = load i32, i32* %4
br label %52
51: ; preds = %39
br label %52
52: ; preds = %51, %49
%53 = phi i32 [ %50, %49 ], [ -1, %51 ]
store i32 %53, i32* %2
br label %54
54: ; preds = %52, %38, %30, %9
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
define i32 @get_prio(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %24, label %3
3: ; preds = %1
%4 = tail call i32 @find_symb_pos(i8* %0, i8 signext 62)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 58
%10 = sext i8 %8 to i32
%11 = add nsw i32 %10, -48
%12 = icmp ult i32 %11, 10
%13 = select i1 %9, i1 %12, i1 false
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = tail call i32 @find_symb_pos(i8* %0, i8 signext 58)
%16 = sub nsw i32 %15, %5
%17 = icmp sgt i32 %16, 1
br i1 %17, label %24, label %18
18: ; preds = %14
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = add nsw i32 %20, -48
%22 = icmp slt i8 %19, 52
%23 = select i1 %22, i32 %21, i32 -1
br label %24
24: ; preds = %14, %3, %1, %18
%25 = phi i32 [ %23, %18 ], [ -1, %1 ], [ -1, %3 ], [ -1, %14 ]
ret i32 %25
}