// File: /workspace/github_c_makefile_star2_O1/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 0x163f7
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %rbx, %rbx
je 0x1652c
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x164b4
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x163d9
jmp 0x1652c
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 0x16488
cmpb $0x1, %al
jne 0x164dd
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 0x1653b
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testq %rbx, %rbx
je 0x1652c
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x165c0
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x1646a
jmp 0x1652c
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
testq %rbx, %rbx
je 0x1652c
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x16505
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x1649d
jmp 0x1652c
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0xa007(%rip), %rsi      # 0x204cc
movl $0x63, %edx
callq 0x66f0
movl $0x2684, 0x9c(%rbx,%r14) # imm = 0x2684
jmp 0x1652c
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
testq %rbx, %rbx
je 0x1652c
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x16505
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x164ee
jmp 0x1652c
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x9fb6(%rip), %rsi      # 0x204cc
movl $0x63, %edx
callq 0x66f0
movl $0x268b, 0x9c(%rbx,%r14) # imm = 0x268B
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 0x16578
movl %eax, %ebp
testq %rbx, %rbx
je 0x1652c
leaq 0x38(%rbx), %rdi
xorl %r14d, %r14d
cmpl $0x0, 0x64(%rdi,%r14)
je 0x165ec
addq $0x68, %r14
cmpq $0x820, %r14            # imm = 0x820
jne 0x1655d
jmp 0x1652c
movl 0x18(%rbx), %edi
movl (%r14), %r15d
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
callq 0x6350
movl %eax, %ebp
testl %eax, %eax
je 0x16618
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
movl %r15d, %edx
movl %ebp, %ecx
callq 0x6120
leaq 0xb590(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x2692, %edx           # imm = 0x2692
callq 0x6de0
jmp 0x1652c
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x9efb(%rip), %rsi      # 0x204cc
movl $0x63, %edx
callq 0x66f0
movl $0x268e, 0x9c(%rbx,%r14) # imm = 0x268E
jmp 0x1652c
addq %r14, %rdi
movq %rdi, 0x860(%rbx)
leaq 0x9ecf(%rip), %rsi      # 0x204cc
movl $0x63, %edx
callq 0x66f0
movl $0x2691, 0x9c(%rbx,%r14) # imm = 0x2691
jmp 0x1652c
testq %rbx, %rbx
je 0x166cf
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x166cf
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 0x166cf
leaq 0x4(%r14), %r12
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movq %r12, %rdx
callq 0x6ae0
testl %eax, %eax
je 0x1668c
movl %eax, %r15d
leaq 0xb4c7(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x2697, %edx           # imm = 0x2697
callq 0x6de0
movl %r15d, %ebp
jmp 0x1652c
movl (%r12), %edx
leal -0x1(%rdx), %r15d
cmpl $0x4, %r15d
jb 0x166c5
movl $0xfffffff7, %ebp       # imm = 0xFFFFFFF7
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x6120
leaq 0xb486(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x2698, %edx           # imm = 0x2698
callq 0x6de0
cmpl $0x3, %r15d
ja 0x1652c
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
movl $0x8, %edx
callq 0x6810
testl %eax, %eax
je 0x1671f
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 0x16773
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
movq %rax, %rdx
callq 0x6cc0
jmp 0x16759
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 0x1680a
movl (%r14), %esi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x6b20
movl %eax, %ebp
testl %eax, %eax
je 0x1679b
leaq 0xb3d8(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26ab, %edx           # imm = 0x26AB
jmp 0x165b6
leaq 0xb3da(%rip), %rdx      # 0x21b54
movl $0x10, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xb3b0(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x269f, %edx           # imm = 0x269F
jmp 0x1682d
testq %rbx, %rbx
je 0x16934
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x1683c
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %eax
orl %edx, %eax
cmpl $0x420028, %eax         # imm = 0x420028
jne 0x1683c
leaq 0x14(%r14), %r15
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movq %r15, %rdx
callq 0x6ae0
testl %eax, %eax
je 0x1693b
movl %eax, %ebp
leaq 0xb341(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26b0, %edx           # imm = 0x26B0
jmp 0x165b6
leaq 0xb358(%rip), %rdx      # 0x21b69
movl $0x18, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xb319(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26a7, %edx           # imm = 0x26A7
callq 0x6de0
movl $0xfffffff4, %ebp       # imm = 0xFFFFFFF4
jmp 0x1652c
testq %rbx, %rbx
je 0x16934
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x168a0
movzbl (%rax), %ecx
shll $0x10, %ecx
movzbl 0x1(%rax), %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl 0x2(%rax), %eax
orl %edx, %eax
cmpl $0x42002a, %eax         # imm = 0x42002A
jne 0x168a0
leaq 0x18(%r14), %rdx
movq %rbx, %rdi
movl $0x42002a, %esi         # imm = 0x42002A
callq 0x60d0
testl %eax, %eax
je 0x168a0
movl %eax, %ebp
leaq 0xb2ab(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26b7, %edx           # imm = 0x26B7
jmp 0x165b6
testq %rbx, %rbx
je 0x16934
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
addq (%rbx), %rcx
cmpq $0x3, %rcx
jb 0x16934
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 0x16934
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x30, %edx
callq *0x868(%rbx)
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x1699a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6bd0
movl $0x0, %ebp
testl %eax, %eax
je 0x1652c
movl %eax, %r14d
leaq 0xb21f(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26c0, %edx           # imm = 0x26C0
callq 0x6de0
movl %r14d, %ebp
jmp 0x1652c
xorl %ebp, %ebp
jmp 0x1652c
movl 0x18(%rbx), %edi
movl (%r15), %ebp
movl $0x420028, %esi         # imm = 0x420028
movl %ebp, %edx
callq 0x6350
movl %eax, %r15d
testl %eax, %eax
je 0x1697f
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
movl %ebp, %edx
movl %r15d, %ecx
callq 0x6120
leaq 0xb1d1(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26b1, %edx           # imm = 0x26B1
callq 0x6de0
movl %r15d, %ebp
jmp 0x16981
xorl %ebp, %ebp
testl %r15d, %r15d
setne %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x1652c
jmp 0x16845
leaq 0xb1db(%rip), %rdx      # 0x21b7c
movl $0x30, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xb189(%rip), %rsi      # 0x21b3e
movq %rbx, %rdi
movl $0x26bd, %edx           # imm = 0x26BD
jmp 0x1682d