// File: /workspace/github_c_makefile_star2_O1/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 $0x168, %rsp            # imm = 0x168
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
xorl %ebx, %ebx
movw %bx, 0x90(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movw %bx, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
leaq 0xa0(%rsp), %rdi
movl $0xc8, %esi
movq %r14, %rdx
callq 0xd1f0
testq %rax, %rax
je 0x13b70
leaq 0xa1(%rsp), %rbp
leaq 0xa0(%rsp), %r15
movabsq $0x100000600, %r12      # imm = 0x100000600
xorl %ebx, %ebx
movq %r14, 0x8(%rsp)
incl %ebx
movq %r15, %r13
movq %r15, %rdi
callq 0x13b84
movq %rbp, %r15
movzbl -0x1(%r15), %eax
cmpq $0x3b, %rax
ja 0x13a3a
btq %rax, %r12
jae 0x13a26
incq %r15
jmp 0x13a10
movabsq $0x800000800000001, %rcx # imm = 0x800000800000001
btq %rax, %rcx
jb 0x13b3b
cmpl $0x5b, %eax
jne 0x13a90
movb (%r15), %cl
movq %r15, %rax
testb %cl, %cl
je 0x13a5b
movq %r15, %rax
cmpb $0x5d, %cl
je 0x13a5b
movb 0x1(%rax), %cl
incq %rax
testb %cl, %cl
jne 0x13a4c
cmpb $0x5d, (%rax)
jne 0x13b5b
xorl %ebp, %ebp
movb %bpl, (%rax)
movl $0x31, %edx
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0xd090
movb %bpl, 0x91(%rsp)
leaq 0xa1(%rsp), %rbp
jmp 0x13b3b
decq %r15
movq %r15, %r14
leaq 0x8f56(%rip), %rbp      # 0x1c9f3
movsbl %al, %esi
movl $0x3, %edx
movq %rbp, %rdi
callq 0xd1d0
testq %rax, %rax
jne 0x13abd
movb 0x1(%r14), %al
incq %r14
testb %al, %al
jne 0x13a9d
movzbl (%r14), %eax
cmpl $0x3d, %eax
je 0x13acf
cmpl $0x3a, %eax
jne 0x13b64
xorl %ebp, %ebp
movb %bpl, (%r14)
movq %r15, %rdi
callq 0x13b84
movl $0x31, %edx
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0xd090
movb %bpl, 0x51(%rsp)
leaq 0xa1(%rsp), %rbp
incq %r14
movq %r14, %rdi
callq 0x13b84
movzbl (%r14), %eax
cmpq $0x20, %rax
ja 0x13b1b
btq %rax, %r12
jae 0x13b1b
incq %r14
jmp 0x13b06
movq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rcx
callq *0x10(%rsp)
cmpl $0x1, %eax
movq 0x8(%rsp), %r14
jne 0x13b70
movq %r13, %r15
movq %r13, %rdi
movl $0xc8, %esi
movq %r14, %rdx
callq 0xd1f0
testq %rax, %rax
jne 0x13a00
xorl %ebx, %ebx
jmp 0x13b70
leaq 0x8eb0(%rip), %rdi      # 0x1ca12
jmp 0x13b6b
leaq 0x8e8b(%rip), %rdi      # 0x1c9f6
callq 0xd0c0
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq