#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*/ __split_attr(char *, char **, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
int split_key_value(char *nameattr, char **namep, char **valuep) {
  char *s = strdup(nameattr);
  if (!__split_attr(nameattr, namep, valuep)) {
    fprintf(stderr, "Cannot parse attribute assignment %s\n", s);
    free(s);
    return 0;
  }
  if (**valuep == '\0')
    *valuep = NULL;
  free(s);
  return 1;
}


x86 assembly (clang, -O0):
<split_key_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <__split_attr@plt>
cmp    $0x0,%eax
jne    11a9 <split_key_value+0x69>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe71(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <split_key_value+0x97>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c7 <split_key_value+0x87>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_key_value>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1060 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1050 <__split_attr@plt>
test   %eax,%eax
je     1180 <split_key_value+0x40>
mov    (%r15),%rax
mov    $0x1,%ebp
cmpb   $0x0,(%rax)
jne    119a <split_key_value+0x5a>
movq   $0x0,(%r15)
jmp    119a <split_key_value+0x5a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Cannot parse attribute assignment %s\0A\00"
define i32 @split_key_value(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i8*, i8** %5
%10 = call i8* @strdup(i8* %9)
store i8* %10, i8** %8
%11 = load i8*, i8** %5
%12 = load i8**, i8*** %6
%13 = load i8**, i8*** %7
%14 = call i32 @__split_attr(i8* %11, i8** %12, i8** %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %8
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %8
%21 = call i32 @free(i8* %20)
store i32 0, i32* %4
br label %33
22: ; preds = %3
%23 = load i8**, i8*** %7
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i8**, i8*** %7
store i8* null, i8** %29
br label %30
30: ; preds = %28, %22
%31 = load i8*, i8** %8
%32 = call i32 @free(i8* %31)
store i32 1, i32* %4
br label %33
33: ; preds = %30, %16
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Cannot parse attribute assignment %s\0A\00"
define i32 @split_key_value(i8* %0, i8** %1, i8** %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i32 @__split_attr(i8* %0, i8** %1, i8** %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %15
10: ; preds = %3
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* null, i8** %2
br label %15
15: ; preds = %10, %14, %7
%16 = phi i32 [ 0, %7 ], [ 1, %14 ], [ 1, %10 ]
%17 = tail call i32 @free(i8* %4)
ret i32 %16
}