// File: /workspace/github_c_makefile_star2_O1/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 0x4a42
movq %rdi, %rbx
movq 0x50(%rdi), %r14
testq %r14, %r14
je 0x4a61
cmpq $0x0, 0x10(%r14)
jne 0x4a80
movl $0x6, (%rbx)
movl $0x7, %r13d
cmpb $0x1, 0x38(%rbx)
jne 0x49be
movzwl 0x2(%r14), %esi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x4747
testq %rax, %rax
je 0x49c3
movq %rax, %r15
movq 0x50(%rbx), %rax
movzwl 0x2(%rax), %eax
cmpq %rax, %r15
jae 0x49d8
cmpb $0x1, 0x38(%rbx)
jne 0x49f3
leaq 0x27f0(%rip), %rsi      # 0x71ac
jmp 0x49df
xorl %r14d, %r14d
jmp 0x4a29
movl $0x8, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2787(%rip), %rsi      # 0x7166
movl $0x3, %edi
xorl %eax, %eax
callq 0x4100
movl $0x8, %r13d
jmp 0x4a29
callq 0x4b31
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 0x4b4e
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 0x4b8d
leaq 0x2688(%rip), %rdi      # 0x70d1
leaq 0x2691(%rip), %rsi      # 0x70e1
leaq 0x2697(%rip), %rcx      # 0x70ee
movl $0x171, %edx            # imm = 0x171
callq 0x21e0
leaq 0x26c6(%rip), %rdi      # 0x712e
leaq 0x2672(%rip), %rsi      # 0x70e1
leaq 0x2678(%rip), %rcx      # 0x70ee
movl $0x172, %edx            # imm = 0x172
callq 0x21e0
leaq 0x26c0(%rip), %rdi      # 0x7147
leaq 0x2653(%rip), %rsi      # 0x70e1
leaq 0x2659(%rip), %rcx      # 0x70ee
movl $0x173, %edx            # imm = 0x173
callq 0x21e0
nop