#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 strlen(char *);
int /*<<< orphan*/ zlog_warning(char *, int, char *);
char *zstr_trim(char *);
int _parse_line(char *filename, char *line_buf, int line_number, char **name,
                char **value) {
  char *np;
  char *vp;
  int len;
  np = zstr_trim(line_buf);
  if (*np == 0) {
    return 0;
  }
  if (*np == '#') {
    return 0;
  }
  if (*np == '[') {
    len = strlen(np);
    if (np[len - 1] == ']') {
      np[len - 1] = 0;
      np++;
      np = zstr_trim(np);
      *name = np;
      *value = 0;
      return 2;
    }
  }
  vp = strchr(np, '=');
  if (!vp) {
    zlog_warning("zdict_load_file: missing '=' at line %d, file %s",
                 line_number, filename);
    return 0;
  }
  *vp = 0;
  vp++;
  *name = zstr_trim(np);
  *value = zstr_trim(vp);
  return 1;
}


x86 assembly (clang, -O0):
<_parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <zstr_trim@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1184 <_parse_line+0x44>
movl   $0x0,-0x4(%rbp)
jmp    12a3 <_parse_line+0x163>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11a0 <_parse_line+0x60>
movl   $0x0,-0x4(%rbp)
jmp    12a3 <_parse_line+0x163>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1227 <_parse_line+0xe7>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    1222 <_parse_line+0xe2>
mov    -0x38(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <zstr_trim@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    12a3 <_parse_line+0x163>
jmp    1227 <_parse_line+0xe7>
mov    -0x38(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1263 <_parse_line+0x123>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xdae(%rip),%rdi
call   1030 <zlog_warning@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a3 <_parse_line+0x163>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <zstr_trim@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
call   1060 <zstr_trim@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rdi,%r13
mov    %rsi,%rdi
call   1060 <zstr_trim@plt>
mov    %rax,%rbx
mov    (%rax),%al
xor    %ebp,%ebp
test   %al,%al
je     1200 <_parse_line+0xc0>
cmp    $0x23,%al
je     1200 <_parse_line+0xc0>
cmp    $0x5b,%al
jne    11ad <_parse_line+0x6d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x5d,-0x1(%rax,%rbx,1)
jne    11ad <_parse_line+0x6d>
movb   $0x0,-0x1(%rbx,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1060 <zstr_trim@plt>
mov    %rax,(%r15)
movq   $0x0,(%r14)
mov    $0x2,%ebp
jmp    1200 <_parse_line+0xc0>
mov    %r14,(%rsp)
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11ee <_parse_line+0xae>
mov    %rax,%r14
movb   $0x0,(%rax)
add    $0x1,%r14
mov    %rbx,%rdi
call   1060 <zstr_trim@plt>
mov    %rax,(%r15)
mov    %r14,%rdi
call   1060 <zstr_trim@plt>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
mov    $0x1,%ebp
jmp    1200 <_parse_line+0xc0>
lea    0xe0b(%rip),%rdi
mov    %r12d,%esi
mov    %r13,%rdx
call   1030 <zlog_warning@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"zdict_load_file: missing '=' at line %d, file %s\00"
define i32 @_parse_line(i8* %0, i8* %1, i32 %2, i8** %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8** %3, i8*** %10
store i8** %4, i8*** %11
%15 = load i8*, i8** %8
%16 = call i8* @zstr_trim(i8* %15)
store i8* %16, i8** %12
%17 = load i8*, i8** %12
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %5
store i32 0, i32* %6
br label %77
22: ; preds = %5
%23 = load i8*, i8** %12
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 35
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %6
br label %77
28: ; preds = %22
%29 = load i8*, i8** %12
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 91
br i1 %32, label %33, label %58
33: ; preds = %28
%34 = load i8*, i8** %12
%35 = call i32 @strlen(i8* %34)
store i32 %35, i32* %14
%36 = load i8*, i8** %12
%37 = load i32, i32* %14
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 93
br i1 %43, label %44, label %57
44: ; preds = %33
%45 = load i8*, i8** %12
%46 = load i32, i32* %14
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
store i8 0, i8* %49
%50 = load i8*, i8** %12
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %12
%52 = load i8*, i8** %12
%53 = call i8* @zstr_trim(i8* %52)
store i8* %53, i8** %12
%54 = load i8*, i8** %12
%55 = load i8**, i8*** %10
store i8* %54, i8** %55
%56 = load i8**, i8*** %11
store i8* null, i8** %56
store i32 2, i32* %6
br label %77
57: ; preds = %33
br label %58
58: ; preds = %57, %28
%59 = load i8*, i8** %12
%60 = call i8* @strchr(i8* %59, i8 signext 61)
store i8* %60, i8** %13
%61 = load i8*, i8** %13
%62 = icmp ne i8* %61, null
br i1 %62, label %67, label %63
63: ; preds = %58
%64 = load i32, i32* %9
%65 = load i8*, i8** %7
%66 = call i32 @zlog_warning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %64, i8* %65)
store i32 0, i32* %6
br label %77
67: ; preds = %58
%68 = load i8*, i8** %13
store i8 0, i8* %68
%69 = load i8*, i8** %13
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %13
%71 = load i8*, i8** %12
%72 = call i8* @zstr_trim(i8* %71)
%73 = load i8**, i8*** %10
store i8* %72, i8** %73
%74 = load i8*, i8** %13
%75 = call i8* @zstr_trim(i8* %74)
%76 = load i8**, i8*** %11
store i8* %75, i8** %76
store i32 1, i32* %6
br label %77
77: ; preds = %67, %63, %44, %27, %21
%78 = load i32, i32* %6
ret i32 %78
}

LLVM IR (-O2):
@.str = [49 x i8] c"zdict_load_file: missing '=' at line %d, file %s\00"
define i32 @_parse_line(i8* %0, i8* %1, i32 %2, i8** nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = tail call i8* @zstr_trim(i8* %1)
%7 = load i8, i8* %6
switch i8 %7, label %18 [
i8 0, label %27
i8 35, label %27
i8 91, label %8
]
8: ; preds = %5
%9 = tail call i32 @strlen(i8* %6)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %6, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 93
br i1 %14, label %15, label %18
15: ; preds = %8
store i8 0, i8* %12
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = tail call i8* @zstr_trim(i8* %16)
store i8* %17, i8** %3
store i8* null, i8** %4
br label %27
18: ; preds = %5, %8
%19 = tail call i8* @strchr(i8* %6, i8 signext 61)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @zlog_warning(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %0)
br label %27
23: ; preds = %18
store i8 0, i8* %19
%24 = getelementptr inbounds i8, i8* %19, i64 1
%25 = tail call i8* @zstr_trim(i8* %6)
store i8* %25, i8** %3
%26 = tail call i8* @zstr_trim(i8* %24)
store i8* %26, i8** %4
br label %27
27: ; preds = %5, %5, %23, %21, %15
%28 = phi i32 [ 2, %15 ], [ 1, %23 ], [ 0, %21 ], [ 0, %5 ], [ 0, %5 ]
ret i32 %28
}