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

    uint8 encoding[288] = {
        0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x01, 0x18, 
        0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28, 
        0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09, 
        0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65, 
        0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
        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, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18, 
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73, 
        0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B, 
        0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x38, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04, 
        0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x20, 
        0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x04, 
        0x4B, 0x65, 0x79, 0x31, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
    };
    
    struct kmip ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_1_0);
    
    struct text_string v = {0};
    v.value = "Template1";
    v.size = 9;
    
    struct name n = {0};
    n.value = &v;
    n.type = KMIP_NAME_UNINTERPRETED_TEXT_STRING;
    
    struct attribute a[4] = {0};
    for(int i = 0; i < 4; i++)
    {
        kmip_init_attribute(&a[i]);
    }
    
    enum cryptographic_algorithm algorithm = KMIP_CRYPTOALG_AES;
    a[0].type = KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM;
    a[0].value = &algorithm;
    
    int32 length = 128;
    a[1].type = KMIP_ATTR_CRYPTOGRAPHIC_LENGTH;
    a[1].value = &length;
    
    int32 mask = KMIP_CRYPTOMASK_ENCRYPT | KMIP_CRYPTOMASK_DECRYPT;
    a[2].type = KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK;
    a[2].value = &mask;
    
    struct text_string value = {0};
    value.value = "Key1";
    value.size = 4;
    
    struct name name = {0};
    name.value = &value;
    name.type = KMIP_NAME_UNINTERPRETED_TEXT_STRING;
    a[3].type = KMIP_ATTR_NAME;
    a[3].value = &name;
    
    struct template_attribute expected = {0};
    expected.names = &n;
    expected.name_count = 1;
    expected.attributes = a;
    expected.attribute_count = ARRAY_LENGTH(a);
    struct template_attribute observed = {0};
    
    int result = kmip_decode_template_attribute(&ctx, &observed);
    result = report_decoding_test_result(
        tracker,
        &ctx,
        kmip_compare_template_attribute(&expected, &observed),
        result,
        __func__);
    kmip_free_template_attribute(&ctx, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa90, %rsp            # imm = 0xA90
movq %rdi, %rbx
incw (%rdi)
leaq 0x24bf4(%rip), %rsi     # 0x33a50
leaq 0xd0(%rsp), %r14
movl $0x120, %edx            # imm = 0x120
movq %r14, %rdi
callq 0x1100
leaq 0x1f8(%rsp), %r15
xorl %r12d, %r12d
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x13747
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x2092e(%rip), %rcx     # 0x2f7e0
movq %rcx, (%rax)
movq $0x9, 0x8(%rax)
movaps %xmm0, (%rsp)
movq %rax, (%rsp)
movl $0x1, 0x8(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0x13e59
addq $0x10, %r12
cmpq $0x40, %r12
jne 0xeee1
movl $0x3, %ecx
leaq 0x1c(%rsp), %rdx
movl %ecx, (%rdx)
leaq 0x20(%rsp), %rax
movl %ecx, (%rax)
movq %rdx, 0x8(%rax)
leaq 0x18(%rsp), %rcx
movl $0x80, (%rcx)
movl $0x4, 0x10(%rax)
movq %rcx, 0x18(%rax)
leaq 0x14(%rsp), %rcx
movl $0xc, (%rcx)
movl $0x6, 0x20(%rax)
movq %rcx, 0x28(%rax)
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x21fa9(%rip), %rdx     # 0x30ef6
movq %rdx, (%rcx)
movl $0x4, %edx
movq %rdx, 0x8(%rcx)
leaq 0x60(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %rcx, (%rsi)
movl $0x1, %ecx
movl %ecx, 0x8(%rsi)
movl %ecx, 0x30(%rax)
movq %rsi, 0x38(%rax)
leaq 0xb0(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movq %rsp, %rcx
movq %rcx, (%r14)
movq $0x1, 0x8(%r14)
movq %rax, 0x10(%r14)
movq %rdx, 0x18(%r14)
leaq 0x90(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x1f8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x20933
movl %eax, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x16640
leaq 0x21f48(%rip), %r8      # 0x30f1a
movq %rbx, %rdi
movq %r12, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x1397
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x14306
movq %r12, %rdi
callq 0x13a23
movl %ebx, %eax
addq $0xa90, %rsp            # imm = 0xA90
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq