// File: /workspace/github_c_makefile_star2_O3/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 0xd441
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xd5d5
movq %rdi, %rbx
cmpl $0x4, 0x18(%rdi)
ja 0xd44b
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd483
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd42a
jmp 0xd4aa
movl $0xffffffef, %ebp       # imm = 0xFFFFFFEF
jmp 0xd5d5
movq %rbx, %rdi
movl $0x42012501, %esi       # imm = 0x42012501
callq 0x60a0
testl %eax, %eax
je 0xd4b4
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd535
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd465
jmp 0xd5d5
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x11558(%rip), %rsi     # 0x1e9ec
movl $0x63, %edx
callq 0x66f0
movl $0x1a9c, 0x9c(%rbx,%r14) # imm = 0x1A9C
movl $0xfffffff5, %ebp       # imm = 0xFFFFFFF5
jmp 0xd5d5
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movq (%r14), %rax
movq %r15, %r14
testq %rax, %rax
je 0xd4fc
movq (%rax), %r13
movq %r15, %r14
testq %r13, %r13
je 0xd4fc
leaq 0x38(%rbx), %r14
movq 0x10(%r13), %rsi
movq %rbx, %rdi
callq 0x6a90
testl %eax, %eax
jne 0xd58f
movq (%r13), %r13
testq %r13, %r13
jne 0xd4db
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xd55e
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xd566
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xd51b
jmp 0xd5d5
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x114a6(%rip), %rsi     # 0x1e9ec
movl $0x63, %edx
callq 0x66f0
movl $0x1aa4, 0x9c(%rbx,%r14) # imm = 0x1AA4
jmp 0xd5d5
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xd5d5
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x11475(%rip), %rsi     # 0x1e9ec
movl $0x63, %edx
callq 0x66f0
movl $0x1aba, 0x9c(%rbx,%r14) # imm = 0x1ABA
jmp 0xd5d5
movl %eax, %ebp
xorl %r15d, %r15d
cmpl $0x0, 0x64(%r14,%r15)
je 0xd5ab
addq $0x68, %r15
cmpq $0x820, %r15            # imm = 0x820
jne 0xd594
jmp 0xd5d5
addq %r15, %r14
movq %r14, 0x860(%rbx)
leaq 0x11430(%rip), %rsi     # 0x1e9ec
movl $0x63, %edx
movq %r14, %rdi
callq 0x66f0
movl $0x1ab0, 0x9c(%rbx,%r15) # imm = 0x1AB0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq