// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa70, %rsp            # imm = 0xA70
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x80(%rbp), %rdi
leaq 0x36408(%rip), %rsi     # 0x444f0
movl $0x78, %edx
callq 0x10c0
leaq -0x918(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x80(%rbp), %rsi
leaq -0x918(%rbp), %rdi
movl $0x78, %edx
movl $0x5, %ecx
callq 0x1c6e0
leaq -0x950(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1090
movl $0x0, -0x954(%rbp)
cmpl $0x3, -0x954(%rbp)
jge 0xe170
movslq -0x954(%rbp), %rax
leaq -0x950(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x1d330
movl -0x954(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x954(%rbp)
jmp 0xe13c
movl $0x3, -0x958(%rbp)
movl $0x3, -0x950(%rbp)
leaq -0x958(%rbp), %rax
movq %rax, -0x948(%rbp)
movl $0x80, -0x95c(%rbp)
movl $0x4, -0x940(%rbp)
leaq -0x95c(%rbp), %rax
movq %rax, -0x938(%rbp)
movl $0xc, -0x960(%rbp)
movl $0x6, -0x930(%rbp)
leaq -0x960(%rbp), %rax
movq %rax, -0x928(%rbp)
leaq -0x968(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
leaq -0x980(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0x9c8(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0x950(%rbp), %rax
movq %rax, -0x988(%rbp)
leaq -0x950(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x9a0(%rbp)
leaq -0x950(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x9b8(%rbp)
leaq -0x980(%rbp), %rdi
leaq -0x998(%rbp), %rsi
callq 0x1b660
leaq -0x980(%rbp), %rdi
leaq -0x9b0(%rbp), %rsi
callq 0x1b660
leaq -0x980(%rbp), %rdi
leaq -0x9c8(%rbp), %rsi
callq 0x1b660
leaq -0x980(%rbp), %rax
movq %rax, -0x968(%rbp)
leaq -0x9d0(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
leaq -0x9e8(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0xa18(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
movl $0x9, -0xa1c(%rbp)
movl $0x210, -0xa20(%rbp)    # imm = 0x210
leaq -0xa1c(%rbp), %rax
movq %rax, -0x9f0(%rbp)
leaq -0xa20(%rbp), %rax
movq %rax, -0xa08(%rbp)
leaq -0x9e8(%rbp), %rdi
leaq -0xa00(%rbp), %rsi
callq 0x1b660
leaq -0x9e8(%rbp), %rdi
leaq -0xa18(%rbp), %rsi
callq 0x1b660
leaq -0x9e8(%rbp), %rax
movq %rax, -0x9d0(%rbp)
leaq -0xa40(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
movl $0x2, -0xa40(%rbp)
leaq -0x968(%rbp), %rax
movq %rax, -0xa30(%rbp)
leaq -0x9d0(%rbp), %rax
movq %rax, -0xa28(%rbp)
leaq -0xa60(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
leaq -0x918(%rbp), %rdi
leaq -0xa60(%rbp), %rsi
callq 0x31bd0
movl %eax, -0xa64(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa70(%rbp)
leaq -0xa40(%rbp), %rdi
leaq -0xa60(%rbp), %rsi
callq 0x22560
movq -0xa70(%rbp), %rdi
movl %eax, %edx
movl -0xa64(%rbp), %ecx
leaq -0x918(%rbp), %rsi
leaq 0x31e1a(%rip), %r8      # 0x401df
callq 0x13a0
movl %eax, -0xa64(%rbp)
leaq -0x918(%rbp), %rdi
leaq -0xa60(%rbp), %rsi
callq 0x1e5e0
leaq -0x918(%rbp), %rdi
callq 0x1cab0
movl -0xa64(%rbp), %eax
addq $0xa70, %rsp            # imm = 0xA70
popq %rbp
retq
nop