// File: /workspace/github_c_makefile_star2_O1/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_encode_attributes
int
kmip_encode_attributes(KMIP *ctx, const Attributes *value)
{
    CHECK_ENCODE_ARGS(ctx, value);
    CHECK_KMIP_VERSION(ctx, KMIP_2_0);

    int result = 0;

    result = kmip_encode_int32_be(
        ctx,
        TAG_TYPE(KMIP_TAG_ATTRIBUTES, KMIP_TYPE_STRUCTURE)
    );
    CHECK_RESULT(ctx, result);

    uint8 *length_index = ctx->index;
    uint8 *value_index = ctx->index += 4;

    if(value->attribute_list != NULL)
    {
        LinkedListItem *curr = value->attribute_list->head;
        while(curr != NULL)
        {
            Attribute *attribute = (Attribute *)curr->data;
            result = kmip_encode_attribute(ctx, attribute);
            CHECK_RESULT(ctx, result);

            curr = curr->next;
        }
    }

    uint8 *curr_index = ctx->index;
    ctx->index = length_index;

    result = kmip_encode_length(ctx, curr_index - value_index);
    CHECK_RESULT(ctx, result);

    ctx->index = curr_index;

    return(KMIP_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xd699
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xd83b
movq %rdi, %rbx
cmpl $0x4, 0x18(%rdi)
ja 0xd6a3
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd6db
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd682
jmp 0xd702
movl $0xffffffef, %ebp       # imm = 0xFFFFFFEF
jmp 0xd83b
movq %rbx, %rdi
movl $0x42012501, %esi       # imm = 0x42012501
callq 0x60a0
testl %eax, %eax
je 0xd70c
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd7e3
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd6bd
jmp 0xd83b
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x1228c(%rip), %rsi     # 0x1f978
movl $0x63, %edx
callq 0x66f0
movl $0x1a9c, 0x9c(%rbx,%r14) # imm = 0x1A9C
movl $0xfffffff5, %ebp       # imm = 0xFFFFFFF5
jmp 0xd83b
movq 0x8(%rbx), %r13
leaq 0x4(%r13), %rcx
movq %rcx, 0x8(%rbx)
movq (%r14), %rax
testq %rax, %rax
je 0xd7a9
movq %rcx, (%rsp)
movq (%rax), %rax
leaq 0x38(%rbx), %r14
movq %rax, %r12
testq %rax, %rax
je 0xd79c
movq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x6a90
movl %eax, %r15d
testl %eax, %eax
je 0xd764
xorl %ebp, %ebp
cmpl $0x0, 0x64(%r14,%rbp)
je 0xd76a
addq $0x68, %rbp
cmpq $0x820, %rbp            # imm = 0x820
jne 0xd74d
jmp 0xd791
movq (%r12), %rax
jmp 0xd797
leaq (%r14,%rbp), %rdi
movq %rdi, 0x860(%rbx)
movl $0x63, %edx
leaq 0x121f7(%rip), %rsi     # 0x1f978
callq 0x66f0
movl $0x1ab0, 0x9c(%rbx,%rbp) # imm = 0x1AB0
movq %r12, %rax
movl %r15d, %ebp
testl %r15d, %r15d
je 0xd72f
testq %r12, %r12
movq (%rsp), %rcx
jne 0xd83b
movq 0x8(%rbx), %r14
movq %r13, 0x8(%rbx)
movq %r14, %rsi
subq %rcx, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xd80c
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd814
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd7cc
jmp 0xd83b
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12184(%rip), %rsi     # 0x1f978
movl $0x63, %edx
callq 0x66f0
movl $0x1aa4, 0x9c(%rbx,%r14) # imm = 0x1AA4
jmp 0xd83b
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xd83b
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12153(%rip), %rsi     # 0x1f978
movl $0x63, %edx
callq 0x66f0
movl $0x1aba, 0x9c(%rbx,%r14) # imm = 0x1ABA
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq