// File: /workspace/github_c_makefile_star2_O1/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, %r14
leaq 0x2b9c(%rip), %rsi      # 0x5004
movl $0x1, %edi
xorl %eax, %eax
callq 0x3c64
xorl %eax, %eax
callq 0x46ce
leaq 0x2b97(%rip), %rsi      # 0x5019
movl $0x1, %edi
xorl %eax, %eax
callq 0x3c64
callq 0x3e9f
movq %rax, %rbx
movl $0xa0, %edi
callq 0x2220
movq %rax, 0x30(%rbx)
movw $0x0, -0x22(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x25ac
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2763
movq %rbx, %rdi
callq 0x3f44
cmpq $0x0, 0x18(%r14)
je 0x24f6
leaq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x31ec
testb %al, %al
je 0x2547
movq 0x40(%rbx), %rdx
leaq 0x2b5d(%rip), %rsi      # 0x5047
movl $0x1, %edi
xorl %eax, %eax
callq 0x3c64
callq 0x3d84
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 -0x22(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x287c
movq %rax, %r15
movzwl (%r12), %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2a70
movzbl %al, %r14d
jmp 0x2563
leaq 0x2adf(%rip), %rsi      # 0x502d
xorl %r15d, %r15d
movl $0x4, %edi
xorl %eax, %eax
callq 0x3c64
movl $0x1, %r14d
movq %rbx, %rdi
callq 0x3eba
movzwl -0x22(%rbp), %ebx
testq %rbx, %rbx
je 0x2594
shll $0x4, %ebx
xorl %r12d, %r12d
movq (%r15,%r12), %rdi
callq 0x21d0
movq $0x0, (%r15,%r12)
addq $0x10, %r12
cmpq %r12, %rbx
jne 0x257a
movq %r15, %rdi
callq 0x21d0
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq