// File: /workspace/github_c_makefile_star2_O1/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 0xfa56
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xfc16
movq %rdi, %rbx
movl $0x42000f01, %esi       # imm = 0x42000F01
callq 0x60a0
testl %eax, %eax
je 0xfa60
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xfaa4
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xfa3c
jmp 0xfc16
movl $0xffffffef, %ebp       # imm = 0xFFFFFFEF
jmp 0xfc16
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movl (%r14), %edx
movq %rbx, %rdi
movl $0x42005c, %esi         # imm = 0x42005C
callq 0x66d0
testl %eax, %eax
je 0xfad0
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xfb06
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xfa8a
jmp 0xfc16
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x10053(%rip), %rsi     # 0x1fb08
movl $0x63, %edx
callq 0x66f0
movl $0x2005, 0x9c(%rbx,%r14) # imm = 0x2005
jmp 0xfc16
cmpl $0x5, 0x18(%rbx)
jb 0xfb32
movl 0x18(%r14), %edx
cmpl $-0x1, %edx
je 0xfb32
movq %rbx, %rdi
movl $0x420154, %esi         # imm = 0x420154
callq 0x6570
testl %eax, %eax
je 0xfb32
movl %eax, %ebp
leaq 0x119e0(%rip), %rsi     # 0x214d9
movq %rbx, %rdi
movl $0x2012, %edx           # imm = 0x2012
jmp 0xfc11
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0xfff1(%rip), %rsi      # 0x1fb08
movl $0x63, %edx
callq 0x66f0
movl $0x200b, 0x9c(%rbx,%r14) # imm = 0x200B
jmp 0xfc16
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0xfb62
movq %rbx, %rdi
movl $0x420093, %esi         # imm = 0x420093
callq 0x6c10
testl %eax, %eax
je 0xfb62
movl %eax, %ebp
leaq 0x11984(%rip), %rsi     # 0x214d9
movq %rbx, %rdi
movl $0x2019, %edx           # imm = 0x2019
jmp 0xfc11
movl (%r14), %eax
cmpl $0x13, %eax
jg 0xfb82
cmpl $0x1, %eax
je 0xfbb5
cmpl $0xa, %eax
jne 0xfb9a
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6160
jmp 0xfbcf
cmpl $0x14, %eax
je 0xfbc3
cmpl $0x18, %eax
jne 0xfb9a
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6510
jmp 0xfbcf
leaq 0x11938(%rip), %rsi     # 0x214d9
movq %rbx, %rdi
movl $0x202f, %edx           # imm = 0x202F
callq 0x6de0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xfc16
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6830
jmp 0xfbcf
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6200
movl %eax, %ebp
testl %eax, %eax
je 0xfbe6
leaq 0x118fd(%rip), %rsi     # 0x214d9
movq %rbx, %rdi
movl $0x2033, %edx           # imm = 0x2033
jmp 0xfc11
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xfc21
movl %eax, %ebp
leaq 0x118d0(%rip), %rsi     # 0x214d9
movq %rbx, %rdi
movl $0x2039, %edx           # imm = 0x2039
callq 0x6de0
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xfc16