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

/* Variables and functions */
int const LOG_DAEMON;
int const LOG_LOCAL0;
int const LOG_LOCAL1;
int const LOG_LOCAL2;
int const LOG_LOCAL3;
int const LOG_LOCAL4;
int const LOG_LOCAL5;
int const LOG_LOCAL6;
int const LOG_LOCAL7;
int /*<<< orphan*/ log_emerg(char *, char *);
int /*<<< orphan*/ strcasecmp(char *, char const *);
char *strchr(char *, char);
char *strdup(char const *);
int strtol(char *, char **, int);
void parse_opt(const char *opt, char **ident, int *facility) {
  char *str = strdup(opt);
  char *ptr, *endptr;
  int n;
  const char *facility_name[] = {"daemon", "local0", "local1",
                                 "local2", "local3", "local4",
                                 "local5", "local6", "local7"};
  const int facility_num[] = {LOG_DAEMON, LOG_LOCAL0, LOG_LOCAL1,
                              LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4,
                              LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7};
  ptr = strchr(str, ',');
  if (ptr) {
    *ptr = 0;
    n = strtol(ptr + 1, &endptr, 10);
    if (*endptr) {
      for (n = 0; n < sizeof(facility_name); n++) {
        if (!strcasecmp(ptr + 1, facility_name[n]))
          break;
      }
      if (n == sizeof(facility_name))
        log_emerg("log_syslog: unknown facility name '%s'\n", ptr + 1);
      else
        *facility = facility_num[n];
    } else
      *facility = n;
  }
  *ident = str;
}


