#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*/ strip_lead(char **);
int split_keyval(char *keyval, char **key_ptr, char **val_ptr) {
  char *key = keyval;
  char *val = keyval;
  while ((*val != ':') && (*val != '\0'))
    val++;
  if (*val == '\0')
    return 1;
  *val = '\0';
  val++;
  strip_lead(&key);
  if (*key == '\0')
    return 1;
  strip_lead(&val);
  if (*val == '\0')
    return 1;
  *key_ptr = key;
  *val_ptr = val;
  return 0;
}


x86 assembly (clang, -O0):
<split_keyval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x31(%rbp)
je     1159 <split_keyval+0x49>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1169 <split_keyval+0x59>
jmp    117a <split_keyval+0x6a>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1134 <split_keyval+0x24>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1196 <split_keyval+0x86>
movl   $0x1,-0x4(%rbp)
jmp    1210 <split_keyval+0x100>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <strip_lead@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ce <split_keyval+0xbe>
movl   $0x1,-0x4(%rbp)
jmp    1210 <split_keyval+0x100>
lea    -0x30(%rbp),%rdi
call   1030 <strip_lead@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11f3 <split_keyval+0xe3>
movl   $0x1,-0x4(%rbp)
jmp    1210 <split_keyval+0x100>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_keyval>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rdi
movzbl -0x1(%rdi),%eax
test   %al,%al
je     1181 <split_keyval+0x71>
cmp    $0x3a,%al
jne    1130 <split_keyval+0x20>
movb   $0x0,-0x1(%rdi)
mov    %rdi,0x8(%rsp)
mov    %rsp,%rdi
call   1030 <strip_lead@plt>
mov    (%rsp),%rax
mov    $0x1,%ebp
cmpb   $0x0,(%rax)
je     1186 <split_keyval+0x76>
lea    0x8(%rsp),%rdi
call   1030 <strip_lead@plt>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1186 <split_keyval+0x76>
mov    (%rsp),%rcx
mov    %rcx,(%rbx)
mov    %rax,(%r14)
xor    %ebp,%ebp
jmp    1186 <split_keyval+0x76>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @split_keyval(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i8*, i8** %5
store i8* %10, i8** %8
%11 = load i8*, i8** %5
store i8* %11, i8** %9
br label %12
12: ; preds = %24, %3
%13 = load i8*, i8** %9
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 58
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %9
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ false, %12 ], [ %21, %17 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %9
br label %12
27: ; preds = %22
%28 = load i8*, i8** %9
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 1, i32* %4
br label %55
33: ; preds = %27
%34 = load i8*, i8** %9
store i8 0, i8* %34
%35 = load i8*, i8** %9
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %9
%37 = call i32 @strip_lead(i8** %8)
%38 = load i8*, i8** %8
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %33
store i32 1, i32* %4
br label %55
43: ; preds = %33
%44 = call i32 @strip_lead(i8** %9)
%45 = load i8*, i8** %9
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %43
store i32 1, i32* %4
br label %55
50: ; preds = %43
%51 = load i8*, i8** %8
%52 = load i8**, i8*** %6
store i8* %51, i8** %52
%53 = load i8*, i8** %9
%54 = load i8**, i8*** %7
store i8* %53, i8** %54
store i32 0, i32* %4
br label %55
55: ; preds = %50, %49, %42, %32
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
define i32 @split_keyval(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i8** %4 to i8*
store i8* %0, i8** %4
%7 = bitcast i8** %5 to i8*
br label %8
8: ; preds = %11, %3
%9 = phi i8* [ %0, %3 ], [ %12, %11 ]
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 0, label %26
i8 58, label %13
]
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
13: ; preds = %8
store i8 0, i8* %9
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %14, i8** %5
%15 = call i32 @strip_lead(i8** %4)
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %13
%20 = call i32 @strip_lead(i8** %5)
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = load i8*, i8** %4
store i8* %25, i8** %1
store i8* %21, i8** %2
br label %26
26: ; preds = %8, %19, %13, %24
%27 = phi i32 [ 0, %24 ], [ 1, %13 ], [ 1, %19 ], [ 1, %8 ]
ret i32 %27
}