// File: /workspace/github_c_makefile_star2_O3/TimeToogo[P]ff-proxy/src/parser.c
// Function: ff_request_parse_options_from_payload
void ff_request_parse_options_from_payload(struct ff_request *request)
{
    assert(request != NULL);
    assert(request->payload != NULL);
    assert(request->payload->next == NULL);

    struct ff_request_payload_node *payload = NULL;
    size_t options_length = 0;

    request->state = FF_REQUEST_STATE_PARSING_OPTIONS;

    if (!request->payload_contains_options)
    {
        goto done;
    }

    payload = request->payload;
    options_length = ff_request_parse_options(request, payload->length, payload->value);

    if (options_length == 0)
    {
        request->state = FF_REQUEST_STATE_PARSING_OPTIONS_FAILED;
        return;
    }

    if (request->payload->length <= options_length)
    {
        ff_log(FF_WARNING, "Request buffer ran out of buffer while parsing options within payload");
        goto error;
    }

    if (request->payload_contains_options)
    {
        ff_log(FF_WARNING, "Request cannot contain multiple FF_REQUEST_OPTION_TYPE_BREAK options");
        goto error;
    }

    struct ff_request_payload_node *new_payload = ff_request_payload_node_alloc();
    new_payload->length = payload->length - options_length;
    ff_request_payload_load_buff(new_payload, new_payload->length, payload->value + options_length);

    request->payload = new_payload;
    request->payload_length = new_payload->length;

    goto done;

done:
    request->state = FF_REQUEST_STATE_PARSED_OPTIONS;
    goto cleanup;

error:
    request->state = FF_REQUEST_STATE_PARSING_OPTIONS_FAILED;
    goto cleanup;

cleanup:
    ff_request_payload_node_free(payload);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x483b
movq %rdi, %rbx
movq 0x50(%rdi), %r14
testq %r14, %r14
je 0x485a
cmpq $0x0, 0x10(%r14)
jne 0x4879
movl $0x6, (%rbx)
movl $0x7, %r13d
cmpb $0x1, 0x38(%rbx)
jne 0x47b7
movzwl 0x2(%r14), %esi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x459b
testq %rax, %rax
je 0x47bc
movq %rax, %r15
movq 0x50(%rbx), %rax
movzwl 0x2(%rax), %eax
cmpq %rax, %r15
jae 0x47d1
cmpb $0x1, 0x38(%rbx)
jne 0x47ec
leaq 0x29f7(%rip), %rsi      # 0x71ac
jmp 0x47d8
xorl %r14d, %r14d
jmp 0x4822
movl $0x8, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x298e(%rip), %rsi      # 0x7166
movl $0x3, %edi
xorl %eax, %eax
callq 0x3fa4
movl $0x8, %r13d
jmp 0x4822
callq 0x4921
movq %rax, %r12
movzwl 0x2(%r14), %eax
subl %r15d, %eax
movw %ax, 0x2(%r12)
movzwl %ax, %esi
addq 0x8(%r14), %r15
movq %r12, %rdi
movq %r15, %rdx
callq 0x493e
movq %r12, 0x50(%rbx)
movzwl 0x2(%r12), %eax
movq %rax, 0x40(%rbx)
movl %r13d, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x497d
leaq 0x288f(%rip), %rdi      # 0x70d1
leaq 0x2898(%rip), %rsi      # 0x70e1
leaq 0x289e(%rip), %rcx      # 0x70ee
movl $0x171, %edx            # imm = 0x171
callq 0x21e0
leaq 0x28cd(%rip), %rdi      # 0x712e
leaq 0x2879(%rip), %rsi      # 0x70e1
leaq 0x287f(%rip), %rcx      # 0x70ee
movl $0x172, %edx            # imm = 0x172
callq 0x21e0
leaq 0x28c7(%rip), %rdi      # 0x7147
leaq 0x285a(%rip), %rsi      # 0x70e1
leaq 0x2860(%rip), %rcx      # 0x70ee
movl $0x173, %edx            # imm = 0x173
callq 0x21e0