// File: /workspace/github_c_makefile_star2_O0/ammarfaizi2[P]riyuu/src/riyuu/server/riyuu_server.c
// Function: riyuu_server_config_parse(_riyuu_run*, _riyuu_server_config*)
bool riyuu_server_config_parse(riyuu_run *run, riyuu_server_config *config)
{
	FILE *h;
	char stream[1024];
	char *strptr = stream;
	char *strptr2 = stream;
	size_t len, i, oft, oft_a, oft_b;
	bool got_oft;

	if (run->config_file == NULL) {
		h = fopen("riyuu.conf", "rb");
	} else {
		h = fopen(run->config_file, "rb");
	}

	if (h == NULL) return false;

	while (fgets(stream, 1023, h)) {

		got_oft = false;
		len = strlen(stream);

		oft_a = oft_b = 0;

		for (i = 0; i < len; i++) {
			if ((*strptr2) == '=') {
				oft = i;
				oft_b = i + 1;
				got_oft = true;
				break;
			}
			strptr2++;
		}

		if (got_oft) {
			oft_a = oft - 1;
			while (
				((*strptr) == ' ') || ((*strptr) == '\t') || 
				((*strptr) == '\r') || ((*strptr) == '\n')
			) {
				strptr++;
			}
			while (
				(oft_a > 0) && 
				((stream[oft_a] == ' ') || (stream[oft_a] == '\t') || 
				(stream[oft_a] == '\r') || (stream[oft_a] == '\n'))
			) {
				oft_a--;
			}
			oft_a++;

			strptr2++;
			while (
				((*strptr2) == ' ') || ((*strptr2) == '\t') ||
				((*strptr2) == '\r') || ((*strptr2) == '\n')
			) {
				strptr2++;
			}

			len--;
			while ((len > 0) && 
				((stream[len] == ' ') || (stream[len] == '\t') ||
				(stream[len] == '\r') || (stream[len] == '\n'))
			) {
				len--;
			}
			len = len - oft_b + 1;

			RIYUU_CONFIG_ACT("bind_addr", {
				config->bind_addr = (char *)malloc(len + 1);
				strncpy(config->bind_addr, strptr2, len);
				PRINTF_DEBUG("Parsed bind_addr: %s\n", config->bind_addr);
			}) else
			RIYUU_CONFIG_ACT("bind_port", {
				char tmp[6];
				strncpy(tmp, strptr2, 5);
				config->bind_port = (uint16_t)atoi(tmp);
				PRINTF_DEBUG("Parsed bind_port: %d\n", config->bind_port);
			})
		}

		strptr = stream;
		strptr2 = stream;
	}

	fclose(h);
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x428(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa913
leaq 0x1bf8(%rip), %rdi      # 0xc4f9
leaq 0x1bfc(%rip), %rsi      # 0xc504
callq 0x2340
movq %rax, -0x20(%rbp)
jmp 0xa92b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1be2(%rip), %rsi      # 0xc504
callq 0x2340
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa93b
movb $0x0, -0x1(%rbp)
jmp 0xadcb
jmp 0xa93d
leaq -0x420(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x3ff, %esi            # imm = 0x3FF
callq 0x21c0
cmpq $0x0, %rax
je 0xadbe
movb $0x0, -0x459(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x2160
movq %rax, -0x438(%rbp)
movq $0x0, -0x458(%rbp)
movq $0x0, -0x450(%rbp)
movq $0x0, -0x440(%rbp)
movq -0x440(%rbp), %rax
cmpq -0x438(%rbp), %rax
jae 0xaa05
movq -0x430(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0xa9df
movq -0x440(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x440(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x458(%rbp)
movb $0x1, -0x459(%rbp)
jmp 0xaa05
movq -0x430(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x430(%rbp)
movq -0x440(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x440(%rbp)
jmp 0xa997
testb $0x1, -0x459(%rbp)
je 0xad9d
movq -0x448(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x450(%rbp)
movq -0x428(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x460(%rbp)
je 0xaa7f
movq -0x428(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x460(%rbp)
je 0xaa7f
movq -0x428(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x460(%rbp)
je 0xaa7f
movq -0x428(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x460(%rbp)
movb -0x460(%rbp), %al
testb $0x1, %al
jne 0xaa8b
jmp 0xaa9f
movq -0x428(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x428(%rbp)
jmp 0xaa24
jmp 0xaaa1
xorl %eax, %eax
cmpq $0x0, -0x450(%rbp)
movb %al, -0x461(%rbp)
jbe 0xab2e
movq -0x450(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x462(%rbp)
je 0xab22
movq -0x450(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x462(%rbp)
je 0xab22
movq -0x450(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x462(%rbp)
je 0xab22
movq -0x450(%rbp), %rax
movsbl -0x420(%rbp,%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x462(%rbp)
movb -0x462(%rbp), %al
movb %al, -0x461(%rbp)
movb -0x461(%rbp), %al
testb $0x1, %al
jne 0xab3a
jmp 0xab51
movq -0x450(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0xaaa1
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
movq -0x430(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x430(%rbp)
movq -0x430(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x463(%rbp)
je 0xabd0
movq -0x430(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x463(%rbp)
je 0xabd0
movq -0x430(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x463(%rbp)
je 0xabd0
movq -0x430(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x463(%rbp)
movb -0x463(%rbp), %al
testb $0x1, %al
jne 0xabdc
jmp 0xabf0
movq -0x430(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x430(%rbp)
jmp 0xab75
movq -0x438(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x438(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x438(%rbp)
movb %al, -0x464(%rbp)
jbe 0xac8f
movq -0x438(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x465(%rbp)
je 0xac83
movq -0x438(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x465(%rbp)
je 0xac83
movq -0x438(%rbp), %rax
movsbl -0x420(%rbp,%rax), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x465(%rbp)
je 0xac83
movq -0x438(%rbp), %rax
movsbl -0x420(%rbp,%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x465(%rbp)
movb -0x465(%rbp), %al
movb %al, -0x464(%rbp)
movb -0x464(%rbp), %al
testb $0x1, %al
jne 0xac9b
jmp 0xacb2
movq -0x438(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x438(%rbp)
jmp 0xac02
movq -0x438(%rbp), %rax
subq -0x458(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x438(%rbp)
movq -0x428(%rbp), %rsi
movq -0x450(%rbp), %rdx
leaq 0x1827(%rip), %rdi      # 0xc507
callq 0x20a0
cmpl $0x0, %eax
jne 0xad35
movq -0x438(%rbp), %rdi
addq $0x1, %rdi
callq 0x2370
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x430(%rbp), %rsi
movq -0x438(%rbp), %rdx
callq 0x2070
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq 0x17e5(%rip), %rdi      # 0xc511
movb $0x0, %al
callq 0x2030
jmp 0xad9b
movq -0x428(%rbp), %rsi
movq -0x450(%rbp), %rdx
leaq 0x17dd(%rip), %rdi      # 0xc527
callq 0x20a0
cmpl $0x0, %eax
jne 0xad99
leaq -0x45f(%rbp), %rdi
movq -0x430(%rbp), %rsi
movl $0x5, %edx
callq 0x2070
leaq -0x45f(%rbp), %rdi
callq 0x2100
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x18(%rbp), %rax
movzwl 0x8(%rax), %esi
leaq 0x179f(%rip), %rdi      # 0xc531
movb $0x0, %al
callq 0x2030
jmp 0xad9b
jmp 0xad9d
leaq -0x420(%rbp), %rax
movq %rax, -0x428(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x430(%rbp)
jmp 0xa93d
movq -0x20(%rbp), %rdi
callq 0x2190
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
nopl (%rax)