// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
addq (%rdi), %rax
cmpq $0x7, %rax
ja 0x15aaf
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x15b33
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x15a91
jmp 0x15b5a
movq %rsi, %r14
xorl %eax, %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6a10
movl (%r15), %eax
movl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
cmpl $0x42004000, %ecx       # imm = 0x42004000
jne 0x15b64
cmpb $0x1, %al
jne 0x15bb0
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x64b0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
addq (%rbx), %rax
movl (%r15), %ecx
cmpq %rcx, %rax
jae 0x15c09
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x15c3d
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x15b18
jmp 0x15b5a
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x99fc(%rip), %rsi      # 0x1f540
movl $0x63, %edx
callq 0x66f0
movl $0x2684, 0x9c(%rbx,%r14) # imm = 0x2684
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
jmp 0x15bfa
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x15b82
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x15b6b
jmp 0x15ba9
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x99ad(%rip), %rsi      # 0x1f540
movl $0x63, %edx
callq 0x66f0
movl $0x268b, 0x9c(%rbx,%r14) # imm = 0x268B
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
jmp 0x15bfa
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x15bce
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x15bb7
jmp 0x15bf5
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x9961(%rip), %rsi      # 0x1f540
movl $0x63, %edx
callq 0x66f0
movl $0x268b, 0x9c(%rbx,%r14) # imm = 0x268B
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
movq %r14, %rdx
callq 0x6ae0
testl %eax, %eax
je 0x15c69
movl %eax, %ebp
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x15cad
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x15c26
jmp 0x15bfa
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x98f2(%rip), %rsi      # 0x1f540
movl $0x63, %edx
callq 0x66f0
movl $0x268e, 0x9c(%rbx,%r14) # imm = 0x268E
jmp 0x15b5a
movl 0x18(%rbx), %edi
movl (%r14), %r15d
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
callq 0x6350
testl %eax, %eax
je 0x15cd9
movl %eax, %ebp
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
movl %eax, %ecx
callq 0x6120
leaq 0xaf13(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x2692, %edx           # imm = 0x2692
callq 0x6de0
jmp 0x15bfa
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x9882(%rip), %rsi      # 0x1f540
movl $0x63, %edx
callq 0x66f0
movl $0x2691, 0x9c(%rbx,%r14) # imm = 0x2691
jmp 0x15bfa
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x15d46
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %eax
orl %edx, %eax
cmpl $0x420041, %eax         # imm = 0x420041
jne 0x15d46
leaq 0x4(%r14), %r15
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movq %r15, %rdx
callq 0x6ae0
testl %eax, %eax
je 0x15d37
movl %eax, %ebp
leaq 0xae84(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x2697, %edx           # imm = 0x2697
jmp 0x15ca3
movl (%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x4, %eax
jae 0x15eb6
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
movl $0x8, %edx
callq 0x6810
testl %eax, %eax
je 0x15d96
movl $0x8, 0x10(%r14)
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x10, %edx
callq *0x868(%rbx)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x15dea
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
movq %rax, %rdx
callq 0x6cc0
jmp 0x15dd0
movl $0x1, 0x10(%r14)
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x18, %edx
callq *0x868(%rbx)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x15e84
movl (%r14), %esi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x6b20
movl %eax, %ebp
testl %eax, %eax
je 0x15e12
leaq 0xadd1(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26ab, %edx           # imm = 0x26AB
jmp 0x15ca3
leaq 0xadd3(%rip), %rdx      # 0x20bc4
movl $0x10, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xada9(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x269f, %edx           # imm = 0x269F
jmp 0x15ea7
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
xorl %ebp, %ebp
cmpq $0x3, %rcx
jb 0x15bfa
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %ecx
orl %edx, %ecx
cmpl $0x420028, %ecx         # imm = 0x420028
jne 0x15f36
leaq 0x14(%r14), %r15
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movq %r15, %rdx
callq 0x6ae0
testl %eax, %eax
je 0x15ee1
movl %eax, %r12d
leaq 0xad3f(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26b0, %edx           # imm = 0x26B0
callq 0x6de0
movl %r12d, %ebp
jmp 0x15bfa
leaq 0xad4e(%rip), %rdx      # 0x20bd9
movl $0x18, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xad0f(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26a7, %edx           # imm = 0x26A7
callq 0x6de0
movl $0xfffffff4, %ebp       # imm = 0xFFFFFFF4
jmp 0x15bfa
movl $0xfffffff7, %ebp       # imm = 0xFFFFFFF7
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x6120
leaq 0xacda(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x2698, %edx           # imm = 0x2698
jmp 0x15ca3
movl 0x18(%rbx), %edi
movl (%r15), %r12d
movl $0x420028, %esi         # imm = 0x420028
movl %r12d, %edx
callq 0x6350
testl %eax, %eax
je 0x15f1e
movl %eax, %r15d
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movl %r12d, %edx
movl %eax, %ecx
callq 0x6120
leaq 0xac9a(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26b1, %edx           # imm = 0x26B1
jmp 0x15f7a
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x15bfa
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %ecx
orl %edx, %ecx
cmpl $0x42002a, %ecx         # imm = 0x42002A
jne 0x15f9f
leaq 0x18(%r14), %rdx
movq %rbx, %rdi
movl $0x42002a, %esi         # imm = 0x42002A
callq 0x60d0
testl %eax, %eax
je 0x15f87
movl %eax, %r15d
leaq 0xac3c(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26b7, %edx           # imm = 0x26B7
callq 0x6de0
movl %r15d, %ebp
jmp 0x15bfa
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x15bfa
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %eax
orl %edx, %eax
cmpl $0x420046, %eax         # imm = 0x420046
jne 0x15bfa
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x30, %edx
callq *0x868(%rbx)
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x16011
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6bd0
testl %eax, %eax
je 0x15bfa
movl %eax, %r14d
leaq 0xabb2(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26c0, %edx           # imm = 0x26C0
callq 0x6de0
movl %r14d, %ebp
jmp 0x15bfa
leaq 0xabd4(%rip), %rdx      # 0x20bec
movl $0x30, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xab82(%rip), %rsi      # 0x20bae
movq %rbx, %rdi
movl $0x26bd, %edx           # imm = 0x26BD
jmp 0x15ea7