#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*/ ltrim(char *);
char *rtrim(int /*<<< orphan*/);
char *strchr(char *, char);
scalar_t__ strlen(char *);
int split_cfg_line(char *line, char **name, char **value) {
  char *p = NULL;
  if ((p = strchr(line, '#')) != NULL) {
    *p = '\0';
  }
  if ((p = strchr(line, '=')) == NULL) {
    return -1;
  }
  *value = rtrim(ltrim(p + 1));
  *p = '\0';
  *name = rtrim(ltrim(line));
  return (strlen(*name) != 0) ? 0 : -1;
}


x86 assembly (clang, -O0):
<split_cfg_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     117f <split_cfg_line+0x3f>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11a7 <split_cfg_line+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    1206 <split_cfg_line+0xc6>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1060 <ltrim@plt>
mov    %eax,%edi
call   1050 <rtrim@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1060 <ltrim@plt>
mov    %eax,%edi
call   1050 <rtrim@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_cfg_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x23,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1153 <split_cfg_line+0x23>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     119a <split_cfg_line+0x6a>
mov    %rax,%rbx
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <ltrim@plt>
mov    %eax,%edi
call   1040 <rtrim@plt>
mov    %rax,(%r15)
movb   $0x0,(%rbx)
mov    %r12,%rdi
call   1050 <ltrim@plt>
mov    %eax,%edi
call   1040 <rtrim@plt>
mov    %rax,(%r14)
cmpb   $0x1,(%rax)
sbb    %eax,%eax
jmp    119f <split_cfg_line+0x6f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @split_cfg_line(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
store i8* null, i8** %8
%9 = load i8*, i8** %5
%10 = call i8* @strchr(i8* %9, i8 signext 35)
store i8* %10, i8** %8
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i8*, i8** %8
store i8 0, i8* %13
br label %14
14: ; preds = %12, %3
%15 = load i8*, i8** %5
%16 = call i8* @strchr(i8* %15, i8 signext 61)
store i8* %16, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 -1, i32* %4
br label %36
19: ; preds = %14
%20 = load i8*, i8** %8
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i32 @ltrim(i8* %21)
%23 = call i8* @rtrim(i32 %22)
%24 = load i8**, i8*** %7
store i8* %23, i8** %24
%25 = load i8*, i8** %8
store i8 0, i8* %25
%26 = load i8*, i8** %5
%27 = call i32 @ltrim(i8* %26)
%28 = call i8* @rtrim(i32 %27)
%29 = load i8**, i8*** %6
store i8* %28, i8** %29
%30 = load i8**, i8*** %6
%31 = load i8*, i8** %30
%32 = call i64 @strlen(i8* %31)
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 0, i32 -1
store i32 %35, i32* %4
br label %36
36: ; preds = %19, %18
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @split_cfg_line(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 35)
%5 = icmp eq i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %3
store i8 0, i8* %4
br label %7
7: ; preds = %6, %3
%8 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%9 = icmp eq i8* %8, null
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = tail call i32 @ltrim(i8* %11)
%13 = tail call i8* @rtrim(i32 %12)
store i8* %13, i8** %2
store i8 0, i8* %8
%14 = tail call i32 @ltrim(i8* %0)
%15 = tail call i8* @rtrim(i32 %14)
store i8* %15, i8** %1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
%18 = sext i1 %17 to i32
br label %19
19: ; preds = %7, %10
%20 = phi i32 [ %18, %10 ], [ -1, %7 ]
ret i32 %20
}