// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/tests/tests.c
// Function: test_decode_key_block_key_value_structure
int
test_decode_key_block_key_value_structure(TestTracker *tracker)
{
    TRACK_TEST(tracker);

    uint8 encoding[88] = {
        0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x50, 
        0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18, 
        0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10, 
        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
        0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 
        0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
    };
    
    struct kmip ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_1_0);
    
    uint8 value[16] = {
        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
        0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
    };
    struct byte_string key = {0};
    key.value = value;
    key.size = ARRAY_LENGTH(value);
    
    struct key_value kv = {0};
    kv.key_material = &key;
    
    struct key_block expected = {0};
    kmip_init_key_block(&expected);
    
    expected.key_format_type = KMIP_KEYFORMAT_RAW;
    expected.key_value = &kv;
    expected.key_value_type = KMIP_TYPE_STRUCTURE;
    expected.cryptographic_algorithm = KMIP_CRYPTOALG_AES;
    expected.cryptographic_length = 128;
    
    struct key_block observed = {0};
    kmip_init_key_block(&observed);
    
    int result = kmip_decode_key_block(&ctx, &observed);
    result = report_decoding_test_result(
        tracker,
        &ctx,
        kmip_compare_key_block(&expected, &observed),
        result,
        __func__);
    kmip_free_key_block(&ctx, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x990, %rsp            # imm = 0x990
movq %rdi, %r14
incw (%rdi)
leaq 0x208ad(%rip), %rsi     # 0x292b0
pushq $0xb
popq %rcx
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xf8(%rsp), %rbx
movl $0x898, %edx            # imm = 0x898
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10c0
pushq $0x58
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x128ed
movaps 0x1d6ce(%rip), %xmm0    # 0x26110
movq %rsp, %rax
movaps %xmm0, (%rax)
leaq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq $0x10, 0x8(%rcx)
xorps %xmm0, %xmm0
leaq 0x28(%rsp), %r15
movups %xmm0, 0x8(%r15)
movq %rcx, (%r15)
leaq 0x70(%rsp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
andq $0x0, 0x20(%r12)
movq %r12, %rdi
callq 0x12eac
movl $0x1, (%r12)
movq %r15, 0x8(%r12)
movabsq $0x300000001, %rax      # imm = 0x300000001
movq %rax, 0x10(%r12)
movl $0x80, 0x18(%r12)
leaq 0x40(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
andq $0x0, 0x20(%r15)
movq %r15, %rdi
callq 0x12eac
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1d621
movl %eax, %ebp
movq %r12, %rdi
movq %r15, %rsi
callq 0x153e5
leaq 0x1e60e(%rip), %r8      # 0x270f6
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x134d
movl %eax, %ebp
movq %rbx, %rdi
movq %r15, %rsi
callq 0x135ab
movq %rbx, %rdi
callq 0x12ade
movl %ebp, %eax
addq $0x990, %rsp            # imm = 0x990
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq