#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 */
struct ini_file {
  int dummy;
};

/* Variables and functions */
int ini__append_new_key_value(struct ini_file *, char *, char *);
char *ini__to_lower(int /*<<< orphan*/);
char *ini__trim_left(char *);
int /*<<< orphan*/ ini__trim_right(char *);
char *strchr(char *, char);
int ini__parse_key_value(struct ini_file *self, char *str) {
  char *eq = strchr(str, '=');
  if (!eq)
    return -1;
  *eq = '\0';
  char *value = ini__trim_left(eq + 1);
  char *key = ini__to_lower(ini__trim_right(str));
  return ini__append_new_key_value(self, key, value);
}


x86 assembly (clang, -O0):
<ini__parse_key_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1189 <ini__parse_key_value+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <ini__parse_key_value+0x79>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1070 <ini__trim_left@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ini__trim_right@plt>
mov    %eax,%edi
call   1060 <ini__to_lower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <ini__append_new_key_value@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ini__parse_key_value>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a1 <ini__parse_key_value+0x51>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
call   1070 <ini__trim_left@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <ini__trim_right@plt>
mov    %eax,%edi
call   1060 <ini__to_lower@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <ini__append_new_key_value@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ini_file = type { i32 }
define i32 @ini__parse_key_value(%struct.ini_file* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.ini_file*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.ini_file* %0, %struct.ini_file** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i8* @strchr(i8* %9, i8 signext 61)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 -1, i32* %3
br label %26
14: ; preds = %2
%15 = load i8*, i8** %6
store i8 0, i8* %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i8* @ini__trim_left(i8* %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %5
%20 = call i32 @ini__trim_right(i8* %19)
%21 = call i8* @ini__to_lower(i32 %20)
store i8* %21, i8** %8
%22 = load %struct.ini_file*, %struct.ini_file** %4
%23 = load i8*, i8** %8
%24 = load i8*, i8** %7
%25 = call i32 @ini__append_new_key_value(%struct.ini_file* %22, i8* %23, i8* %24)
store i32 %25, i32* %3
br label %26
26: ; preds = %14, %13
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.ini_file = type { i32 }
define i32 @ini__parse_key_value(%struct.ini_file* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 61)
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2
store i8 0, i8* %3
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = tail call i8* @ini__trim_left(i8* %6)
%8 = tail call i32 @ini__trim_right(i8* %1)
%9 = tail call i8* @ini__to_lower(i32 %8)
%10 = tail call i32 @ini__append_new_key_value(%struct.ini_file* %0, i8* %9, i8* %7)
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ %10, %5 ], [ -1, %2 ]
ret i32 %12
}