// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_decode_response_batch_item
int
kmip_decode_response_batch_item(KMIP *ctx, ResponseBatchItem *value)
{
    CHECK_BUFFER_FULL(ctx, 8);
    
    int result = 0;
    int32 tag_type = 0;
    uint32 length = 0;
    
    kmip_decode_int32_be(ctx, &tag_type);
    CHECK_TAG_TYPE(ctx, tag_type, KMIP_TAG_BATCH_ITEM, KMIP_TYPE_STRUCTURE);
    
    kmip_decode_length(ctx, &length);
    CHECK_BUFFER_FULL(ctx, length);
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_OPERATION))
    {
        result = kmip_decode_enum(ctx, KMIP_TAG_OPERATION, &value->operation);
        CHECK_RESULT(ctx, result);
        CHECK_ENUM(ctx, KMIP_TAG_OPERATION, value->operation);
    }
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_UNIQUE_BATCH_ITEM_ID))
    {
        value->unique_batch_item_id = ctx->calloc_func(ctx->state, 1, sizeof(ByteString));
        CHECK_NEW_MEMORY(ctx, value->unique_batch_item_id, sizeof(ByteString), "UniqueBatchItemID byte string");
        
        result = kmip_decode_byte_string(ctx, KMIP_TAG_UNIQUE_BATCH_ITEM_ID, value->unique_batch_item_id);
        CHECK_RESULT(ctx, result);
    }
    
    result = kmip_decode_enum(ctx, KMIP_TAG_RESULT_STATUS, &value->result_status);
    CHECK_RESULT(ctx, result);
    CHECK_ENUM(ctx, KMIP_TAG_RESULT_STATUS, value->result_status);
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_RESULT_REASON))
    {
        result = kmip_decode_enum(ctx, KMIP_TAG_RESULT_REASON, &value->result_reason);
        CHECK_RESULT(ctx, result);
    }
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_RESULT_MESSAGE))
    {
        value->result_message = ctx->calloc_func(ctx->state, 1, sizeof(TextString));
        CHECK_NEW_MEMORY(ctx, value->result_message, sizeof(TextString), "ResultMessage text string");
        
        result = kmip_decode_text_string(ctx, KMIP_TAG_RESULT_MESSAGE, value->result_message);
        CHECK_RESULT(ctx, result);
    }
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_ASYNCHRONOUS_CORRELATION_VALUE))
    {
        value->asynchronous_correlation_value = ctx->calloc_func(ctx->state, 1, sizeof(ByteString));
        CHECK_NEW_MEMORY(ctx, value->asynchronous_correlation_value, sizeof(ByteString), "AsynchronousCorrelationValue byte string");
        
        result = kmip_decode_byte_string(ctx, KMIP_TAG_ASYNCHRONOUS_CORRELATION_VALUE, value->asynchronous_correlation_value);
        CHECK_RESULT(ctx, result);
    }
    
    /* NOTE (ph) Omitting the tag check is a good way to test error output. */
    if(kmip_is_tag_next(ctx, KMIP_TAG_RESPONSE_PAYLOAD))
    {
        switch(value->operation)
        {
            case KMIP_OP_CREATE:
            value->response_payload = ctx->calloc_func(ctx->state, 1, sizeof(CreateResponsePayload));
            CHECK_NEW_MEMORY(ctx, value->response_payload, sizeof(CreateResponsePayload), "CreateResponsePayload structure");
            result = kmip_decode_create_response_payload(ctx, value->response_payload);
            break;
            
            case KMIP_OP_GET:
            value->response_payload = ctx->calloc_func(ctx->state, 1, sizeof(GetResponsePayload));
            CHECK_NEW_MEMORY(ctx, value->response_payload, sizeof(GetResponsePayload), "GetResponsePayload structure");
            
            result = kmip_decode_get_response_payload(ctx, value->response_payload);
            break;
            
            case KMIP_OP_DESTROY:
            value->response_payload = ctx->calloc_func(ctx->state, 1, sizeof(DestroyResponsePayload));
            CHECK_NEW_MEMORY(ctx, value->response_payload, sizeof(DestroyResponsePayload), "DestroyResponsePayload structure");
            result = kmip_decode_destroy_response_payload(ctx, value->response_payload);
            break;
            
            case KMIP_OP_QUERY:
            value->response_payload = ctx->calloc_func(ctx->state, 1, sizeof(QueryResponsePayload));
            CHECK_NEW_MEMORY(ctx, value->response_payload, sizeof(QueryResponsePayload), "QueryResponsePayload structure");
            result = kmip_decode_query_response_payload(ctx, value->response_payload);
            break;

            default:
            kmip_push_error_frame(ctx, __func__, __LINE__);
            return(KMIP_NOT_IMPLEMENTED);
            break;
        };
        CHECK_RESULT(ctx, result);
    }
    
    return(KMIP_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
addq (%rdi), %rax
cmpq $0x7, %rax
ja 0x13ee8
leaq 0x48a9(%rip), %rsi      # 0x1877e
movq %rbx, %rdi
movl $0x28b4, %edx           # imm = 0x28B4
callq 0x6e80
pushq $-0x2
popq %r15
jmp 0x13f63
movq %rsi, %r14
leaq 0x4(%rsp), %r15
andl $0x0, (%r15)
andl $0x0, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6a80
movl (%r15), %eax
movl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
movl $0x28bb, %edx           # imm = 0x28BB
cmpl $0x42000f00, %ecx       # imm = 0x42000F00
jne 0x13f4a
cmpb $0x1, %al
jne 0x13f4e
movq %rsp, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x64d0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
addq (%rbx), %rax
movl (%r15), %ecx
cmpq %rcx, %rax
jae 0x13f71
pushq $-0x2
popq %rbp
movl $0x28be, %edx           # imm = 0x28BE
jmp 0x13f51
pushq $-0x4
jmp 0x13f50
pushq $-0x5
popq %rbp
leaq 0x4826(%rip), %rsi      # 0x1877e
movq %rbx, %rdi
callq 0x6e80
movl %ebp, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x42005c, %esi         # imm = 0x42005C
callq 0x62d0
testl %eax, %eax
je 0x13fb9
movq %rbx, %rdi
movl $0x42005c, %esi         # imm = 0x42005C
movq %r14, %rdx
callq 0x6b70
testl %eax, %eax
je 0x13f9f
movl %eax, %ebp
movl $0x28c3, %edx           # imm = 0x28C3
jmp 0x13f51
movl (%r14), %edx
cmpl $0x18, %edx
ja 0x1409f
movl $0x1100402, %eax        # imm = 0x1100402
btl %edx, %eax
jae 0x1409f
movq %rbx, %rdi
movl $0x420093, %esi         # imm = 0x420093
callq 0x62d0
testl %eax, %eax
je 0x14006
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x1402a
movq %rbx, %rdi
movl $0x420093, %esi         # imm = 0x420093
movq %rax, %rdx
callq 0x6d60
testl %eax, %eax
je 0x14006
movl %eax, %ebp
movl $0x28cd, %edx           # imm = 0x28CD
jmp 0x13f51
leaq 0x10(%r14), %r15
movq %rbx, %rdi
movl $0x42007f, %esi         # imm = 0x42007F
movq %r15, %rdx
callq 0x6b70
testl %eax, %eax
je 0x14049
movl %eax, %ebp
movl $0x28d1, %edx           # imm = 0x28D1
jmp 0x13f51
leaq 0x46b6(%rip), %rdx      # 0x186e7
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x28ca, %edx           # imm = 0x28CA
jmp 0x13f51
movl (%r15), %edx
cmpl $0x4, %edx
jae 0x14083
movq %rbx, %rdi
movl $0x42007e, %esi         # imm = 0x42007E
callq 0x62d0
testl %eax, %eax
je 0x140bb
leaq 0x14(%r14), %rdx
movq %rbx, %rdi
movl $0x42007e, %esi         # imm = 0x42007E
callq 0x6b70
testl %eax, %eax
je 0x140bb
movl %eax, %ebp
movl $0x28d7, %edx           # imm = 0x28D7
jmp 0x13f51
pushq $-0x9
popq %rbp
movq %rbx, %rdi
movl $0x42007f, %esi         # imm = 0x42007F
movl %ebp, %ecx
callq 0x6120
movl $0x28d2, %edx           # imm = 0x28D2
jmp 0x13f51
pushq $-0x9
popq %rbp
movq %rbx, %rdi
movl $0x42005c, %esi         # imm = 0x42005C
movl %ebp, %ecx
callq 0x6120
movl $0x28c4, %edx           # imm = 0x28C4
jmp 0x13f51
movq %rbx, %rdi
movl $0x42007d, %esi         # imm = 0x42007D
callq 0x62d0
testl %eax, %eax
je 0x1410c
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x141cc
movq %rbx, %rdi
movl $0x42007d, %esi         # imm = 0x42007D
movq %rax, %rdx
callq 0x6560
testl %eax, %eax
je 0x1410c
movl %eax, %ebp
movl $0x28e0, %edx           # imm = 0x28E0
jmp 0x13f51
movq %rbx, %rdi
movl $0x420006, %esi         # imm = 0x420006
callq 0x62d0
testl %eax, %eax
je 0x1415d
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x141eb
movq %rbx, %rdi
movl $0x420006, %esi         # imm = 0x420006
movq %rax, %rdx
callq 0x6d60
testl %eax, %eax
je 0x1415d
movl %eax, %ebp
movl $0x28e9, %edx           # imm = 0x28E9
jmp 0x13f51
movq %rbx, %rdi
movl $0x42007c, %esi         # imm = 0x42007C
callq 0x62d0
xorl %r15d, %r15d
testl %eax, %eax
je 0x13f63
movl (%r14), %eax
cmpl $0x18, %eax
je 0x14264
cmpl $0xa, %eax
je 0x1420a
cmpl $0x14, %eax
je 0x14237
cmpl $0x1, %eax
jne 0x142a3
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x18
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x142cf
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6d10
jmp 0x1428f
leaq 0x45cb(%rip), %rdx      # 0x1879e
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x28dd, %edx           # imm = 0x28DD
jmp 0x13f51
leaq 0x45c6(%rip), %rdx      # 0x187b8
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x28e6, %edx           # imm = 0x28E6
jmp 0x13f51
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x18
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x142b0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6570
jmp 0x1428f
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x8
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x142ee
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a20
jmp 0x1428f
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x20
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x1430d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6820
movl %eax, %ebp
movl $0x290f, %edx           # imm = 0x290F
testl %eax, %eax
jne 0x13f51
jmp 0x13f63
pushq $-0x1
popq %rbp
movl $0x290b, %edx           # imm = 0x290B
jmp 0x13f51
leaq 0x454a(%rip), %rdx      # 0x18801
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x28f9, %edx           # imm = 0x28F9
jmp 0x13f51
leaq 0x450b(%rip), %rdx      # 0x187e1
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x28f3, %edx           # imm = 0x28F3
jmp 0x13f51
leaq 0x4529(%rip), %rdx      # 0x1881e
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x2900, %edx           # imm = 0x2900
jmp 0x13f51
leaq 0x452b(%rip), %rdx      # 0x1883f
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x2906, %edx           # imm = 0x2906
jmp 0x13f51