// File: /workspace/github_c_makefile_star2_O0/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
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x5c05
jmp 0x5c24
leaq 0x24f9(%rip), %rdi      # 0x8105
leaq 0x2502(%rip), %rsi      # 0x8115
movl $0x171, %edx            # imm = 0x171
leaq 0x2503(%rip), %rcx      # 0x8122
callq 0x21f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x5c31
jmp 0x5c50
leaq 0x252a(%rip), %rdi      # 0x8162
leaq 0x24d6(%rip), %rsi      # 0x8115
movl $0x172, %edx            # imm = 0x172
leaq 0x24d7(%rip), %rcx      # 0x8122
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x5c61
jmp 0x5c80
leaq 0x2513(%rip), %rdi      # 0x817b
leaq 0x24a6(%rip), %rsi      # 0x8115
movl $0x173, %edx            # imm = 0x173
leaq 0x24a7(%rip), %rcx      # 0x8122
callq 0x21f0
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl $0x6, (%rax)
movq -0x8(%rbp), %rax
testb $0x1, 0x38(%rax)
jne 0x5ca9
jmp 0x5d8c
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x58c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5ce8
movq -0x8(%rbp), %rax
movl $0x8, (%rax)
jmp 0x5dab
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movzwl 0x2(%rax), %eax
cmpq -0x18(%rbp), %rax
ja 0x5d12
movl $0x3, %edi
leaq 0x2494(%rip), %rsi      # 0x819a
movb $0x0, %al
callq 0x4d70
jmp 0x5d98
movq -0x8(%rbp), %rax
testb $0x1, 0x38(%rax)
je 0x5d31
movl $0x3, %edi
leaq 0x24b8(%rip), %rsi      # 0x81e0
movb $0x0, %al
callq 0x4d70
jmp 0x5d98
callq 0x5ea0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %eax
subq -0x18(%rbp), %rax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
addq -0x18(%rbp), %rdx
callq 0x5ef0
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rax
movl $0x7, (%rax)
jmp 0x5da2
movq -0x8(%rbp), %rax
movl $0x8, (%rax)
movq -0x10(%rbp), %rdi
callq 0x5f40
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)