// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
xorl %ebx, %ebx
movw %bx, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movw %bx, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0x90(%rsp), %rdi
movl $0xc8, %esi
movq %r12, %rdx
callq 0xd1e0
testq %rax, %rax
je 0x1399b
leaq 0x90(%rsp), %rbp
movabsq $0x100000600, %r13      # imm = 0x100000600
xorl %ebx, %ebx
movq %r15, (%rsp)
incl %ebx
movq %rbp, %rdi
callq 0x139b3
leaq 0x92(%rsp), %rax
leaq 0x91(%rsp), %r14
movzbl -0x1(%r14), %ecx
cmpq $0x3b, %rcx
ja 0x138bb
btq %rcx, %r13
jae 0x13891
incq %r14
incq %rax
jmp 0x13878
movabsq $0x800000800000001, %rdx # imm = 0x800000800000001
btq %rcx, %rdx
jae 0x138bb
movq %rbp, %rdi
movl $0xc8, %esi
movq %r12, %rdx
callq 0xd1e0
testq %rax, %rax
jne 0x1385e
jmp 0x139af
cmpl $0x5b, %ecx
jne 0x138db
movb (%r14), %cl
testb %cl, %cl
je 0x13986
cmpb $0x5d, %cl
je 0x13961
movb (%rax), %cl
incq %rax
jmp 0x138c3
leaq -0x1(%r14), %r15
cmpb $0x3a, %cl
je 0x138fb
movzbl %cl, %eax
cmpl $0x3d, %eax
je 0x138fb
movb (%r14), %cl
incq %r14
testb %cl, %cl
jne 0x138df
jmp 0x1398f
xorl %eax, %eax
movb %al, -0x1(%r14)
movq %r15, %rdi
callq 0x139b3
movl $0x31, %edx
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xd090
xorl %eax, %eax
movb %al, 0x41(%rsp)
movq %r14, %rdi
callq 0x139b3
movq (%rsp), %r15
movzbl (%r14), %eax
cmpq $0x20, %rax
ja 0x13942
btq %rax, %r13
jae 0x13942
incq %r14
jmp 0x1392d
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rcx
callq *0x8(%rsp)
cmpl $0x1, %eax
je 0x138a1
jmp 0x1399b
xorl %ecx, %ecx
movb %cl, -0x1(%rax)
movl $0x31, %edx
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0xd090
xorl %eax, %eax
movb %al, 0x81(%rsp)
jmp 0x138a1
leaq 0x90ab(%rip), %rdi      # 0x1ca38
jmp 0x13996
leaq 0x9086(%rip), %rdi      # 0x1ca1c
callq 0xd0c0
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x1399b