// File: /workspace/github_c_makefile_star2_O3/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 0xf662
movq %rsi, %r14
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xf822
movq %rdi, %rbx
movl $0x42000f01, %esi       # imm = 0x42000F01
callq 0x60a0
testl %eax, %eax
je 0xf66c
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xf6b0
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xf648
jmp 0xf822
movl $0xffffffef, %ebp       # imm = 0xFFFFFFEF
jmp 0xf822
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 0xf6dc
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0xf712
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0xf696
jmp 0xf822
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0xf4bb(%rip), %rsi      # 0x1eb7c
movl $0x63, %edx
callq 0x66f0
movl $0x2005, 0x9c(%rbx,%r14) # imm = 0x2005
jmp 0xf822
cmpl $0x5, 0x18(%rbx)
jb 0xf73e
movl 0x18(%r14), %edx
cmpl $-0x1, %edx
je 0xf73e
movq %rbx, %rdi
movl $0x420154, %esi         # imm = 0x420154
callq 0x6570
testl %eax, %eax
je 0xf73e
movl %eax, %ebp
leaq 0x10e44(%rip), %rsi     # 0x20549
movq %rbx, %rdi
movl $0x2012, %edx           # imm = 0x2012
jmp 0xf81d
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0xf459(%rip), %rsi      # 0x1eb7c
movl $0x63, %edx
callq 0x66f0
movl $0x200b, 0x9c(%rbx,%r14) # imm = 0x200B
jmp 0xf822
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0xf76e
movq %rbx, %rdi
movl $0x420093, %esi         # imm = 0x420093
callq 0x6c10
testl %eax, %eax
je 0xf76e
movl %eax, %ebp
leaq 0x10de8(%rip), %rsi     # 0x20549
movq %rbx, %rdi
movl $0x2019, %edx           # imm = 0x2019
jmp 0xf81d
movl (%r14), %eax
cmpl $0x13, %eax
jg 0xf78e
cmpl $0x1, %eax
je 0xf7c1
cmpl $0xa, %eax
jne 0xf7a6
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6160
jmp 0xf7db
cmpl $0x14, %eax
je 0xf7cf
cmpl $0x18, %eax
jne 0xf7a6
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6510
jmp 0xf7db
leaq 0x10d9c(%rip), %rsi     # 0x20549
movq %rbx, %rdi
movl $0x202f, %edx           # imm = 0x202F
callq 0x6de0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xf822
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6830
jmp 0xf7db
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6200
movl %eax, %ebp
testl %eax, %eax
je 0xf7f2
leaq 0x10d61(%rip), %rsi     # 0x20549
movq %rbx, %rdi
movl $0x2033, %edx           # imm = 0x2033
jmp 0xf81d
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6a80
testl %eax, %eax
je 0xf82d
movl %eax, %ebp
leaq 0x10d34(%rip), %rsi     # 0x20549
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 0xf822