// File: /workspace/github_c_makefile_star2_O1/OpenKMIP[P]libkmip/demos/demo_query.c
// Function: use_mid_level_api
int
use_mid_level_api(BIO* bio,
                  QueryResponse* query_result)
{
    /* Set up the KMIP context and send the request message. */
    KMIP kmip_context = {0};

    kmip_init(&kmip_context, NULL, 0, KMIP_1_0);
    
    enum query_function queries[] =
    {
        KMIP_QUERY_OPERATIONS,
        KMIP_QUERY_OBJECTS,
        KMIP_QUERY_SERVER_INFORMATION,
        KMIP_QUERY_APPLICATION_NAMESPACES,
    };

    int result = kmip_bio_query_with_context(&kmip_context, bio, queries, ARRAY_LENGTH(queries), query_result);
    
    /* Handle the response results. */
    printf("\n");
    if(result < 0)
    {
        printf("An error occurred while running the query.");
        printf("Error Code: %d\n", result);
        printf("Error Name: ");
        kmip_print_error_string(stderr, result);
        printf("\n");
        printf("Context Error: %s\n", kmip_context.error_message);
        printf("Stack trace:\n");
        kmip_print_stack_trace(stderr, &kmip_context);
    }
    else if(result >= 0)
    {
        printf("The KMIP operation was executed with no errors.\n");
        printf("Result: ");
        kmip_print_result_status_enum(stdout, result);
        printf(" (%d)\n", result);
        
        if(result == KMIP_STATUS_SUCCESS)
        {
            printf("Query results: ");
            printf("vendor: %s\n", query_result->vendor_identification);
            printf("\n");
        }
    }
    
    printf("\n");
    
    /* Clean up the KMIP context and return the results. */
    kmip_set_buffer(&kmip_context, NULL, 0);
    kmip_destroy(&kmip_context);
    return(result);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x8b0, %rsp            # imm = 0x8B0
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %r15
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x20e0
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3b8f
movaps 0x1e1c5(%rip), %xmm0    # 0x21020
movq %rsp, %rdx
movaps %xmm0, (%rdx)
movl $0x4, %ecx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %r8
callq 0x205ee
movl %eax, %ebx
movl $0xa, %edi
callq 0x21e0
testl %ebx, %ebx
js 0x2ef9
leaq 0x1e705(%rip), %rdi     # 0x21590
callq 0x2210
leaq 0x1e36c(%rip), %rdi     # 0x21203
xorl %eax, %eax
callq 0x2040
movq 0x2b11b(%rip), %rax     # 0x2dfc0
movq (%rax), %rdi
movl %ebx, %esi
callq 0x1aa87
leaq 0x1e389(%rip), %rdi     # 0x2123f
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
testl %ebx, %ebx
jne 0x2f6e
leaq 0x1e378(%rip), %rdi     # 0x21246
xorl %eax, %eax
callq 0x2040
addq $0x190, %r14            # imm = 0x190
leaq 0x1e373(%rip), %rdi     # 0x21256
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movl $0xa, %edi
callq 0x21e0
jmp 0x2f6e
leaq 0x1e314(%rip), %rdi     # 0x21214
xorl %eax, %eax
callq 0x2040
leaq 0x1e260(%rip), %rdi     # 0x2116e
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x1e260(%rip), %rdi     # 0x2117e
xorl %eax, %eax
callq 0x2040
movq 0x2b0ac(%rip), %r15     # 0x2dfd8
movq (%r15), %rdi
movl %ebx, %esi
callq 0x1a5bc
movl $0xa, %edi
callq 0x21e0
leaq 0x18(%rsp), %r14
movq 0x28(%r14), %rsi
leaq 0x1e23b(%rip), %rdi     # 0x2118b
xorl %eax, %eax
callq 0x2040
leaq 0x1e662(%rip), %rdi     # 0x215c0
callq 0x2210
movq (%r15), %rdi
movq %r14, %rsi
callq 0x1a56a
movl $0xa, %edi
callq 0x21e0
leaq 0x18(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3e5a
movq %r14, %rdi
callq 0x3e6b
movl %ebx, %eax
addq $0x8b0, %rsp            # imm = 0x8B0
popq %rbx
popq %r14
popq %r15
retq