// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_decode_template_attribute
int
kmip_decode_template_attribute(KMIP *ctx, TemplateAttribute *value)
{
    CHECK_BUFFER_FULL(ctx, 8);
    
    int result = 0;
    int32 tag_type = 0;
    uint32 length = 0;
    
    kmip_decode_int32_be(ctx, &tag_type);
    CHECK_TAG_TYPE(ctx, tag_type, KMIP_TAG_TEMPLATE_ATTRIBUTE, KMIP_TYPE_STRUCTURE);
    
    kmip_decode_length(ctx, &length);
    CHECK_BUFFER_FULL(ctx, length);
    
    value->name_count = kmip_get_num_items_next(ctx, KMIP_TAG_NAME);
    if(value->name_count > 0)
    {
        value->names = ctx->calloc_func(ctx->state, value->name_count, sizeof(Name));
        CHECK_NEW_MEMORY(ctx, value->names, value->name_count * sizeof(Name), "sequence of Name structures");
        
        for(size_t i = 0; i < value->name_count; i++)
        {
            result = kmip_decode_name(ctx, &value->names[i]);
            CHECK_RESULT(ctx, result);
        }
    }
    
    value->attribute_count = kmip_get_num_items_next(ctx, KMIP_TAG_ATTRIBUTE);
    if(value->attribute_count > 0)
    {
        value->attributes = ctx->calloc_func(ctx->state, value->attribute_count, sizeof(Attribute));
        CHECK_NEW_MEMORY(ctx, value->attributes, value->attribute_count * sizeof(Attribute), "sequence of Attribute structures");
        
        for(size_t i = 0; i < value->attribute_count; i++)
        {
            result = kmip_decode_attribute(ctx, &value->attributes[i]);
            CHECK_RESULT(ctx, result);
        }
    }
    
    return(KMIP_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
addq (%rdi), %rax
cmpq $0x7, %rax
ja 0x1179d
leaq 0x695a(%rip), %rsi      # 0x180e1
movq %rbx, %rdi
movl $0x2481, %edx           # imm = 0x2481
callq 0x6e80
pushq $-0x2
popq %r12
jmp 0x1181f
movq %rsi, %r14
leaq 0x24(%rsp), %r15
andl $0x0, (%r15)
andl $0x0, 0x14(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6a80
movl (%r15), %eax
movl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
movl $0x2488, %ebp           # imm = 0x2488
cmpl $0x42009100, %ecx       # imm = 0x42009100
jne 0x11803
cmpb $0x1, %al
jne 0x11807
leaq 0x14(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x64d0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
addq (%rbx), %rax
movl (%r15), %ecx
cmpq %rcx, %rax
jae 0x11831
pushq $-0x2
popq %r15
movl $0x248b, %ebp           # imm = 0x248B
jmp 0x1180b
pushq $-0x4
jmp 0x11809
pushq $-0x5
popq %r15
leaq 0x68cf(%rip), %rsi      # 0x180e1
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6e80
movl %r15d, %r12d
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x420053, %esi         # imm = 0x420053
callq 0x6310
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x118a5
leaq 0x8(%r14), %rcx
movq %rcx, 0x8(%rsp)
movq 0x890(%rbx), %rdi
pushq $0x10
popq %rdx
movq %rax, %rsi
callq *0x868(%rbx)
movq %rax, (%r14)
testq %rax, %rax
je 0x11925
pushq $-0x1
popq %r12
xorl %esi, %esi
movl $0x2496, %ebp           # imm = 0x2496
incq %r12
movq 0x8(%rsp), %rax
cmpq (%rax), %r12
jae 0x118a5
leaq 0x10(%rsi), %r13
addq (%r14), %rsi
movq %rbx, %rdi
callq 0x6e60
movl %eax, %r15d
movq %r13, %rsi
testl %eax, %eax
je 0x1187a
jmp 0x1180b
movq %rbx, %rdi
movl $0x420008, %esi         # imm = 0x420008
callq 0x6310
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x11933
leaq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
movq 0x890(%rbx), %rdi
pushq $0x10
popq %rdx
movq %rax, %rsi
callq *0x868(%rbx)
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x1193b
pushq $-0x1
popq %r13
xorl %r12d, %r12d
xorl %esi, %esi
movl $0x24a3, %ebp           # imm = 0x24A3
incq %r13
movq 0x8(%rsp), %rax
cmpq (%rax), %r13
jae 0x1181f
leaq 0x10(%rsi), %rax
movq %rax, 0x18(%rsp)
addq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6830
movl %eax, %r15d
movq 0x18(%rsp), %rsi
testl %eax, %eax
je 0x118ee
jmp 0x1180b
movl $0x2491, %ebp           # imm = 0x2491
leaq 0x67cf(%rip), %rdx      # 0x18100
jmp 0x11947
xorl %r12d, %r12d
jmp 0x1181f
movl $0x249e, %ebp           # imm = 0x249E
leaq 0x67d5(%rip), %rdx      # 0x1811c
movq 0x8(%rsp), %rax
movq (%rax), %rsi
shlq $0x4, %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
jmp 0x11809