#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 facility_number(char const *);
int /*<<< orphan*/ usage(char *);
void parse_facility(const char *str, unsigned *facility, unsigned *all_fac) {
  if (str[0] == '*' && !str[1])
    *all_fac = 1;
  else {
    int i = facility_number(str);
    if (i < 0)
      usage("Unknown facility name");
    *facility = i;
    *all_fac = 0;
  }
}


x86 assembly (clang, -O0):
<parse_facility>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1161 <parse_facility+0x41>
mov    -0x8(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    1161 <parse_facility+0x41>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1196 <parse_facility+0x76>
mov    -0x8(%rbp),%rdi
call   1030 <facility_number@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1183 <parse_facility+0x63>
lea    0xe82(%rip),%rdi
call   1040 <usage@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_facility>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
cmpb   $0x2a,(%rdi)
jne    1135 <parse_facility+0x15>
cmpb   $0x0,0x1(%rdi)
je     1152 <parse_facility+0x32>
call   1030 <facility_number@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    114c <parse_facility+0x2c>
lea    0xeb9(%rip),%rdi
call   1040 <usage@plt>
mov    %ebp,(%rbx)
xor    %eax,%eax
jmp    1157 <parse_facility+0x37>
mov    $0x1,%eax
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Unknown facility name\00"
define void @parse_facility(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 42
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = load i32*, i32** %6
store i32 1, i32* %19
br label %31
20: ; preds = %13, %3
%21 = load i8*, i8** %4
%22 = call i32 @facility_number(i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %20
%28 = load i32, i32* %7
%29 = load i32*, i32** %5
store i32 %28, i32* %29
%30 = load i32*, i32** %6
store i32 0, i32* %30
br label %31
31: ; preds = %27, %18
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Unknown facility name\00"
define void @parse_facility(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 42
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6, %3
%11 = tail call i32 @facility_number(i8* %0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
store i32 %11, i32* %1
br label %16
16: ; preds = %6, %15
%17 = phi i32 [ 0, %15 ], [ 1, %6 ]
store i32 %17, i32* %2
ret void
}