// File: /workspace/github_c_makefile_star2_O1/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_encode_protection_storage_masks
int
kmip_encode_protection_storage_masks(KMIP *ctx, const ProtectionStorageMasks *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_PROTECTION_STORAGE_MASKS, KMIP_TYPE_STRUCTURE)
    );
    CHECK_RESULT(ctx, result);

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

    if(value->masks != NULL)
    {
        LinkedListItem *curr = value->masks->head;
        while(curr != NULL)
        {
            result = kmip_encode_integer(ctx, KMIP_TAG_PROTECTION_STORAGE_MASK, *(int32 *)curr->data);
            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 0xc9d2
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xcb62
movq %rdi, %rbx
cmpl $0x4, 0x18(%rdi)
ja 0xc9dc
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xca14
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xc9bb
jmp 0xca3b
movl $0xffffffef, %ebp       # imm = 0xFFFFFFEF
jmp 0xcb62
movq %rbx, %rdi
movl $0x42015f01, %esi       # imm = 0x42015F01
callq 0x60a0
testl %eax, %eax
je 0xca45
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xcaa1
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xc9f6
jmp 0xcb62
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12e8b(%rip), %rsi     # 0x1f8b0
movl $0x63, %edx
callq 0x66f0
movl $0x18db, 0x9c(%rbx,%r14) # imm = 0x18DB
movl $0xfffffff5, %ebp       # imm = 0xFFFFFFF5
jmp 0xcb62
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movq (%r14), %r14
testq %r14, %r14
je 0xcaf9
movq (%r14), %r14
testq %r14, %r14
je 0xcaf4
movq 0x10(%r14), %rax
movl (%rax), %edx
movq %rbx, %rdi
movl $0x42015e, %esi         # imm = 0x42015E
callq 0x63d0
testl %eax, %eax
je 0xca5e
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r13d, %r13d
cmpl $0x0, 0x64(%rdi,%r13)
je 0xcacd
addq $0x68, %r13
cmpq $0x820, %r13            # imm = 0x820
jne 0xca8a
jmp 0xcaf4
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12dfe(%rip), %rsi     # 0x1f8b0
movl $0x63, %edx
callq 0x66f0
movl $0x18e3, 0x9c(%rbx,%r14) # imm = 0x18E3
jmp 0xcb62
addq %r13, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12dd2(%rip), %rsi     # 0x1f8b0
movl $0x63, %edx
callq 0x66f0
movl $0x18ee, 0x9c(%rbx,%r13) # imm = 0x18EE
testq %r14, %r14
jne 0xcb62
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xcb33
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xcb3b
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xcb1c
jmp 0xcb62
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xcb62
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x12d64(%rip), %rsi     # 0x1f8b0
movl $0x63, %edx
callq 0x66f0
movl $0x18f8, 0x9c(%rbx,%r14) # imm = 0x18F8
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq