// File: /workspace/github_c_makefile_star2_O1/OpenKMIP[P]libkmip/demos/demo_destroy.c
// Function: use_high_level_api
int
use_high_level_api(const char *server_address,
                   const char *server_port,
                   const char *client_certificate,
                   const char *client_key,
                   const char *ca_certificate,
                   char *id)
{
    /* Set up the TLS connection to the KMIP server. */
    SSL_CTX *ctx = NULL;
    SSL *ssl = NULL;
    OPENSSL_init_ssl(0, NULL);
    ctx = SSL_CTX_new(TLS_client_method());
    
    printf("\n");
    printf("Loading the client certificate: %s\n", client_certificate);
    if(SSL_CTX_use_certificate_file(ctx, client_certificate, SSL_FILETYPE_PEM) != 1)
    {
        fprintf(stderr, "Loading the client certificate failed\n");
        ERR_print_errors_fp(stderr);
        SSL_CTX_free(ctx);
        return(-1);
    }
    
    printf("Loading the client key: %s\n", client_key);
    if(SSL_CTX_use_PrivateKey_file(ctx, client_key, SSL_FILETYPE_PEM) != 1)
    {
        fprintf(stderr, "Loading the client key failed\n");
        ERR_print_errors_fp(stderr);
        SSL_CTX_free(ctx);
        return(-1);
    }
    
    printf("Loading the CA certificate: %s\n", ca_certificate);
    if(SSL_CTX_load_verify_locations(ctx, ca_certificate, NULL) != 1)
    {
        fprintf(stderr, "Loading the CA file failed\n");
        ERR_print_errors_fp(stderr);
        SSL_CTX_free(ctx);
        return(-1);
    }
    
    BIO *bio = NULL;
    bio = BIO_new_ssl_connect(ctx);
    if(bio == NULL)
    {
        fprintf(stderr, "BIO_new_ssl_connect failed\n");
        ERR_print_errors_fp(stderr);
        SSL_CTX_free(ctx);
        return(-1);
    }
    
    BIO_get_ssl(bio, &ssl);
    SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
    BIO_set_conn_hostname(bio, server_address);
    BIO_set_conn_port(bio, server_port);
    if(BIO_do_connect(bio) != 1)
    {
        fprintf(stderr, "BIO_do_connect failed\n");
        ERR_print_errors_fp(stderr);
        BIO_free_all(bio);
        SSL_CTX_free(ctx);
        return(-1);
    }
    
    /* Send the request message. */
    int result = kmip_bio_destroy_symmetric_key(bio, id, kmip_strnlen_s(id, 50));
    
    BIO_free_all(bio);
    SSL_CTX_free(ctx);
    
    /* Handle the response results. */
    printf("\n");
    if(result < 0)
    {
        printf("An error occurred while deleting object: %s\n", id);
        printf("Error Code: %d\n", result);
    }
    else
    {
        printf("The KMIP operation was executed with no errors.\n");
        printf("Result: ");
        kmip_print_result_status_enum(stdout, result);
        printf(" (%d)\n", result);
    }
    
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
movq $0x0, 0x10(%rsp)
xorl %edi, %edi
xorl %esi, %esi
callq 0x2120
callq 0x20b0
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movl $0xa, %edi
callq 0x21e0
leaq 0x1e950(%rip), %rdi     # 0x21053
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x21d0
cmpl $0x1, %eax
jne 0x288b
leaq 0x1e971(%rip), %rdi     # 0x2109e
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0x2030
cmpl $0x1, %eax
jne 0x2895
leaq 0x1e982(%rip), %rdi     # 0x210d9
movq %r13, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x21c0
cmpl $0x1, %eax
jne 0x289f
movq %r14, %rdi
callq 0x2160
testq %rax, %rax
je 0x28a9
movq %rax, %r13
leaq 0x10(%rsp), %r15
movq %rax, %rdi
movl $0x6e, %esi
xorl %edx, %edx
movq %r15, %rcx
callq 0x2060
movq (%r15), %rdi
movl $0x4, %edx
movl $0x21, %esi
xorl %ecx, %ecx
callq 0x2070
movq %r13, %rdi
movl $0x64, %esi
xorl %edx, %edx
movq %r12, %rcx
callq 0x2060
movl $0x1, %edx
movq %r13, %rdi
movl $0x64, %esi
movq 0x8(%rsp), %rcx
callq 0x2060
movq %r13, %rdi
movl $0x65, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2060
cmpq $0x1, %rax
jne 0x28b3
movl $0x32, %esi
movq %rbx, %rdi
callq 0x2978
movq %r13, %rdi
movq %rbx, %rsi
movl %eax, %edx
callq 0x1e225
movl %eax, %ebp
movq %r13, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2050
movl $0xa, %edi
callq 0x21e0
testl %ebp, %ebp
js 0x2868
leaq 0x1ea7c(%rip), %rdi     # 0x212b7
callq 0x2210
leaq 0x1e93e(%rip), %rdi     # 0x21185
xorl %eax, %eax
callq 0x2040
movq 0x2b76b(%rip), %rax     # 0x2dfc0
movq (%rax), %rdi
movl %ebp, %esi
callq 0x1a1bf
leaq 0x1e928(%rip), %rdi     # 0x2118e
jmp 0x2880
leaq 0x1e8d9(%rip), %rdi     # 0x21148
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1e8f5(%rip), %rdi     # 0x21175
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x28c3
movq %r14, %rdi
callq 0x2260
jmp 0x28be
movq %r14, %rdi
callq 0x229a
jmp 0x28be
movq %r14, %rdi
callq 0x22d4
jmp 0x28be
movq %r14, %rdi
callq 0x2353
jmp 0x28be
movq %r13, %rdi
movq %r14, %rsi
callq 0x230e
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq