// File: /workspace/github_c_makefile_star2_O2/TimeToogo[P]ff-proxy/client/c/client.c
// Function: ff_client_make_request
int ff_client_make_request(struct ff_client_config *config, FILE *fd)
{
    ff_log(FF_DEBUG, "Initialising OpenSSL");
    ff_init_openssl();
    ff_log(FF_DEBUG, "Initialised OpenSSL");

    int ret_val = 0;

    struct ff_request *request = ff_request_alloc();
    request->options = malloc(sizeof(struct ff_request_option_node *) * FF_REQUEST_MAX_OPTIONS);

    uint16_t packet_count = 0;
    struct ff_client_packet *packets = NULL;

    uint8_t options_in_payload = ff_client_create_payload_options(request, config);

    ff_client_read_payload_from_file(request, fd);

    ff_request_vectorise_payload(request);

    if (config->encryption.key != NULL)
    {
        if (!ff_client_encrypt_request(request, &config->encryption))
        {
            ff_log(FF_ERROR, "Failed to encrypt payload");
            goto error;
        }
        ff_log(FF_DEBUG, "Encrypted payload using pre-shared key (ciphertext length: %u)", request->payload_length);
    }

    request->options[request->options_length] = ff_request_option_node_alloc();
    request->options[request->options_length]->type = options_in_payload == 0 ? FF_REQUEST_OPTION_TYPE_EOL : FF_REQUEST_OPTION_TYPE_BREAK;
    request->options_length++;

    packets = ff_client_packetise_request(request, &packet_count);

    if (!ff_client_send_request(config, packets, packet_count))
    {
        goto done;
    }
    else
    {
        goto error;
    }

done:
    ret_val = 0;
    goto cleanup;

error:
    ret_val = 1;
    goto cleanup;

cleanup:
    ff_request_free(request);

    for (uint16_t i = 0; i < packet_count; i++)
    {
        FREE(packets[i].value);
    }

    FREE(packets);

    return ret_val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r15
leaq 0x2bdd(%rip), %rsi      # 0x5004
pushq $0x1
popq %r14
movl %r14d, %edi
xorl %eax, %eax
callq 0x37ac
xorl %eax, %eax
callq 0x40fb
leaq 0x2bd6(%rip), %rsi      # 0x5019
movl %r14d, %edi
xorl %eax, %eax
callq 0x37ac
callq 0x39c9
movq %rax, %rbx
movl $0xa0, %edi
callq 0x2220
movq %rax, 0x30(%rbx)
andw $0x0, -0x2a(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x255d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2677
movq %rbx, %rdi
callq 0x3a42
cmpq $0x0, 0x18(%r15)
je 0x24b2
leaq 0x18(%r15), %rsi
movq %rbx, %rdi
callq 0x2edc
testb %al, %al
je 0x2505
movq 0x40(%rbx), %rdx
leaq 0x2b9f(%rip), %rsi      # 0x5047
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x37ac
callq 0x38cc
movq 0x30(%rbx), %rcx
movzbl 0x28(%rbx), %edx
leal 0x1(%rdx), %esi
shll $0x3, %edx
movq %rax, (%rcx,%rdx)
movq 0x30(%rbx), %rax
movq (%rax,%rdx), %rax
movl $0x7, (%rax)
movb %sil, 0x28(%rbx)
leaq -0x2a(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x274a
movq %rax, %r13
movzwl (%r14), %r12d
movq %r15, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x28ae
movzbl %al, %r14d
jmp 0x251c
leaq 0x2b21(%rip), %rsi      # 0x502d
xorl %r12d, %r12d
pushq $0x4
popq %rdi
xorl %eax, %eax
callq 0x37ac
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x39e7
xorl %ebx, %ebx
movq %r13, %r15
cmpq %r12, %rbx
jae 0x2543
movq (%r15), %rdi
callq 0x21d0
andq $0x0, (%r15)
incq %rbx
addq $0x10, %r15
jmp 0x2529
movq %r13, %rdi
callq 0x21d0
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq