#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 *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
void parse_kv(char *line, char key[64], char value[1024]) {
  char *end = strchr(line, '\n');
  char *c = strchr(line, '=');
  if (*line == '[')
    line++;
  if (*(--end) == '\r')
    *end-- = '\0';
  if (*end == ']')
    *end-- = '\0';
  if (c) {
    *(c - 1) = '\0';
    strcpy(key, line);
    strcpy(value, c + 2);
  } else {
    strcpy(key, line);
  }
}


x86 assembly (clang, -O0):
<parse_kv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1174 <parse_kv+0x54>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0xd,%eax
jne    11a2 <parse_kv+0x82>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
jne    11c4 <parse_kv+0xa4>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     11fa <parse_kv+0xda>
mov    -0x28(%rbp),%rax
movb   $0x0,-0x1(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
jmp    1207 <parse_kv+0xe7>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_kv>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
xor    %ecx,%ecx
cmpb   $0x5b,0x0(%r13)
mov    %rax,%r12
sete   %cl
mov    -0x1(%rbx),%al
cmp    $0xd,%al
jne    1171 <parse_kv+0x51>
movb   $0x0,-0x1(%rbx)
mov    -0x2(%rbx),%al
add    $0xfffffffffffffffe,%rbx
cmp    $0x5d,%al
je     1179 <parse_kv+0x59>
jmp    117c <parse_kv+0x5c>
add    $0xffffffffffffffff,%rbx
cmp    $0x5d,%al
jne    117c <parse_kv+0x5c>
movb   $0x0,(%rbx)
add    %rcx,%r13
test   %r12,%r12
je     11a1 <parse_kv+0x81>
movb   $0x0,-0x1(%r12)
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
add    $0x2,%r12
mov    %r14,%rdi
mov    %r12,%rsi
jmp    11a7 <parse_kv+0x87>
mov    %r15,%rdi
mov    %r13,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
define void @parse_kv(i8* %0, i8* %1, i8* %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 91
%8 = zext i1 %7 to i64
%9 = getelementptr i8, i8* %0, i64 %8
%10 = getelementptr inbounds i8, i8* %4, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 13
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = getelementptr inbounds i8, i8* %4, i64 -2
store i8 0, i8* %10
%15 = load i8, i8* %14
br label %16
16: ; preds = %13, %3
%17 = phi i8 [ %15, %13 ], [ %11, %3 ]
%18 = phi i8* [ %14, %13 ], [ %10, %3 ]
%19 = icmp eq i8 %17, 93
br i1 %19, label %20, label %21
20: ; preds = %16
store i8 0, i8* %18
br label %21
21: ; preds = %20, %16
%22 = icmp eq i8* %5, null
br i1 %22, label %28, label %23
23: ; preds = %21
%24 = getelementptr inbounds i8, i8* %5, i64 -1
store i8 0, i8* %24
%25 = tail call i32 @strcpy(i8* %1, i8* %9)
%26 = getelementptr inbounds i8, i8* %5, i64 2
%27 = tail call i32 @strcpy(i8* %2, i8* %26)
br label %30
28: ; preds = %21
%29 = tail call i32 @strcpy(i8* %1, i8* %9)
br label %30
30: ; preds = %28, %23
ret void
}