// File: /workspace/github_c_makefile_star2_O3/OpenKMIP[P]libkmip/src/kmip.c
// Function: kmip_decode_key_material
int
kmip_decode_key_material(KMIP *ctx, enum key_format_type format, void **value)
{
    int result = 0;
    
    switch(format)
    {
        case KMIP_KEYFORMAT_RAW:
        case KMIP_KEYFORMAT_OPAQUE:
        case KMIP_KEYFORMAT_PKCS1:
        case KMIP_KEYFORMAT_PKCS8:
        case KMIP_KEYFORMAT_X509:
        case KMIP_KEYFORMAT_EC_PRIVATE_KEY:
        *value = ctx->calloc_func(ctx->state, 1, sizeof(ByteString));
        CHECK_NEW_MEMORY(ctx, *value, sizeof(ByteString), "KeyMaterial byte string");
        result = kmip_decode_byte_string(ctx, KMIP_TAG_KEY_MATERIAL, (ByteString*)*value);
        CHECK_RESULT(ctx, result);
        return(KMIP_OK);
        break;
        
        default:
        break;
    };
    
    switch(format)
    {
        case KMIP_KEYFORMAT_TRANS_SYMMETRIC_KEY:
        *value = ctx->calloc_func(ctx->state, 1, sizeof(TransparentSymmetricKey));
        CHECK_NEW_MEMORY(ctx, *value, sizeof(TransparentSymmetricKey), "TransparentSymmetricKey structure");
        result = kmip_decode_transparent_symmetric_key(ctx, (TransparentSymmetricKey*)*value);
        CHECK_RESULT(ctx, result);
        break;
        
        /* TODO (ph) The rest require BigInteger support. */
        
        case KMIP_KEYFORMAT_TRANS_DSA_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_DSA_PUBLIC_KEY:
        case KMIP_KEYFORMAT_TRANS_RSA_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_RSA_PUBLIC_KEY:
        case KMIP_KEYFORMAT_TRANS_DH_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_DH_PUBLIC_KEY:
        case KMIP_KEYFORMAT_TRANS_ECDSA_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_ECDSA_PUBLIC_KEY:
        case KMIP_KEYFORMAT_TRANS_ECDH_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_ECDH_PUBLIC_KEY:
        case KMIP_KEYFORMAT_TRANS_ECMQV_PRIVATE_KEY:
        case KMIP_KEYFORMAT_TRANS_ECMQV_PUBLIC_KEY:
        default:
        kmip_push_error_frame(ctx, __func__, __LINE__);
        return(KMIP_NOT_IMPLEMENTED);
        break;
    };
    
    return(KMIP_OK);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
leal -0x1(%rsi), %eax
cmpl $0x5, %eax
ja 0x149f7
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x10, %edx
callq *0x868(%rbx)
movq %rax, (%r14)
testq %rax, %rax
je 0x14a5d
movq %rbx, %rdi
movl $0x420043, %esi         # imm = 0x420043
movq %rax, %rdx
callq 0x6cc0
testl %eax, %eax
je 0x14a82
movl %eax, %ebp
leaq 0xbf35(%rip), %rsi      # 0x20922
movq %rbx, %rdi
movl $0x24ea, %edx           # imm = 0x24EA
jmp 0x14a3b
cmpl $0x7, %esi
jne 0x14a42
movq 0x890(%rbx), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq *0x868(%rbx)
movq %rax, (%r14)
testq %rax, %rax
je 0x14a86
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a30
testl %eax, %eax
je 0x14a82
movl %eax, %ebp
leaq 0xbeef(%rip), %rsi      # 0x20922
movq %rbx, %rdi
movl $0x24f8, %edx           # imm = 0x24F8
callq 0x6de0
jmp 0x14ab3
leaq 0xbed9(%rip), %rsi      # 0x20922
movq %rbx, %rdi
movl $0x250a, %edx           # imm = 0x250A
callq 0x6de0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x14ab3
leaq 0xbea6(%rip), %rdx      # 0x2090a
movl $0x10, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xbeaa(%rip), %rsi      # 0x20922
movq %rbx, %rdi
movl $0x24e8, %edx           # imm = 0x24E8
jmp 0x14aa9
xorl %ebp, %ebp
jmp 0x14ab3
leaq 0xbeae(%rip), %rdx      # 0x2093b
movl $0x8, %esi
movq %rbx, %rdi
callq 0x6ba0
leaq 0xbe81(%rip), %rsi      # 0x20922
movq %rbx, %rdi
movl $0x24f6, %edx           # imm = 0x24F6
callq 0x6de0
movl $0xfffffff4, %ebp       # imm = 0xFFFFFFF4
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq