#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 */
char *semanage_split_on_space(char const *);
char *strdup(char *);
int strlen(char const *);
char *strstr(char const *, char const *);
char *semanage_split(const char *str, const char *delim) {
  char *retval;
  if (!str)
    return NULL;
  if (!delim || !(*delim))
    return semanage_split_on_space(str);
  retval = strstr(str, delim);
  if (retval == NULL)
    return NULL;
  return strdup(retval + strlen(delim));
}


x86 assembly (clang, -O0):
<semanage_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1168 <semanage_split+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11de <semanage_split+0x9e>
cmpq   $0x0,-0x18(%rbp)
je     1180 <semanage_split+0x40>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1192 <semanage_split+0x52>
mov    -0x10(%rbp),%rdi
call   1040 <semanage_split_on_space@plt>
mov    %rax,-0x8(%rbp)
jmp    11de <semanage_split+0x9e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bb <semanage_split+0x7b>
movq   $0x0,-0x8(%rbp)
jmp    11de <semanage_split+0x9e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<semanage_split>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1182 <semanage_split+0x42>
mov    %rsi,%rbx
test   %rsi,%rsi
je     118c <semanage_split+0x4c>
cmpb   $0x0,(%rbx)
je     118c <semanage_split+0x4c>
mov    %rbx,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1182 <semanage_split+0x42>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strdup@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <semanage_split_on_space@plt>

LLVM IR (-O0):
define i8* @semanage_split(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %3
br label %34
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13, %10
%18 = load i8*, i8** %4
%19 = call i8* @semanage_split_on_space(i8* %18)
store i8* %19, i8** %3
br label %34
20: ; preds = %13
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i8* @strstr(i8* %21, i8* %22)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %20
store i8* null, i8** %3
br label %34
27: ; preds = %20
%28 = load i8*, i8** %6
%29 = load i8*, i8** %5
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = call i8* @strdup(i8* %32)
store i8* %33, i8** %3
br label %34
34: ; preds = %27, %26, %17, %9
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @semanage_split(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = icmp eq i8* %1, null
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6, %4
%10 = tail call i8* @semanage_split_on_space(i8* %0)
br label %19
11: ; preds = %6
%12 = tail call i8* @strstr(i8* %0, i8* %1)
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = tail call i32 @strlen(i8* %1)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %12, i64 %16
%18 = tail call i8* @strdup(i8* %17)
br label %19
19: ; preds = %11, %2, %14, %9
%20 = phi i8* [ %18, %14 ], [ %10, %9 ], [ null, %2 ], [ null, %11 ]
ret i8* %20
}