// File: /workspace/github_c_makefile_star2_O2/intel[P]pf-bb-config/cfg_reader/cfg_reader.c
// Function: cfg_parse_contents
int
cfg_parse_contents(void *contents, cfg_handler handler, void *user)
{

	char line[CFG_MAX_LINE_LEN];
	int max_line_len = CFG_MAX_LINE_LEN;

	char section[MAX_SECTION_LEN] = "";
	char name[MAX_NAME_LEN] = "";

	char *left;
	char *right;
	char *cur_name;
	char *value;
	int line_num = 0;
	int error_line_index = 0;

	while (fgets(line, max_line_len, contents) != NULL) {

		line_num++;
		left = line;
		/* skip UTF-8 BOM char sequence if it exists */
		left = (line_num == 1 && left[0] == 0xEF && left[1] == 0xBB
				&& left[2] == 0xBF) ? (left + 3) : left;

		left = lstrip(rstrip(left));

		if (*left == ';' || *left == '#') {
			/* skip start-of-line comment */
			continue;
		} else if (*left == '[') {
			/* parse "section" */
			right = jump_to_targets_location(left + 1, "]");
			if (*right == ']') {
				*right = '\0';
				strncpy(section, left + 1, MAX_SECTION_LEN - 1);
				section[MAX_SECTION_LEN - 1] = '\0';
			} else {
				printf("error, no [ exists\n");
				error_line_index = line_num;
				break;
			}
		} else if (*left) {
			right = jump_to_targets_location(left, "=:");
			if (*right == '=' || *right == ':') {
				/* parse "name" and "value" */
				*right = '\0';
				cur_name = rstrip(left);
				strncpy(name, cur_name, MAX_NAME_LEN - 1);
				name[MAX_NAME_LEN - 1] = '\0';
				value = right + 1;
				value = lstrip(rstrip(value));
				if (handler(user, section, name, value) != 1) {
					error_line_index = line_num;
					break;
				}
			} else {
				printf("error, no \":\" or \"=\" exists\n");
				error_line_index = line_num;
				break;
			}
		}
	}

	return error_line_index;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdx, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rdi, %r12
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r13
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
andw $0x0, 0x30(%r13)
movaps %xmm0, (%r13)
leaq 0x10(%rsp), %rax
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
andw $0x0, 0x30(%rax)
pushq $0x1
popq %rbx
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movl $0xc8, %esi
movq %r12, %rdx
callq 0xd1f0
testq %rax, %rax
je 0x136bb
movq %r14, %rdi
callq 0x1370a
movq %r14, %rdi
callq 0x136e8
movq %rax, %r15
movzbl (%rax), %eax
testl %eax, %eax
je 0x136b4
cmpl $0x23, %eax
je 0x136b4
cmpl $0x3b, %eax
je 0x136b4
cmpl $0x5b, %eax
jne 0x13640
incq %r15
movq %r15, %rdi
leaq 0x93c7(%rip), %rsi      # 0x1c9dc
callq 0x1373a
cmpb $0x5d, (%rax)
jne 0x136bf
xorl %ebp, %ebp
movb %bpl, (%rax)
movq %r13, %rdi
movq %r15, %rsi
pushq $0x31
popq %rdx
callq 0xd090
movb %bpl, 0x81(%rsp)
jmp 0x136b4
movq %r15, %rdi
leaq 0x9394(%rip), %rsi      # 0x1c9de
callq 0x1373a
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x3d, %eax
je 0x1365f
cmpl $0x3a, %eax
jne 0x136c8
xorl %eax, %eax
movb %al, (%r13)
movq %r15, %rdi
callq 0x1370a
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
pushq $0x31
popq %rdx
callq 0xd090
xorl %eax, %eax
movb %al, 0x41(%rsp)
incq %r13
movq %r13, %rdi
callq 0x1370a
movq %r13, %rdi
callq 0x136e8
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %r13
movq %r13, %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq *(%rsp)
cmpl $0x1, %eax
jne 0x136d4
incl %ebx
jmp 0x135ba
xorl %ebx, %ebx
jmp 0x136d4
leaq 0x9337(%rip), %rdi      # 0x1c9fd
jmp 0x136cf
leaq 0x9312(%rip), %rdi      # 0x1c9e1
callq 0xd0c0
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq