// File: /workspace/github_c_makefile_star2_O3/howerj[P]eweb/eweb.c
// Function: eweb_get_form_values
static int eweb_get_form_values(eweb_os_t *w, eweb_os_hit_args_t *args, char *body) {
	assert(w);
	assert(args);
	assert(body);
	long t = 0, alloc = FORM_VALUE_BLOCK;
	char *saveptr = NULL;
	char *token = eweb_strtok(body, "&", &saveptr);

	args->form_values = eweb_calloc_or_die(w, sizeof(eweb_form_value_t), alloc);
	if (!(args->form_values))
		goto fail;

	while (token) {
		const size_t token_length = strlen(token) + 1;
		char *tmp = eweb_malloc_or_die(w, token_length);
		if (!tmp)
			goto fail;
		memcpy(tmp, token, token_length);
		if (eweb_url_decode(w, tmp) != EWEB_OK) {
			w->log(w, EWEB_ERROR, "url decode failed");
			eweb_free(w, tmp);
			goto fail;
		}

		size_t i = 0;
		const size_t tlen = strlen(tmp);
		for (i = 0; i < tlen; i++)
			if (tmp[i] == '=')
				break;

		if (i < tlen) {
			if (alloc <= t) {
				const long newsize = alloc + FORM_VALUE_BLOCK;
				void *fv = eweb_realloc_or_die(w, args->form_values, newsize * sizeof(eweb_form_value_t));
				if (!fv) {
					eweb_free(w, tmp);
					goto fail;
				}
				args->form_values = fv;
				memset(args->form_values + alloc, 0, FORM_VALUE_BLOCK * sizeof(eweb_form_value_t));
				alloc = newsize;
			}

			if (!(args->form_values[t].data = eweb_malloc_or_die(w, strlen(tmp) + 1))) {
				eweb_free(w, tmp);
				goto fail;
			}
			memcpy(args->form_values[t].data, tmp, tlen + 1);
			args->form_values[t].name = args->form_values[t].data;
			args->form_values[t].value = args->form_values[t].data + 1 + i;
			args->form_values[t++].data[i] = 0;
		}

		token = eweb_strtok(NULL, "&", &saveptr);
		eweb_free(w, tmp);
	}
	args->form_value_counter = t;
	return EWEB_OK;
fail:
	eweb_clear_form_values(w, args);
	return EWEB_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x8(%rsp)
testq %rdx, %rdx
je 0x3daa
movq %rdi, %r14
leaq 0x20(%rsp), %rsi
movq $0x0, (%rsi)
movq %rdx, %rdi
callq 0x4400
movq %rax, %r13
movl $0x18, %esi
movl $0xa, %edx
movq %r14, %rdi
callq 0x3f4a
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
testq %rax, %rax
je 0x3d70
testq %r13, %r13
je 0x3d2a
movl $0xa, %eax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
leaq 0x20(%rsp), %r15
movq %r14, 0x10(%rsp)
movq %r13, %rdi
callq 0x20b0
movq %rax, %rbp
incq %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3a6c
testq %rax, %rax
je 0x3d70
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x21b0
movq %r14, %rdi
movq %r12, %rsi
callq 0x4002
testl %eax, %eax
jne 0x3d44
movq %r12, %rdi
callq 0x20b0
testq %rax, %rax
je 0x3d02
movq %rax, %r13
negq %rax
movl $0x1, %ebp
cmpb $0x3d, -0x1(%r12,%rbp)
je 0x3c3e
leaq (%rax,%rbp), %rcx
incq %rcx
incq %rbp
cmpq $0x1, %rcx
jne 0x3c21
jmp 0x3d02
movq 0x18(%rsp), %r15
cmpq %rbx, %r15
jg 0x3c94
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rsi
leaq 0x50(,%r15,8), %rax
leaq (%rax,%rax,2), %rdx
movq %r14, %rdi
callq 0x4243
testq %rax, %rax
je 0x3d60
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
leaq (%r15,%r15,2), %rcx
addq $0xa, %r15
movq %r15, 0x18(%rsp)
leaq (%rax,%rcx,8), %rdi
movl $0xf0, %edx
xorl %esi, %esi
callq 0x2100
movq %r12, %rdi
callq 0x20b0
leaq 0x1(%rax), %rsi
movq %r14, %rdi
callq 0x3a6c
movq 0x8(%rsp), %r15
movq 0x20(%r15), %rcx
movq %rbx, %r14
leaq (%rbx,%rbx,2), %rbx
movq %rax, 0x10(%rcx,%rbx,8)
testq %rax, %rax
je 0x3d5b
incq %r13
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21b0
movq 0x20(%r15), %rax
movq 0x10(%rax,%rbx,8), %rcx
movq %rcx, (%rax,%rbx,8)
leaq (%rcx,%rbp), %rdx
movq %rdx, 0x8(%rax,%rbx,8)
incq %r14
movb $0x0, -0x1(%rcx,%rbp)
movq %r14, %rbx
movq 0x10(%rsp), %r14
leaq 0x20(%rsp), %r15
xorl %edi, %edi
movq %r15, %rsi
callq 0x4400
testq %r14, %r14
je 0x3d8b
movq %rax, %r13
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq *0x10(%r14)
testq %r13, %r13
jne 0x3bbf
jmp 0x3d2c
xorl %ebx, %ebx
movq 0x8(%rsp), %rax
movq %rbx, 0x30(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x248d(%rip), %rdx      # 0x61d8
movq %r14, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq *0x50(%r14)
jmp 0x3d65
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x3d8b
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq *0x10(%r14)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x439a
leaq 0x179b(%rip), %rdi      # 0x552d
leaq 0x1af2(%rip), %rsi      # 0x588b
leaq 0x22c5(%rip), %rcx      # 0x6065
movl $0x200, %edx            # imm = 0x200
callq 0x20e0
leaq 0x2420(%rip), %rdi      # 0x61d1
leaq 0x1ad3(%rip), %rsi      # 0x588b
leaq 0x23ce(%rip), %rcx      # 0x618d
movl $0x35, %edx
callq 0x20e0