#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 /*<<< orphan*/ free(char *);
char *strchr(char const *, char);
char *string_strndup(char const *, int);
long strtol(char *, char **, int);
void hook_get_priority_and_name(const char *string, int *priority,
                                const char **name) {
  char *pos, *str_priority, *error;
  long number;
  if (priority)
    *priority = 1000;
  if (name)
    *name = string;
  pos = strchr(string, '|');
  if (pos) {
    str_priority = string_strndup(string, pos - string);
    if (str_priority) {
      error = NULL;
      number = strtol(str_priority, &error, 10);
      if (error && !error[0]) {
        if (priority)
          *priority = number;
        if (name)
          *name = pos + 1;
      }
      free(str_priority);
    }
  }
}


x86 assembly (clang, -O0):
<hook_get_priority_and_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1169 <hook_get_priority_and_name+0x29>
mov    -0x10(%rbp),%rax
movl   $0x3e8,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     117f <hook_get_priority_and_name+0x3f>
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x7c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     123b <hook_get_priority_and_name+0xfb>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1060 <string_strndup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1236 <hook_get_priority_and_name+0xf6>
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     122d <hook_get_priority_and_name+0xed>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
jne    122d <hook_get_priority_and_name+0xed>
cmpq   $0x0,-0x10(%rbp)
je     120e <hook_get_priority_and_name+0xce>
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1228 <hook_get_priority_and_name+0xe8>
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    122d <hook_get_priority_and_name+0xed>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    123b <hook_get_priority_and_name+0xfb>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hook_get_priority_and_name>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rsi,%rsi
je     1162 <hook_get_priority_and_name+0x22>
movl   $0x3e8,(%r15)
test   %r14,%r14
je     116a <hook_get_priority_and_name+0x2a>
mov    %rbx,(%r14)
mov    %rbx,%rdi
mov    $0x7c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e7 <hook_get_priority_and_name+0xa7>
mov    %rax,%r13
mov    %r13d,%esi
sub    %ebx,%esi
mov    %rbx,%rdi
call   1060 <string_strndup@plt>
test   %rax,%rax
je     11e7 <hook_get_priority_and_name+0xa7>
mov    %rax,%r12
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
je     11d2 <hook_get_priority_and_name+0x92>
cmpb   $0x0,(%rcx)
jne    11d2 <hook_get_priority_and_name+0x92>
test   %r15,%r15
je     11c6 <hook_get_priority_and_name+0x86>
mov    %eax,(%r15)
test   %r14,%r14
je     11d2 <hook_get_priority_and_name+0x92>
add    $0x1,%r13
mov    %r13,(%r14)
mov    %r12,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hook_get_priority_and_name(i8* %0, i32* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8** %2, i8*** %6
%11 = load i32*, i32** %5
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i32*, i32** %5
store i32 1000, i32* %14
br label %15
15: ; preds = %13, %3
%16 = load i8**, i8*** %6
%17 = icmp ne i8** %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i8**, i8*** %6
store i8* %19, i8** %20
br label %21
21: ; preds = %18, %15
%22 = load i8*, i8** %4
%23 = call i8* @strchr(i8* %22, i8 signext 124)
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %66
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = load i8*, i8** %7
%29 = load i8*, i8** %4
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i8* @string_strndup(i8* %27, i32 %33)
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %65
37: ; preds = %26
store i8* null, i8** %9
%38 = load i8*, i8** %8
%39 = call i64 @strtol(i8* %38, i8** %9, i32 10)
store i64 %39, i64* %10
%40 = load i8*, i8** %9
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %62
42: ; preds = %37
%43 = load i8*, i8** %9
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 0
br i1 %46, label %62, label %47
47: ; preds = %42
%48 = load i32*, i32** %5
%49 = icmp ne i32* %48, null
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i64, i64* %10
%52 = trunc i64 %51 to i32
%53 = load i32*, i32** %5
store i32 %52, i32* %53
br label %54
54: ; preds = %50, %47
%55 = load i8**, i8*** %6
%56 = icmp ne i8** %55, null
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i64 1
%60 = load i8**, i8*** %6
store i8* %59, i8** %60
br label %61
61: ; preds = %57, %54
br label %62
62: ; preds = %61, %42, %37
%63 = load i8*, i8** %8
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %62, %26
br label %66
66: ; preds = %65, %21
ret void
}

LLVM IR (-O2):
define void @hook_get_priority_and_name(i8* %0, i32* writeonly %1, i8** writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = icmp eq i32* %1, null
br i1 %6, label %8, label %7
7: ; preds = %3
store i32 1000, i32* %1
br label %8
8: ; preds = %7, %3
%9 = icmp eq i8** %2, null
br i1 %9, label %11, label %10
10: ; preds = %8
store i8* %0, i8** %2
br label %11
11: ; preds = %10, %8
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 124)
%13 = icmp eq i8* %12, null
br i1 %13, label %36, label %14
14: ; preds = %11
%15 = ptrtoint i8* %12 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = tail call i8* @string_strndup(i8* %0, i32 %18)
%20 = icmp eq i8* %19, null
br i1 %20, label %36, label %21
21: ; preds = %14
store i8* null, i8** %4
%22 = call i64 @strtol(i8* %19, i8** %4, i32 10)
%23 = load i8*, i8** %4
%24 = icmp eq i8* %23, null
br i1 %24, label %34, label %25
25: ; preds = %21
%26 = load i8, i8* %23
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25
br i1 %6, label %31, label %29
29: ; preds = %28
%30 = trunc i64 %22 to i32
store i32 %30, i32* %1
br label %31
31: ; preds = %29, %28
br i1 %9, label %34, label %32
32: ; preds = %31
%33 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %33, i8** %2
br label %34
34: ; preds = %31, %32, %25, %21
%35 = tail call i32 @free(i8* %19)
br label %36
36: ; preds = %14, %34, %11
ret void
}