// File: /workspace/github_c_makefile_star2_O2/OpenKMIP[P]libkmip/tests/tests.c
// Function: test_decode_create_request_payload_kmip_2_0
int
test_decode_create_request_payload_kmip_2_0(TestTracker *tracker)
{
    TRACK_TEST(tracker);

    /* This encoding matches the following set of values:
    *  Request Payload
    *      Object Type - Symmetric Key
    *      Attributes
    *          Cryptographic Algorithm - AES
    *          Cryptographic Length - 128
    *          Cryptographic Usage Mask - Encrypt | Decrypt
    *      Protection Storage Masks
    *          Protection Storage Mask - Software | On System
    *          Protection Storage Mask - Off System | Off Premises
    */
    uint8 encoding[120] = {
        0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x70, 
        0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x30,
        0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x01, 0x5F, 0x01, 0x00, 0x00, 0x00, 0x20,
        0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00
    };
    
    struct kmip ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_2_0);
    
    Attribute a[3] = {0};
    for(int i = 0; i < 3; i++)
    {
        kmip_init_attribute(&a[i]);
    }
    
    enum cryptographic_algorithm algorithm = KMIP_CRYPTOALG_AES;
    a[0].type = KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM;
    a[0].value = &algorithm;
    
    int32 length = 128;
    a[1].type = KMIP_ATTR_CRYPTOGRAPHIC_LENGTH;
    a[1].value = &length;
    
    int32 mask = KMIP_CRYPTOMASK_ENCRYPT | KMIP_CRYPTOMASK_DECRYPT;
    a[2].type = KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK;
    a[2].value = &mask;
    
    Attributes attributes = {0};
    LinkedList list = {0};
    LinkedListItem item_1, item_2, item_3 = {0};
    item_1.data = &a[0];
    item_2.data = &a[1];
    item_3.data = &a[2];
    kmip_linked_list_enqueue(&list, &item_1);
    kmip_linked_list_enqueue(&list, &item_2);
    kmip_linked_list_enqueue(&list, &item_3);
    attributes.attribute_list = &list;

    ProtectionStorageMasks psm = {0};
    LinkedList masks = {0};
    LinkedListItem mask_1, mask_2 = {0};
    int32 m1 = KMIP_PROTECT_SOFTWARE | KMIP_PROTECT_ON_SYSTEM;
    int32 m2 = KMIP_PROTECT_OFF_SYSTEM | KMIP_PROTECT_OFF_PREMISES;
    mask_1.data = &m1;
    mask_2.data = &m2;
    kmip_linked_list_enqueue(&masks, &mask_1);
    kmip_linked_list_enqueue(&masks, &mask_2);
    psm.masks = &masks;

    CreateRequestPayload expected = {0};
    expected.object_type = KMIP_OBJTYPE_SYMMETRIC_KEY;
    expected.attributes = &attributes;
    expected.protection_storage_masks = &psm;
    
    CreateRequestPayload observed = {0};
    
    int result = kmip_decode_create_request_payload(&ctx, &observed);
    result = report_decoding_test_result(
        tracker,
        &ctx,
        kmip_compare_create_request_payload(&expected, &observed),
        result,
        __func__);
    kmip_free_create_request_payload(&ctx, &observed);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa70, %rsp            # imm = 0xA70
movq %rdi, %rbx
incw (%rdi)
leaq 0x2076b(%rip), %rsi     # 0x2a030
pushq $0xf
popq %rcx
leaq 0x160(%rsp), %r14
movq %r14, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1d8(%rsp), %r15
xorl %r12d, %r12d
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
pushq $0x78
popq %rdx
pushq $0x5
popq %rcx
movq %r15, %rdi
movq %r14, %rsi
callq 0x128ed
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
cmpq $0x30, %r12
je 0x992c
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0x12e6d
addq $0x10, %r12
jmp 0x9913
pushq $0x3
popq %rax
leaq 0x1c(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x30(%rsp), %rdx
movl %eax, -0x10(%rdx)
movq %rcx, -0x8(%rdx)
leaq 0x18(%rsp), %rax
movl $0x80, (%rax)
movl $0x4, (%rdx)
movq %rax, 0x8(%rdx)
leaq 0x14(%rsp), %rax
movl $0xc, (%rax)
leaq 0x40(%rsp), %rcx
movl $0x6, (%rcx)
movq %rax, 0x8(%rcx)
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0xa0(%rsp), %r15
movaps %xmm0, (%r15)
leaq 0x20(%rsp), %rax
leaq 0x108(%rsp), %rsi
movq %rax, 0x10(%rsi)
leaq 0xf0(%rsp), %r12
movq %rdx, 0x10(%r12)
movq %rcx, 0x10(%r15)
movq %r14, %rdi
callq 0x12233
movq %r14, %rdi
movq %r12, %rsi
callq 0x12233
movq %r14, %rdi
movq %r15, %rsi
callq 0x12233
leaq 0x58(%rsp), %r12
movq %r14, (%r12)
leaq 0x80(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x60(%rsp), %r15
movaps %xmm0, (%r15)
leaq 0x10(%rsp), %rax
movl $0x9, (%rax)
leaq 0xc(%rsp), %rcx
movl $0x210, (%rcx)          # imm = 0x210
leaq 0xd8(%rsp), %rsi
movq %rax, 0x10(%rsi)
movq %rcx, 0x10(%r15)
movq %r14, %rdi
callq 0x12233
movq %r14, %rdi
movq %r15, %rsi
callq 0x12233
leaq 0x50(%rsp), %rax
movq %r14, (%rax)
leaq 0x140(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movl $0x2, (%r14)
movq %r12, 0x10(%r14)
movq %rax, 0x18(%r14)
leaq 0x120(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x1d8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1df65
movl %eax, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x15669
leaq 0x1d809(%rip), %r8      # 0x27297
movq %rbx, %rdi
movq %r12, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x134d
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x137a6
movq %r12, %rdi
callq 0x12ade
movl %ebx, %eax
addq $0xa70, %rsp            # imm = 0xA70
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq