// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x8d0, %rsp            # imm = 0x8D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x8a8(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x20e0
leaq -0x8a8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
movq %rdx, %rsi
callq 0x48c0
movq 0x2850e(%rip), %rax     # 0x2b5c0
movq %rax, -0x8c0(%rbp)
movq 0x28508(%rip), %rax     # 0x2b5c8
movq %rax, -0x8b8(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x8c0(%rbp), %rdx
movq -0x10(%rbp), %r8
leaq -0x8a8(%rbp), %rdi
movl $0x4, %ecx
callq 0x29e30
movl %eax, -0x8c4(%rbp)
leaq 0x2833a(%rip), %rdi     # 0x2b42e
movb $0x0, %al
callq 0x2040
cmpl $0x0, -0x8c4(%rbp)
jge 0x3199
leaq 0x28332(%rip), %rdi     # 0x2b441
movb $0x0, %al
callq 0x2040
movl -0x8c4(%rbp), %esi
leaq 0x2817d(%rip), %rdi     # 0x2b2a0
movb $0x0, %al
callq 0x2040
leaq 0x2817f(%rip), %rdi     # 0x2b2b0
movb $0x0, %al
callq 0x2040
movq 0x32ea1(%rip), %rax     # 0x35fe0
movq (%rax), %rdi
movl -0x8c4(%rbp), %esi
callq 0x20550
leaq 0x282da(%rip), %rdi     # 0x2b42e
movb $0x0, %al
callq 0x2040
movq -0x880(%rbp), %rsi
leaq 0x28154(%rip), %rdi     # 0x2b2bd
movb $0x0, %al
callq 0x2040
leaq 0x28159(%rip), %rdi     # 0x2b2d0
movb $0x0, %al
callq 0x2040
movq 0x32e5b(%rip), %rax     # 0x35fe0
movq (%rax), %rdi
leaq -0x8a8(%rbp), %rsi
callq 0x204e0
jmp 0x322d
cmpl $0x0, -0x8c4(%rbp)
jl 0x322b
leaq 0x28241(%rip), %rdi     # 0x2b3ee
movb $0x0, %al
callq 0x2040
leaq 0x28264(%rip), %rdi     # 0x2b41f
movb $0x0, %al
callq 0x2040
movq 0x32dff(%rip), %rax     # 0x35fc8
movq (%rax), %rdi
movl -0x8c4(%rbp), %esi
callq 0x20db0
movl -0x8c4(%rbp), %esi
leaq 0x28288(%rip), %rdi     # 0x2b46c
movb $0x0, %al
callq 0x2040
cmpl $0x0, -0x8c4(%rbp)
jne 0x3229
leaq 0x28278(%rip), %rdi     # 0x2b473
movb $0x0, %al
callq 0x2040
movq -0x10(%rbp), %rsi
addq $0x190, %rsi            # imm = 0x190
leaq 0x2826f(%rip), %rdi     # 0x2b483
movb $0x0, %al
callq 0x2040
leaq 0x2820c(%rip), %rdi     # 0x2b42e
movb $0x0, %al
callq 0x2040
jmp 0x322b
jmp 0x322d
leaq 0x281fa(%rip), %rdi     # 0x2b42e
movb $0x0, %al
callq 0x2040
leaq -0x8a8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x4c40
leaq -0x8a8(%rbp), %rdi
callq 0x4c90
movl -0x8c4(%rbp), %eax
addq $0x8d0, %rsp            # imm = 0x8D0
popq %rbp
retq
nopl (%rax)