#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 */
int priority_number(char const *);
int /*<<< orphan*/ usage(char *);
void parse_priority(const char *str, unsigned *priority, unsigned *negate,
                    unsigned *equal) {
  *negate = 0;
  while (*str == '!') {
    ++str;
    *negate = !*negate;
  }
  *equal = 0;
  while (*str == '=') {
    ++str;
    *equal = 1;
  }
  if (str[0] == '*' && !str[1])
    *priority = 8 - 1;
  else {
    int i = priority_number(str);
    if (i < 0)
      usage("Unknown priority name");
    *priority = i;
  }
}


x86 assembly (clang, -O0):
<parse_priority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    117a <parse_priority+0x5a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1142 <parse_priority+0x22>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    11af <parse_priority+0x8f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    1184 <parse_priority+0x64>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11dc <parse_priority+0xbc>
mov    -0x8(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    11dc <parse_priority+0xbc>
mov    -0x10(%rbp),%rax
movl   $0x7,(%rax)
jmp    1207 <parse_priority+0xe7>
mov    -0x8(%rbp),%rdi
call   1030 <priority_number@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11fe <parse_priority+0xde>
lea    0xe07(%rip),%rdi
call   1040 <usage@plt>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_priority>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rax
movl   $0x0,(%rdx)
cmpb   $0x21,(%rdi)
jne    1154 <parse_priority+0x34>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rax),%rdi
xor    $0x1,%esi
mov    %esi,(%rdx)
cmpb   $0x21,0x1(%rax)
mov    %rdi,%rax
je     1140 <parse_priority+0x20>
jmp    1157 <parse_priority+0x37>
mov    %rax,%rdi
xor    %eax,%eax
nopl   0x0(%rax)
mov    %eax,(%rcx)
movzbl (%rdi),%eax
cmp    $0x3d,%al
jne    1174 <parse_priority+0x54>
add    $0x1,%rdi
mov    $0x1,%eax
jmp    1160 <parse_priority+0x40>
cmp    $0x2a,%al
jne    117e <parse_priority+0x5e>
cmpb   $0x0,0x1(%rdi)
je     1197 <parse_priority+0x77>
call   1030 <priority_number@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    119c <parse_priority+0x7c>
lea    0xe70(%rip),%rdi
call   1040 <usage@plt>
jmp    119c <parse_priority+0x7c>
mov    $0x7,%ebp
mov    %ebp,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Unknown priority name\00"
define void @parse_priority(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i32*, i32** %7
store i32 0, i32* %10
br label %11
11: ; preds = %16, %4
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 33
br i1 %15, label %16, label %25
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %5
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
%24 = load i32*, i32** %7
store i32 %23, i32* %24
br label %11
25: ; preds = %11
%26 = load i32*, i32** %8
store i32 0, i32* %26
br label %27
27: ; preds = %32, %25
%28 = load i8*, i8** %5
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 61
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
%35 = load i32*, i32** %8
store i32 1, i32* %35
br label %27
36: ; preds = %27
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 42
br i1 %41, label %42, label %49
42: ; preds = %36
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = load i32*, i32** %6
store i32 7, i32* %48
br label %59
49: ; preds = %42, %36
%50 = load i8*, i8** %5
%51 = call i32 @priority_number(i8* %50)
store i32 %51, i32* %9
%52 = load i32, i32* %9
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = load i32, i32* %9
%58 = load i32*, i32** %6
store i32 %57, i32* %58
br label %59
59: ; preds = %56, %47
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Unknown priority name\00"
define void @parse_priority(i8* %0, i32* nocapture writeonly %1, i32* nocapture %2, i32* nocapture writeonly %3) {
store i32 0, i32* %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 33
br i1 %6, label %7, label %14
7: ; preds = %4, %7
%8 = phi i8* [ %10, %7 ], [ %0, %4 ]
%9 = phi i32 [ %11, %7 ], [ 0, %4 ]
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = xor i32 %9, 1
store i32 %11, i32* %2
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 33
br i1 %13, label %7, label %14
14: ; preds = %7, %4
%15 = phi i8* [ %0, %4 ], [ %10, %7 ]
br label %16
16: ; preds = %14, %20
%17 = phi i32 [ 1, %20 ], [ 0, %14 ]
%18 = phi i8* [ %21, %20 ], [ %15, %14 ]
store i32 %17, i32* %3
%19 = load i8, i8* %18
switch i8 %19, label %26 [
i8 61, label %20
i8 42, label %22
]
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %18, i64 1
br label %16
22: ; preds = %16
%23 = getelementptr inbounds i8, i8* %18, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %16, %22
%27 = tail call i32 @priority_number(i8* %18)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %26, %29, %22
%32 = phi i32 [ 7, %22 ], [ %27, %29 ], [ %27, %26 ]
store i32 %32, i32* %1
ret void
}