// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xab0, %rsp            # imm = 0xAB0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x130(%rbp), %rdi
leaq 0x302b5(%rip), %rsi     # 0x45950
movl $0x120, %edx            # imm = 0x120
callq 0x10c0
leaq -0x9c8(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x130(%rbp), %rsi
leaq -0x9c8(%rbp), %rdi
movl $0x120, %edx            # imm = 0x120
xorl %ecx, %ecx
callq 0x1c6e0
leaq -0x9d8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x2a026(%rip), %rax     # 0x3f712
movq %rax, -0x9d8(%rbp)
movq $0x9, -0x9d0(%rbp)
leaq -0x9e8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x9d8(%rbp), %rax
movq %rax, -0x9e8(%rbp)
movl $0x1, -0x9e0(%rbp)
leaq -0xa30(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x1090
movl $0x0, -0xa34(%rbp)
cmpl $0x4, -0xa34(%rbp)
jge 0x1577a
movslq -0xa34(%rbp), %rax
leaq -0xa30(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x1d330
movl -0xa34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa34(%rbp)
jmp 0x15746
movl $0x3, -0xa38(%rbp)
movl $0x3, -0xa30(%rbp)
leaq -0xa38(%rbp), %rax
movq %rax, -0xa28(%rbp)
movl $0x80, -0xa3c(%rbp)
movl $0x4, -0xa20(%rbp)
leaq -0xa3c(%rbp), %rax
movq %rax, -0xa18(%rbp)
movl $0xc, -0xa40(%rbp)
movl $0x6, -0xa10(%rbp)
leaq -0xa40(%rbp), %rax
movq %rax, -0xa08(%rbp)
leaq -0xa50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x2b644(%rip), %rax     # 0x40e3e
movq %rax, -0xa50(%rbp)
movq $0x4, -0xa48(%rbp)
leaq -0xa60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xa50(%rbp), %rax
movq %rax, -0xa60(%rbp)
movl $0x1, -0xa58(%rbp)
movl $0x1, -0xa00(%rbp)
leaq -0xa60(%rbp), %rax
movq %rax, -0x9f8(%rbp)
leaq -0xa80(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
leaq -0x9e8(%rbp), %rax
movq %rax, -0xa80(%rbp)
movq $0x1, -0xa78(%rbp)
leaq -0xa30(%rbp), %rax
movq %rax, -0xa70(%rbp)
movq $0x4, -0xa68(%rbp)
leaq -0xaa0(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
leaq -0x9c8(%rbp), %rdi
leaq -0xaa0(%rbp), %rsi
callq 0x2f4c0
movl %eax, -0xaa4(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xab0(%rbp)
leaq -0xa80(%rbp), %rdi
leaq -0xaa0(%rbp), %rsi
callq 0x216d0
movq -0xab0(%rbp), %rdi
movl %eax, %edx
movl -0xaa4(%rbp), %ecx
leaq -0x9c8(%rbp), %rsi
leaq 0x2b567(%rip), %r8      # 0x40e62
callq 0x13a0
movl %eax, -0xaa4(%rbp)
leaq -0x9c8(%rbp), %rdi
leaq -0xaa0(%rbp), %rsi
callq 0x1dc60
leaq -0x9c8(%rbp), %rdi
callq 0x1cab0
movl -0xaa4(%rbp), %eax
addq $0xab0, %rsp            # imm = 0xAB0
popq %rbp
retq
nopw %cs:(%rax,%rax)