#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_PRI(int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
char *syslog_facility(int);
int syslog_priority(char *line, char **facility, int *level) {
  int priority, start;
  start = 0, sscanf(line, "<%d>%n", &priority, &start);
  if (start > 0) {
    *facility = syslog_facility(priority);
    *level = LOG_PRI(priority);
  }
  return start;
}


x86 assembly (clang, -O0):
<syslog_priority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <sscanf@plt>
cmpl   $0x0,-0x20(%rbp)
jle    118f <syslog_priority+0x5f>
mov    -0x1c(%rbp),%edi
call   1030 <syslog_facility@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%edi
call   1040 <LOG_PRI@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syslog_priority>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
movl   $0x0,(%rsp)
lea    0xeb8(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1050 <sscanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
jle    1177 <syslog_priority+0x47>
mov    0x4(%rsp),%edi
call   1030 <syslog_facility@plt>
mov    %rax,(%rbx)
mov    0x4(%rsp),%edi
call   1040 <LOG_PRI@plt>
mov    %eax,(%r14)
mov    (%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<%d>%n\00"
define i32 @syslog_priority(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
store i32 0, i32* %8
%9 = load i8*, i8** %4
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8)
%11 = load i32, i32* %8
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i32, i32* %7
%15 = call i8* @syslog_facility(i32 %14)
%16 = load i8**, i8*** %5
store i8* %15, i8** %16
%17 = load i32, i32* %7
%18 = call i32 @LOG_PRI(i32 %17)
%19 = load i32*, i32** %6
store i32 %18, i32* %19
br label %20
20: ; preds = %13, %3
%21 = load i32, i32* %8
ret i32 %21
}

LLVM IR (-O2):
@.str = [7 x i8] c"<%d>%n\00"
define i32 @syslog_priority(i8* nocapture %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i32, i32* %4
%13 = call i8* @syslog_facility(i32 %12)
store i8* %13, i8** %1
%14 = load i32, i32* %4
%15 = call i32 @LOG_PRI(i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %5
br label %17
17: ; preds = %11, %3
%18 = phi i32 [ %16, %11 ], [ %9, %3 ]
ret i32 %18
}