// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x2b9c(%rip), %rsi      # 0x5004
movl $0x1, %edi
xorl %eax, %eax
callq 0x3a20
xorl %eax, %eax
callq 0x442c
leaq 0x2b97(%rip), %rsi      # 0x5019
movl $0x1, %edi
xorl %eax, %eax
callq 0x3a20
callq 0x3c4b
movq %rax, %r14
movl $0xa0, %edi
callq 0x2220
movq %rax, 0x30(%r14)
movw $0x0, -0x22(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x25b5
movq %r14, %rdi
movq %r15, %rsi
callq 0x276c
movq %r14, %rdi
callq 0x3cdd
cmpq $0x0, 0x18(%rbx)
je 0x24fa
leaq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x30fc
testb %al, %al
je 0x257b
movq 0x40(%r14), %rdx
leaq 0x2b59(%rip), %rsi      # 0x5047
movl $0x1, %edi
xorl %eax, %eax
callq 0x3a20
callq 0x3b40
movq 0x30(%r14), %rcx
movzbl 0x28(%r14), %edx
leal 0x1(%rdx), %esi
shll $0x3, %edx
movq %rax, (%rcx,%rdx)
movq 0x30(%r14), %rax
movq (%rax,%rdx), %rax
movl $0x7, (%rax)
movb %sil, 0x28(%r14)
leaq -0x22(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2885
movq %rax, %r15
movzwl (%r12), %r12d
movq %rbx, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x2a79
movl %eax, %ebx
movq %r14, %rdi
callq 0x3c5f
testl %r12d, %r12d
je 0x259b
shll $0x4, %r12d
xorl %r14d, %r14d
movq (%r15,%r14), %rdi
callq 0x21d0
movq $0x0, (%r15,%r14)
addq $0x10, %r14
cmpq %r14, %r12
jne 0x255f
jmp 0x259b
leaq 0x2aab(%rip), %rsi      # 0x502d
xorl %r15d, %r15d
movl $0x4, %edi
xorl %eax, %eax
callq 0x3a20
movq %r14, %rdi
callq 0x3c5f
movb $0x1, %bl
movzbl %bl, %ebx
movq %r15, %rdi
callq 0x21d0
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq