// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_encode_request_batch_item
int
kmip_encode_request_batch_item(KMIP *ctx, const RequestBatchItem *value)
{
    CHECK_ENCODE_ARGS(ctx, value);

    int result = 0;
    result = kmip_encode_int32_be(ctx, TAG_TYPE(KMIP_TAG_BATCH_ITEM, KMIP_TYPE_STRUCTURE));
    CHECK_RESULT(ctx, result);
    
    uint8 *length_index = ctx->index;
    uint8 *value_index = ctx->index += 4;
    
    result = kmip_encode_enum(ctx, KMIP_TAG_OPERATION, value->operation);
    CHECK_RESULT(ctx, result);

    if(ctx->version >= KMIP_2_0)
    {
        if(value->ephemeral != KMIP_UNSET)
        {
            result=kmip_encode_bool(ctx, KMIP_TAG_EPHEMERAL, value->ephemeral);
            CHECK_RESULT(ctx, result);
        }
    }

    if(value->unique_batch_item_id != NULL)
    {
        result = kmip_encode_byte_string(ctx, KMIP_TAG_UNIQUE_BATCH_ITEM_ID, value->unique_batch_item_id);
        CHECK_RESULT(ctx, result);
    }
    
    switch(value->operation)
    {
        case KMIP_OP_CREATE:
        result = kmip_encode_create_request_payload(ctx, (CreateRequestPayload*)value->request_payload);
        break;
        
        case KMIP_OP_GET:
        result = kmip_encode_get_request_payload(ctx, (GetRequestPayload*)value->request_payload);
        break;
        
        case KMIP_OP_DESTROY:
        result = kmip_encode_destroy_request_payload(ctx, (DestroyRequestPayload*)value->request_payload);
        break;
        
        case KMIP_OP_QUERY:
        result = kmip_encode_query_request_payload(ctx, (QueryRequestPayload*)value->request_payload);
        break;

        default:
        kmip_push_error_frame(ctx, __func__, __LINE__);
        return(KMIP_NOT_IMPLEMENTED);
        break;
    };
    CHECK_RESULT(ctx, result);
    
    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 %r12
pushq %rbx
testq %rdi, %rdi
je 0xe6a0
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xe6dc
movq %rdi, %rbx
movl $0x42000f01, %esi       # imm = 0x42000F01
callq 0x60a0
testl %eax, %eax
je 0xe6a5
movl %eax, %ebp
leaq 0x9615(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x2005, %edx           # imm = 0x2005
jmp 0xe6d7
pushq $-0x11
popq %rbp
jmp 0xe6dc
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movl (%r14), %edx
movq %rbx, %rdi
movl $0x42005c, %esi         # imm = 0x42005C
callq 0x6700
testl %eax, %eax
je 0xe6e7
movl %eax, %ebp
leaq 0x95dc(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x200b, %edx           # imm = 0x200B
callq 0x6e80
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x5, 0x18(%rbx)
jb 0xe71a
movl 0x18(%r14), %edx
cmpl $-0x1, %edx
je 0xe71a
movq %rbx, %rdi
movl $0x420154, %esi         # imm = 0x420154
callq 0x6590
testl %eax, %eax
je 0xe71a
movl %eax, %ebp
leaq 0x959b(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x2012, %edx           # imm = 0x2012
jmp 0xe6d7
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0xe747
movq %rbx, %rdi
movl $0x420093, %esi         # imm = 0x420093
callq 0x6cb0
testl %eax, %eax
je 0xe747
movl %eax, %ebp
leaq 0x956e(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x2019, %edx           # imm = 0x2019
jmp 0xe6d7
movl (%r14), %eax
cmpl $0x18, %eax
je 0xe78c
cmpl $0xa, %eax
je 0xe770
cmpl $0x14, %eax
je 0xe77e
cmpl $0x1, %eax
jne 0xe7e2
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6870
jmp 0xe798
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6160
jmp 0xe798
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6210
jmp 0xe798
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6530
movl %eax, %ebp
testl %eax, %eax
je 0xe7b2
leaq 0x9506(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x2033, %edx           # imm = 0x2033
jmp 0xe6d7
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6b10
testl %eax, %eax
je 0xe7fd
movl %eax, %ebp
leaq 0x94d6(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x2039, %edx           # imm = 0x2039
jmp 0xe6d7
leaq 0x94c2(%rip), %rsi      # 0x17cab
movq %rbx, %rdi
movl $0x202f, %edx           # imm = 0x202F
callq 0x6e80
pushq $-0x1
jmp 0xe6a2
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xe6dc