// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_decode_key_block
int
kmip_decode_key_block(KMIP *ctx, KeyBlock *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_KEY_BLOCK, KMIP_TYPE_STRUCTURE);
    
    kmip_decode_length(ctx, &length);
    CHECK_BUFFER_FULL(ctx, length);
    
    result = kmip_decode_enum(ctx, KMIP_TAG_KEY_FORMAT_TYPE, &value->key_format_type);
    CHECK_RESULT(ctx, result);
    CHECK_ENUM(ctx, KMIP_TAG_KEY_FORMAT_TYPE, value->key_format_type);
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_KEY_COMPRESSION_TYPE))
    {
        result = kmip_decode_enum(ctx, KMIP_TAG_KEY_COMPRESSION_TYPE, &value->key_compression_type);
        CHECK_RESULT(ctx, result);
        CHECK_ENUM(ctx, KMIP_TAG_KEY_COMPRESSION_TYPE, value->key_compression_type);
    }
    
    if(kmip_is_tag_type_next(ctx, KMIP_TAG_KEY_VALUE, KMIP_TYPE_BYTE_STRING))
    {
        value->key_value_type = KMIP_TYPE_BYTE_STRING;
        value->key_value = ctx->calloc_func(ctx->state, 1, sizeof(ByteString));
        CHECK_NEW_MEMORY(ctx, value->key_value, sizeof(ByteString), "KeyValue byte string");
        
        result = kmip_decode_byte_string(ctx, KMIP_TAG_KEY_VALUE, (ByteString *)value->key_value);
    }
    else
    {
        value->key_value_type = KMIP_TYPE_STRUCTURE;
        value->key_value = ctx->calloc_func(ctx->state, 1, sizeof(KeyValue));
        CHECK_NEW_MEMORY(ctx, value->key_value, sizeof(KeyValue), "KeyValue structure");
        
        result = kmip_decode_key_value(ctx, value->key_format_type, (KeyValue *)value->key_value);
    }
    CHECK_RESULT(ctx, result);
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM))
    {
        result = kmip_decode_enum(ctx, KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM, &value->cryptographic_algorithm);
        CHECK_RESULT(ctx, result);
        CHECK_ENUM(ctx, KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM, value->cryptographic_algorithm);
    }
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_CRYPTOGRAPHIC_LENGTH))
    {
        result = kmip_decode_integer(ctx, KMIP_TAG_CRYPTOGRAPHIC_LENGTH, &value->cryptographic_length);
        CHECK_RESULT(ctx, result);
    }
    
    if(kmip_is_tag_next(ctx, KMIP_TAG_KEY_WRAPPING_DATA))
    {
        value->key_wrapping_data = ctx->calloc_func(ctx->state, 1, sizeof(KeyWrappingData));
        CHECK_NEW_MEMORY(ctx, value->key_wrapping_data, sizeof(KeyWrappingData), "KeyWrappingData structure");
        
        result = kmip_decode_key_wrapping_data(ctx, value->key_wrapping_data);
        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 0x1243d
leaq 0x6009(%rip), %rsi      # 0x18434
movq %rbx, %rdi
movl $0x2684, %edx           # imm = 0x2684
callq 0x6e80
pushq $-0x2
popq %rbp
jmp 0x124b5
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 $0x268b, %edx           # imm = 0x268B
cmpl $0x42004000, %ecx       # imm = 0x42004000
jne 0x1249f
cmpb $0x1, %al
jne 0x124a3
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 0x124c2
pushq $-0x2
popq %rbp
movl $0x268e, %edx           # imm = 0x268E
jmp 0x124a6
pushq $-0x4
jmp 0x124a5
pushq $-0x5
popq %rbp
leaq 0x5f87(%rip), %rsi      # 0x18434
movq %rbx, %rdi
callq 0x6e80
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
movq %r14, %rdx
callq 0x6b70
testl %eax, %eax
je 0x124df
movl %eax, %ebp
movl $0x2691, %edx           # imm = 0x2691
jmp 0x124a6
movl 0x18(%rbx), %edi
movl (%r14), %r15d
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
callq 0x6370
testl %eax, %eax
je 0x12511
movl %eax, %ebp
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
movl %eax, %ecx
callq 0x6120
movl $0x2692, %edx           # imm = 0x2692
jmp 0x124a6
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
callq 0x62d0
testl %eax, %eax
je 0x12555
leaq 0x4(%r14), %r15
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movq %r15, %rdx
callq 0x6b70
testl %eax, %eax
je 0x12546
movl %eax, %ebp
movl $0x2697, %edx           # imm = 0x2697
jmp 0x124a6
movl (%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x4, %eax
jae 0x12621
pushq $0x8
popq %rdx
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
callq 0x6850
testl %eax, %eax
je 0x125a3
movl $0x8, 0x10(%r14)
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x1263d
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
movq %rax, %rdx
callq 0x6d60
jmp 0x125d9
movl $0x1, 0x10(%r14)
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x18
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x1265c
movl (%r14), %esi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x6bb0
movl %eax, %ebp
movl $0x26ab, %edx           # imm = 0x26AB
testl %eax, %eax
jne 0x124a6
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
callq 0x62d0
testl %eax, %eax
je 0x126b0
leaq 0x14(%r14), %r15
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movq %r15, %rdx
callq 0x6b70
testl %eax, %eax
je 0x1267b
movl %eax, %ebp
movl $0x26b0, %edx           # imm = 0x26B0
jmp 0x124a6
pushq $-0x9
popq %rbp
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movl %ebp, %ecx
callq 0x6120
movl $0x2698, %edx           # imm = 0x2698
jmp 0x124a6
leaq 0x5e06(%rip), %rdx      # 0x1844a
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x269f, %edx           # imm = 0x269F
jmp 0x124a6
leaq 0x5dfc(%rip), %rdx      # 0x1845f
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x26a7, %edx           # imm = 0x26A7
jmp 0x124a6
movl 0x18(%rbx), %edi
movl (%r15), %r15d
movl $0x420028, %esi         # imm = 0x420028
movl %r15d, %edx
callq 0x6370
testl %eax, %eax
je 0x126b0
movl %eax, %ebp
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movl %r15d, %edx
movl %eax, %ecx
callq 0x6120
movl $0x26b1, %edx           # imm = 0x26B1
jmp 0x124a6
movq %rbx, %rdi
movl $0x42002a, %esi         # imm = 0x42002A
callq 0x62d0
testl %eax, %eax
je 0x126e2
leaq 0x18(%r14), %rdx
movq %rbx, %rdi
movl $0x42002a, %esi         # imm = 0x42002A
callq 0x60d0
testl %eax, %eax
je 0x126e2
movl %eax, %ebp
movl $0x26b7, %edx           # imm = 0x26B7
jmp 0x124a6
movq %rbx, %rdi
movl $0x420046, %esi         # imm = 0x420046
callq 0x62d0
xorl %ebp, %ebp
testl %eax, %eax
je 0x124b5
movq 0x890(%rbx), %rdi
pushq $0x1
popq %rsi
pushq $0x30
popq %rdx
callq *0x868(%rbx)
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x12734
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6c70
testl %eax, %eax
je 0x124b5
movl $0x26c0, %edx           # imm = 0x26C0
movl %eax, %ebp
jmp 0x124a6
leaq 0x5d37(%rip), %rdx      # 0x18472
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x6c40
pushq $-0xc
popq %rbp
movl $0x26bd, %edx           # imm = 0x26BD
jmp 0x124a6