#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 LOG_DAEMON;
int strtol(char const *, char **, int /*<<< orphan*/);
int tapdisk_syslog_facility_by_name(char const *);
int tapdisk_syslog_facility(const char *arg) {
  int facility;
  char *endptr;
  if (arg) {
    facility = strtol(arg, &endptr, 0);
    if (*endptr == 0)
      return facility;
    facility = tapdisk_syslog_facility_by_name(arg);
    if (facility >= 0)
      return facility;
  }
  return LOG_DAEMON;
}


x86 assembly (clang, -O0):
<tapdisk_syslog_facility>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118a <tapdisk_syslog_facility+0x6a>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1164 <tapdisk_syslog_facility+0x44>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <tapdisk_syslog_facility+0x76>
mov    -0x10(%rbp),%rdi
call   1040 <tapdisk_syslog_facility_by_name@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1185 <tapdisk_syslog_facility+0x65>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <tapdisk_syslog_facility+0x76>
jmp    118a <tapdisk_syslog_facility+0x6a>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tapdisk_syslog_facility>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     114f <tapdisk_syslog_facility+0x2f>
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1158 <tapdisk_syslog_facility+0x38>
mov    %rbx,%rdi
call   1040 <tapdisk_syslog_facility_by_name@plt>
test   %eax,%eax
jns    1158 <tapdisk_syslog_facility+0x38>
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@LOG_DAEMON = global i32 0
define i32 @tapdisk_syslog_facility(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %25
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strtol(i8* %9, i8** %5, i32 0)
store i32 %10, i32* %4
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = load i32, i32* %4
store i32 %16, i32* %2
br label %27
17: ; preds = %8
%18 = load i8*, i8** %3
%19 = call i32 @tapdisk_syslog_facility_by_name(i8* %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i32, i32* %4
store i32 %23, i32* %2
br label %27
24: ; preds = %17
br label %25
25: ; preds = %24, %1
%26 = load i32, i32* @LOG_DAEMON
store i32 %26, i32* %2
br label %27
27: ; preds = %25, %22, %15
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@LOG_DAEMON = global i32 0
define i32 @tapdisk_syslog_facility(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = call i32 @strtol(i8* %0, i8** %2, i32 0)
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = tail call i32 @tapdisk_syslog_facility_by_name(i8* %0)
%12 = icmp sgt i32 %11, -1
br i1 %12, label %15, label %13
13: ; preds = %10, %1
%14 = load i32, i32* @LOG_DAEMON
br label %15
15: ; preds = %10, %5, %13
%16 = phi i32 [ %14, %13 ], [ %6, %5 ], [ %11, %10 ]
ret i32 %16
}