x86 assembly (clang, -O0):
<parse_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x20(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c01(%rip),%rsi
mov    $0x48,%edx
call   1070 <memcpy@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x90(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1301 <parse_opt+0x1a1>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     12f3 <parse_opt+0x193>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x48,%rax
jae    12b6 <parse_opt+0x156>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
movslq -0x34(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    12a3 <parse_opt+0x143>
jmp    12b6 <parse_opt+0x156>
jmp    12a8 <parse_opt+0x148>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1271 <parse_opt+0x111>
movslq -0x34(%rbp),%rax
cmp    $0x48,%rax
jne    12dd <parse_opt+0x17d>
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
lea    0xd6c(%rip),%rdi
call   1050 <log_emerg@plt>
jmp    12ee <parse_opt+0x18e>
movslq -0x34(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12fc <parse_opt+0x19c>
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1301 <parse_opt+0x1a1>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
call   1070 <strdup@plt>
mov    %rax,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
mov    %rax,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1208 <parse_opt+0xb8>
mov    %rax,%r13
movb   $0x0,(%rax)
add    $0x1,%r13
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1205 <parse_opt+0xb5>
xor    %ebx,%ebx
lea    0xea6(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq (%rbx,%rbp,1),%rsi
add    %rbp,%rsi
mov    %r13,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1201 <parse_opt+0xb1>
add    $0x4,%rbx
cmp    $0x120,%rbx
jne    11d0 <parse_opt+0x80>
lea    0xe48(%rip),%rdi
mov    %r13,%rsi
call   1050 <log_emerg@plt>
jmp    1208 <parse_opt+0xb8>
mov    0x10(%rsp,%rbx,1),%eax
mov    %eax,(%r15)
mov    %r12,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"daemon\00"
@.str.1 = [7 x i8] c"local0\00"
@.str.2 = [7 x i8] c"local1\00"
@.str.3 = [7 x i8] c"local2\00"
@.str.4 = [7 x i8] c"local3\00"
@.str.5 = [7 x i8] c"local4\00"
@.str.6 = [7 x i8] c"local5\00"
@.str.7 = [7 x i8] c"local6\00"
@.str.8 = [7 x i8] c"local7\00"
@__const.parse_opt.facility_name = [9 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0)]
@LOG_DAEMON = constant i32 0
@LOG_LOCAL0 = constant i32 0
@LOG_LOCAL1 = constant i32 0
@LOG_LOCAL2 = constant i32 0
@LOG_LOCAL3 = constant i32 0
@LOG_LOCAL4 = constant i32 0
@LOG_LOCAL5 = constant i32 0
@LOG_LOCAL6 = constant i32 0
@LOG_LOCAL7 = constant i32 0
@.str.9 = [40 x i8] c"log_syslog: unknown facility name '%s'\0A\00"
define void @parse_opt(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [9 x i8*]
%12 = alloca [9 x i32]
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%13 = load i8*, i8** %4
%14 = call i8* @strdup(i8* %13)
store i8* %14, i8** %7
%15 = bitcast [9 x i8*]* %11 to i8*
%16 = getelementptr inbounds [9 x i32], [9 x i32]* %12, i64 0, i64 0
%17 = load i32, i32* @LOG_DAEMON
store i32 %17, i32* %16
%18 = getelementptr inbounds i32, i32* %16, i64 1
%19 = load i32, i32* @LOG_LOCAL0
store i32 %19, i32* %18
%20 = getelementptr inbounds i32, i32* %18, i64 1
%21 = load i32, i32* @LOG_LOCAL1
store i32 %21, i32* %20
%22 = getelementptr inbounds i32, i32* %20, i64 1
%23 = load i32, i32* @LOG_LOCAL2
store i32 %23, i32* %22
%24 = getelementptr inbounds i32, i32* %22, i64 1
%25 = load i32, i32* @LOG_LOCAL3
store i32 %25, i32* %24
%26 = getelementptr inbounds i32, i32* %24, i64 1
%27 = load i32, i32* @LOG_LOCAL4
store i32 %27, i32* %26
%28 = getelementptr inbounds i32, i32* %26, i64 1
%29 = load i32, i32* @LOG_LOCAL5
store i32 %29, i32* %28
%30 = getelementptr inbounds i32, i32* %28, i64 1
%31 = load i32, i32* @LOG_LOCAL6
store i32 %31, i32* %30
%32 = getelementptr inbounds i32, i32* %30, i64 1
%33 = load i32, i32* @LOG_LOCAL7
store i32 %33, i32* %32
%34 = load i8*, i8** %7
%35 = call i8* @strchr(i8* %34, i8 signext 44)
store i8* %35, i8** %8
%36 = load i8*, i8** %8
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %84
38: ; preds = %3
%39 = load i8*, i8** %8
store i8 0, i8* %39
%40 = load i8*, i8** %8
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i32 @strtol(i8* %41, i8** %9, i32 10)
store i32 %42, i32* %10
%43 = load i8*, i8** %9
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %80
46: ; preds = %38
store i32 0, i32* %10
br label %47
47: ; preds = %62, %46
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = icmp ult i64 %49, 72
br i1 %50, label %51, label %65
51: ; preds = %47
%52 = load i8*, i8** %8
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @strcasecmp(i8* %53, i8* %57)
%59 = icmp ne i32 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %51
br label %65
61: ; preds = %51
br label %62
62: ; preds = %61
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %47
65: ; preds = %60, %47
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = icmp eq i64 %67, 72
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = load i8*, i8** %8
%71 = getelementptr inbounds i8, i8* %70, i64 1
%72 = call i32 @log_emerg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i8* %71)
br label %79
73: ; preds = %65
%74 = load i32, i32* %10
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [9 x i32], [9 x i32]* %12, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = load i32*, i32** %6
store i32 %77, i32* %78
br label %79
79: ; preds = %73, %69
br label %83
80: ; preds = %38
%81 = load i32, i32* %10
%82 = load i32*, i32** %6
store i32 %81, i32* %82
br label %83
83: ; preds = %80, %79
br label %84
84: ; preds = %83, %3
%85 = load i8*, i8** %7
%86 = load i8**, i8*** %5
store i8* %85, i8** %86
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"daemon\00"
@.str.1 = [7 x i8] c"local0\00"
@.str.2 = [7 x i8] c"local1\00"
@.str.3 = [7 x i8] c"local2\00"
@.str.4 = [7 x i8] c"local3\00"
@.str.5 = [7 x i8] c"local4\00"
@.str.6 = [7 x i8] c"local5\00"
@.str.7 = [7 x i8] c"local6\00"
@.str.8 = [7 x i8] c"local7\00"
@reltable.parse_opt = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.parse_opt to i64)) to i32)]
@LOG_DAEMON = constant i32 0
@LOG_LOCAL0 = constant i32 0
@LOG_LOCAL1 = constant i32 0
@LOG_LOCAL2 = constant i32 0
@LOG_LOCAL3 = constant i32 0
@LOG_LOCAL4 = constant i32 0
@LOG_LOCAL5 = constant i32 0
@LOG_LOCAL6 = constant i32 0
@LOG_LOCAL7 = constant i32 0
@.str.9 = [40 x i8] c"log_syslog: unknown facility name '%s'\0A\00"
define void @parse_opt(i8* nocapture %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
%5 = alloca [9 x i32]
%6 = tail call i8* @strdup(i8* %0)
%7 = bitcast i8** %4 to i8*
%8 = bitcast [9 x i32]* %5 to i8*
%9 = bitcast [9 x i32]* %5 to i8*
%10 = tail call i8* @strchr(i8* dereferenceable(1) %6, i8 signext 44)
%11 = icmp eq i8* %10, null
br i1 %11, label %34, label %12
12: ; preds = %3
store i8 0, i8* %10
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = call i32 @strtol(i8* %13, i8** %4, i32 10)
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %12, %24
%19 = phi i64 [ %25, %24 ], [ 0, %12 ]
%20 = shl i64 %19, 2
%21 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.parse_opt to i8*), i64 %20)
%22 = tail call i32 @strcasecmp(i8* %13, i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %18
%25 = add nuw nsw i64 %19, 1
%26 = icmp eq i64 %25, 72
br i1 %26, label %27, label %18
27: ; preds = %24
%28 = tail call i32 @log_emerg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i8* %13)
br label %34
29: ; preds = %18
%30 = and i64 %19, 4294967295
%31 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %2
br label %34
33: ; preds = %12
store i32 %14, i32* %2
br label %34
34: ; preds = %33, %29, %27, %3
store i8* %6, i8** %1
ret void
}