// File: /workspace/github_c_makefile_star2_O3/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 0x22f6e(%rip), %rsi     # 0x31a40
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 0x13177
leaq 0x1ecc6(%rip), %rax     # 0x2d7e0
leaq 0x80(%rsp), %rcx
movq %rax, (%rcx)
movq $0x9, 0x8(%rcx)
movq $0x0, 0x8(%rsp)
movq %rcx, (%rsp)
movl $0x1, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0x1388b
addq $0x10, %r12
cmpq $0x40, %r12
jne 0xeb59
movl $0x3, %eax
leaq 0x1c(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x20(%rsp), %rdx
movl %eax, (%rdx)
movq %rcx, 0x8(%rdx)
leaq 0x18(%rsp), %rax
movl $0x80, (%rax)
movl $0x4, 0x10(%rdx)
movq %rax, 0x18(%rdx)
leaq 0x14(%rsp), %rax
movl $0xc, (%rax)
movl $0x6, 0x20(%rdx)
movq %rax, 0x28(%rdx)
leaq 0x2033c(%rip), %rax     # 0x2eef6
leaq 0x70(%rsp), %rcx
movq %rax, (%rcx)
movl $0x4, %eax
movq %rax, 0x8(%rcx)
leaq 0x60(%rsp), %rsi
movq $0x0, 0x8(%rsi)
movq %rcx, (%rsi)
movl $0x1, %ecx
movl %ecx, 0x8(%rsi)
movl %ecx, 0x30(%rdx)
movq %rsi, 0x38(%rdx)
movq %rsp, %rcx
leaq 0xb0(%rsp), %r14
movq %rcx, (%r14)
movq $0x1, 0x8(%r14)
movq %rdx, 0x10(%r14)
movq %rax, 0x18(%r14)
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x1f8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1faa6
movl %eax, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x15ff4
leaq 0x202d7(%rip), %r8      # 0x2ef1a
movq %rbx, %rdi
movq %r12, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x1363
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x13d2f
movq %r12, %rdi
callq 0x13455
movl %ebx, %eax
addq $0xa90, %rsp            # imm = 0xA90
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq