// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_encode_key_block
int
kmip_encode_key_block(KMIP *ctx, const KeyBlock *value)
{
    int result = 0;
    result = kmip_encode_int32_be(ctx, TAG_TYPE(KMIP_TAG_KEY_BLOCK, 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_KEY_FORMAT_TYPE, value->key_format_type);
    CHECK_RESULT(ctx, result);
    
    if(value->key_compression_type != 0)
    {
        result = kmip_encode_enum(ctx, KMIP_TAG_KEY_COMPRESSION_TYPE, value->key_compression_type);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->key_wrapping_data != NULL)
    {
        result = kmip_encode_byte_string(ctx, KMIP_TAG_KEY_VALUE, (ByteString*)value->key_value);
    }
    else
    {
        result = kmip_encode_key_value(ctx, value->key_format_type, (KeyValue*)value->key_value);
    }
    CHECK_RESULT(ctx, result);
    
    if(value->cryptographic_algorithm != 0)
    {
        result = kmip_encode_enum(ctx, KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM, value->cryptographic_algorithm);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->cryptographic_length != KMIP_UNSET)
    {
        result = kmip_encode_integer(ctx, KMIP_TAG_CRYPTOGRAPHIC_LENGTH, value->cryptographic_length);
        CHECK_RESULT(ctx, result);
    }
    
    if(value->key_wrapping_data != NULL)
    {
        result = kmip_encode_key_wrapping_data(ctx, value->key_wrapping_data);
        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
movq %rsi, %r14
movq %rdi, %rbx
movl $0x42004001, %esi       # imm = 0x42004001
callq 0x60a0
testl %eax, %eax
je 0xced4
movl %eax, %ebp
leaq 0xab88(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cc3, %edx           # imm = 0x1CC3
jmp 0xcf06
movq 0x8(%rbx), %r12
leaq 0x4(%r12), %r15
movq %r15, 0x8(%rbx)
movl (%r14), %edx
movq %rbx, %rdi
movl $0x420042, %esi         # imm = 0x420042
callq 0x6700
testl %eax, %eax
je 0xcf16
movl %eax, %ebp
leaq 0xab54(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cc9, %edx           # imm = 0x1CC9
callq 0x6e80
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r14), %edx
testl %edx, %edx
je 0xcf42
movq %rbx, %rdi
movl $0x420041, %esi         # imm = 0x420041
callq 0x6700
testl %eax, %eax
je 0xcf42
movl %eax, %ebp
leaq 0xab1a(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cce, %edx           # imm = 0x1CCE
jmp 0xcf06
cmpq $0x0, 0x20(%r14)
je 0xcf5c
movq 0x8(%r14), %rdx
movq %rbx, %rdi
movl $0x420045, %esi         # imm = 0x420045
callq 0x6cb0
jmp 0xcf6b
movl (%r14), %esi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x6c90
movl %eax, %ebp
testl %eax, %eax
je 0xcf82
leaq 0xaada(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cd9, %edx           # imm = 0x1CD9
jmp 0xcf06
movl 0x14(%r14), %edx
testl %edx, %edx
je 0xcfb1
movq %rbx, %rdi
movl $0x420028, %esi         # imm = 0x420028
callq 0x6700
testl %eax, %eax
je 0xcfb1
movl %eax, %ebp
leaq 0xaaae(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cde, %edx           # imm = 0x1CDE
jmp 0xcf06
movl 0x18(%r14), %edx
cmpl $-0x1, %edx
je 0xcfe1
movq %rbx, %rdi
movl $0x42002a, %esi         # imm = 0x42002A
callq 0x63f0
testl %eax, %eax
je 0xcfe1
movl %eax, %ebp
leaq 0xaa7e(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1ce4, %edx           # imm = 0x1CE4
jmp 0xcf06
movq 0x20(%r14), %rsi
testq %rsi, %rsi
je 0xd00c
movq %rbx, %rdi
callq 0x6450
testl %eax, %eax
je 0xd00c
movl %eax, %ebp
leaq 0xaa53(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cea, %edx           # imm = 0x1CEA
jmp 0xcf06
movq 0x8(%rbx), %r14
movq %r12, 0x8(%rbx)
movq %r14, %rsi
subq %r15, %rsi
movq %rbx, %rdi
callq 0x6b10
testl %eax, %eax
je 0xd03c
movl %eax, %ebp
leaq 0xaa23(%rip), %rsi      # 0x17a52
movq %rbx, %rdi
movl $0x1cf1, %edx           # imm = 0x1CF1
jmp 0xcf06
movq %r14, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0xcf0b