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

    uint8 encoding[144] = {
        0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x88, 
        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, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17, 
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C, 
        0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00, 
        0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65, 
        0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x0B, 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 attribute attributes[2] = {0};
    for(size_t i = 0; i < 2; i++)
    {
        kmip_init_attribute(&attributes[i]);
    }
    
    enum cryptographic_algorithm ca = KMIP_CRYPTOALG_AES;
    int length = 128;
    attributes[0].type = KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM;
    attributes[0].value = &ca;
    attributes[1].type = KMIP_ATTR_CRYPTOGRAPHIC_LENGTH;
    attributes[1].value = &length;
    
    struct key_value expected = {0};
    expected.key_material = &key;
    expected.attributes = attributes;
    expected.attribute_count = ARRAY_LENGTH(attributes);
    struct key_value observed = {0};
    
    int result = kmip_decode_key_value(&ctx, KMIP_KEYFORMAT_RAW, &observed);
    result = report_decoding_test_result(
        tracker,
        &ctx,
        kmip_compare_key_value(KMIP_KEYFORMAT_RAW, &expected, &observed),
        result,
        __func__);
    kmip_free_key_value(&ctx, KMIP_KEYFORMAT_RAW, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x9a8, %rsp            # imm = 0x9A8
movq %rdi, %rbx
incw (%rdi)
leaq 0x20c94(%rip), %rsi     # 0x29140
leaq 0x80(%rsp), %r14
movl $0x90, %edx
movq %r14, %rdi
callq 0x1100
leaq 0x110(%rsp), %r15
xorl %r12d, %r12d
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0x90, %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x128ed
movaps 0x1dc1c(%rip), %xmm0    # 0x26110
leaq 0x40(%rsp), %rax
movaps %xmm0, (%rax)
movq %rax, 0x10(%rsp)
movq $0x10, 0x18(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
cmpq $0x20, %r12
je 0x8530
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0x12e6d
addq $0x10, %r12
jmp 0x8517
pushq $0x3
popq %rax
leaq 0xc(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x8(%rsp), %rdx
movl $0x80, (%rdx)
leaq 0x20(%rsp), %rsi
movl %eax, (%rsi)
movq %rcx, 0x8(%rsi)
movl $0x4, 0x10(%rsi)
movq %rdx, 0x18(%rsi)
leaq 0x10(%rsp), %rax
leaq 0x68(%rsp), %r12
movq %rax, (%r12)
movq %rsi, 0x8(%r12)
movq $0x2, 0x10(%r12)
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0x110(%rsp), %r14
pushq $0x1
popq %rbp
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x1ce8b
movl %eax, %r13d
movl %ebp, %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1516c
leaq 0x1ea97(%rip), %r8      # 0x2704e
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %edx
movl %r13d, %ecx
callq 0x134d
movl %eax, %ebx
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x133a6
movq %r14, %rdi
callq 0x12ade
movl %ebx, %eax
addq $0x9a8, %rsp            # imm = 0x9A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq