// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0xa78, %rsp            # imm = 0xA78
movq %rdi, %rbx
incw (%rdi)
leaq 0x29150(%rip), %rsi     # 0x33040
leaq 0x160(%rsp), %r14
movl $0xf, %ecx
movq %r14, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1e0(%rsp), %r15
xorl %r12d, %r12d
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0x78, %edx
movq %r15, %rdi
movq %r14, %rsi
movl $0x5, %ecx
callq 0x13747
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0x13e59
addq $0x10, %r12
cmpq $0x30, %r12
jne 0x9f44
movl $0x3, %eax
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)
xorl %ebp, %ebp
leaq 0x58(%rsp), %r13
movq %rbp, (%r13)
leaq 0xc0(%rsp), %r14
movq %rbp, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%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 0x12ebd
movq %r14, %rdi
movq %r12, %rsi
callq 0x12ebd
movq %r14, %rdi
movq %r15, %rsi
callq 0x12ebd
movq %r14, (%r13)
leaq 0x50(%rsp), %r12
movq %rbp, (%r12)
leaq 0x80(%rsp), %r14
movq %rbp, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq 0x60(%rsp), %r15
movq %rbp, 0x10(%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 0x12ebd
movq %r14, %rdi
movq %r15, %rsi
callq 0x12ebd
movq %r14, (%r12)
leaq 0x140(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movl $0x2, (%r14)
movq %r13, 0x10(%r14)
movq %r12, 0x18(%r14)
leaq 0x120(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x1e0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x23642
movl %eax, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x16e0d
leaq 0x261c6(%rip), %r8      # 0x30297
movq %rbx, %rdi
movq %r12, %rsi
movl %eax, %edx
movl %ebp, %ecx
callq 0x1397
movl %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x14966
movq %r12, %rdi
callq 0x13a23
movl %ebx, %eax
addq $0xa78, %rsp            # imm = 0xA78
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq