// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0xc8, -0xe4(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movl $0x32, %edx
callq 0xd170
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
movl $0x32, %edx
callq 0xd170
movl $0x0, -0x184(%rbp)
movl $0x0, -0x188(%rbp)
leaq -0xe0(%rbp), %rdi
movl -0xe4(%rbp), %esi
movq -0x8(%rbp), %rdx
callq 0xd1d0
cmpq $0x0, %rax
je 0x17d77
movl -0x184(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x184(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpl $0x1, -0x184(%rbp)
jne 0x17b7a
movq -0x168(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xef, %eax
jne 0x17b7a
movq -0x168(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0xbb, %eax
jne 0x17b7a
movq -0x168(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0xbf, %eax
jne 0x17b7a
movq -0x168(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x190(%rbp)
jmp 0x17b88
movq -0x168(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
callq 0x17d90
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
je 0x17bcf
movq -0x168(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0x17bd4
jmp 0x17aeb
movq -0x168(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x17c67
movq -0x168(%rbp), %rdi
addq $0x1, %rdi
leaq 0xce07(%rip), %rsi      # 0x24a00
callq 0x17e80
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0x17c43
movq -0x170(%rbp), %rax
movb $0x0, (%rax)
leaq -0x120(%rbp), %rdi
movq -0x168(%rbp), %rsi
addq $0x1, %rsi
movl $0x31, %edx
callq 0xd080
movb $0x0, -0xef(%rbp)
jmp 0x17c62
leaq 0xcdb8(%rip), %rdi      # 0x24a02
movb $0x0, %al
callq 0xd140
movl -0x184(%rbp), %eax
movl %eax, -0x188(%rbp)
jmp 0x17d77
jmp 0x17d70
movq -0x168(%rbp), %rax
cmpb $0x0, (%rax)
je 0x17d6e
movq -0x168(%rbp), %rdi
leaq 0xcd91(%rip), %rsi      # 0x24a16
callq 0x17e80
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
je 0x17cb3
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x17d50
movq -0x170(%rbp), %rax
movb $0x0, (%rax)
movq -0x168(%rbp), %rdi
callq 0x17e00
movq %rax, -0x178(%rbp)
leaq -0x160(%rbp), %rdi
movq -0x178(%rbp), %rsi
movl $0x31, %edx
callq 0xd080
movb $0x0, -0x12f(%rbp)
movq -0x170(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
callq 0x17d90
movq %rax, -0x180(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x160(%rbp), %rdx
movq -0x180(%rbp), %rcx
callq *%rax
cmpl $0x1, %eax
je 0x17d4e
movl -0x184(%rbp), %eax
movl %eax, -0x188(%rbp)
jmp 0x17d77
jmp 0x17d6c
leaq 0xccc2(%rip), %rdi      # 0x24a19
movb $0x0, %al
callq 0xd140
movl -0x184(%rbp), %eax
movl %eax, -0x188(%rbp)
jmp 0x17d77
jmp 0x17d6e
jmp 0x17d70
jmp 0x17d72
jmp 0x17aeb
movl -0x188(%rbp), %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw %cs:(%rax,%rax)