// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
andq $0x0, 0x10(%rsp)
xorl %edi, %edi
xorl %esi, %esi
callq 0x2120
callq 0x20b0
movq %rax, %rdi
callq 0x21f0
movq %rax, %rbx
pushq $0xa
popq %rdi
callq 0x21e0
leaq 0x16b48(%rip), %rdi     # 0x1903e
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21d0
cmpl $0x1, %eax
jne 0x2669
leaq 0x16b6b(%rip), %rdi     # 0x19089
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2040
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2030
cmpl $0x1, %eax
jne 0x267e
leaq 0x16b7e(%rip), %rdi     # 0x190c4
movq %r13, %rsi
xorl %eax, %eax
callq 0x2040
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x21c0
cmpl $0x1, %eax
jne 0x2693
movq %rbx, %rdi
callq 0x2160
testq %rax, %rax
je 0x26a6
movq %rax, %r13
pushq $0x6e
popq %rsi
leaq 0x10(%rsp), %r15
movq %rax, %rdi
xorl %edx, %edx
movq %r15, %rcx
callq 0x2060
movq (%r15), %rdi
pushq $0x21
popq %rsi
pushq $0x4
popq %rdx
xorl %ecx, %ecx
callq 0x2070
pushq $0x64
popq %rbp
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
movq %r12, %rcx
callq 0x2060
pushq $0x1
popq %rdx
movq %r13, %rdi
movl %ebp, %esi
movq 0x8(%rsp), %rcx
callq 0x2060
pushq $0x65
popq %rsi
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2060
cmpq $0x1, %rax
jne 0x26e6
pushq $0x32
popq %rsi
movq %r14, %rdi
callq 0x27b8
movq %r13, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x161c6
movl %eax, %ebp
movq %r13, %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2050
pushq $0xa
popq %rdi
callq 0x21e0
testl %ebp, %ebp
js 0x2646
leaq 0x16c89(%rip), %rdi     # 0x192a2
callq 0x2210
leaq 0x16b4b(%rip), %rdi     # 0x19170
xorl %eax, %eax
callq 0x2040
movq 0x2498d(%rip), %rax     # 0x26fc0
movq (%rax), %rdi
movl %ebp, %esi
callq 0x12494
leaq 0x16b35(%rip), %rdi     # 0x19179
jmp 0x265e
leaq 0x16ae6(%rip), %rdi     # 0x19133
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x16b02(%rip), %rdi     # 0x19160
movl %ebp, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x26d5
movq 0x24968(%rip), %r14     # 0x26fd8
movq (%r14), %rcx
leaq 0x169e8(%rip), %rdi     # 0x19062
pushq $0x26
jmp 0x26b9
movq 0x24953(%rip), %r14     # 0x26fd8
movq (%r14), %rcx
leaq 0x16a16(%rip), %rdi     # 0x190a5
pushq $0x1e
jmp 0x26b9
movq 0x2493e(%rip), %r14     # 0x26fd8
movq (%r14), %rcx
leaq 0x16a40(%rip), %rdi     # 0x190e4
jmp 0x26b7
movq 0x2492b(%rip), %r14     # 0x26fd8
movq (%r14), %rcx
leaq 0x16a49(%rip), %rdi     # 0x19100
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x2240
movq (%r14), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2050
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x248eb(%rip), %r14     # 0x26fd8
movq (%r14), %rcx
leaq 0x16a25(%rip), %rdi     # 0x1911c
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2240
movq (%r14), %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x2080
jmp 0x26ca