// File: /workspace/github_c_makefile_star2_O3/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 0x1da14(%rip), %rdi     # 0x2003e
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x21d0
cmpl $0x1, %eax
jne 0x27b2
leaq 0x1da35(%rip), %rdi     # 0x20089
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0x2030
cmpl $0x1, %eax
jne 0x27bc
leaq 0x1da46(%rip), %rdi     # 0x200c4
movq %r13, %rsi
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x21c0
cmpl $0x1, %eax
jne 0x27c6
movq %r14, %rdi
callq 0x2160
testq %rax, %rax
je 0x27d0
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 0x27da
movl $0x32, %esi
movq %rbx, %rdi
callq 0x289c
movq %r13, %rdi
movq %rbx, %rsi
movl %eax, %edx
callq 0x1d373
movl %eax, %ebp
movq %r13, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2050
movl $0xa, %edi
callq 0x21e0
testl %ebp, %ebp
js 0x278f
leaq 0x1db40(%rip), %rdi     # 0x202a2
callq 0x2210
leaq 0x1da02(%rip), %rdi     # 0x20170
xorl %eax, %eax
callq 0x2040
movq 0x2a844(%rip), %rax     # 0x2cfc0
movq (%rax), %rdi
movl %ebp, %esi
callq 0x192cf
leaq 0x1d9ec(%rip), %rdi     # 0x20179
jmp 0x27a7
leaq 0x1d99d(%rip), %rdi     # 0x20133
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1d9b9(%rip), %rdi     # 0x20160
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x27ea
movq %r14, %rdi
callq 0x2260
jmp 0x27e5
movq %r14, %rdi
callq 0x229a
jmp 0x27e5
movq %r14, %rdi
callq 0x22d4
jmp 0x27e5
movq %r14, %rdi
callq 0x2353
jmp 0x27e5
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