// File: /workspace/github_c_makefile_star2_O0/OpenKMIP[P]libkmip/tests/tests.c
// Function: test_encode_create_request_payload_kmip_2_0
int
test_encode_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 expected[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
    };
    
    uint8 observed[120] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), 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 payload = {0};
    payload.object_type = KMIP_OBJTYPE_SYMMETRIC_KEY;
    payload.attributes = &attributes;
    payload.protection_storage_masks = &psm;
    
    int result = kmip_encode_create_request_payload(&ctx, &payload);
    result = report_encoding_test_result(
        tracker,
        &ctx,
        expected,
        observed,
        result,
        __func__);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xad0, %rsp            # imm = 0xAD0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x80(%rbp), %rdi
leaq 0x367e8(%rip), %rsi     # 0x443a0
movl $0x78, %edx
callq 0x10c0
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x1090
leaq -0x998(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x100(%rbp), %rsi
leaq -0x998(%rbp), %rdi
movl $0x78, %edx
movl $0x5, %ecx
callq 0x1c6e0
leaq -0x9d0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x1090
movl $0x0, -0x9d4(%rbp)
cmpl $0x3, -0x9d4(%rbp)
jge 0xdc56
movslq -0x9d4(%rbp), %rax
leaq -0x9d0(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x1d330
movl -0x9d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9d4(%rbp)
jmp 0xdc22
movl $0x3, -0x9d8(%rbp)
movl $0x3, -0x9d0(%rbp)
leaq -0x9d8(%rbp), %rax
movq %rax, -0x9c8(%rbp)
movl $0x80, -0x9dc(%rbp)
movl $0x4, -0x9c0(%rbp)
leaq -0x9dc(%rbp), %rax
movq %rax, -0x9b8(%rbp)
movl $0xc, -0x9e0(%rbp)
movl $0x6, -0x9b0(%rbp)
leaq -0x9e0(%rbp), %rax
movq %rax, -0x9a8(%rbp)
leaq -0x9e8(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
leaq -0xa00(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0xa48(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0x9d0(%rbp), %rax
movq %rax, -0xa08(%rbp)
leaq -0x9d0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xa20(%rbp)
leaq -0x9d0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0xa38(%rbp)
leaq -0xa00(%rbp), %rdi
leaq -0xa18(%rbp), %rsi
callq 0x1b660
leaq -0xa00(%rbp), %rdi
leaq -0xa30(%rbp), %rsi
callq 0x1b660
leaq -0xa00(%rbp), %rdi
leaq -0xa48(%rbp), %rsi
callq 0x1b660
leaq -0xa00(%rbp), %rax
movq %rax, -0x9e8(%rbp)
leaq -0xa50(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
leaq -0xa68(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0xa98(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
movl $0x9, -0xa9c(%rbp)
movl $0x210, -0xaa0(%rbp)    # imm = 0x210
leaq -0xa9c(%rbp), %rax
movq %rax, -0xa70(%rbp)
leaq -0xaa0(%rbp), %rax
movq %rax, -0xa88(%rbp)
leaq -0xa68(%rbp), %rdi
leaq -0xa80(%rbp), %rsi
callq 0x1b660
leaq -0xa68(%rbp), %rdi
leaq -0xa98(%rbp), %rsi
callq 0x1b660
leaq -0xa68(%rbp), %rax
movq %rax, -0xa50(%rbp)
leaq -0xac0(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
movl $0x2, -0xac0(%rbp)
leaq -0x9e8(%rbp), %rax
movq %rax, -0xab0(%rbp)
leaq -0xa50(%rbp), %rax
movq %rax, -0xaa8(%rbp)
leaq -0x998(%rbp), %rdi
leaq -0xac0(%rbp), %rsi
callq 0x28140
movl %eax, -0xac4(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x100(%rbp), %rcx
movl -0xac4(%rbp), %r8d
leaq -0x998(%rbp), %rsi
leaq 0x3230f(%rip), %r9      # 0x40190
callq 0x11f0
movl %eax, -0xac4(%rbp)
leaq -0x998(%rbp), %rdi
callq 0x1cab0
movl -0xac4(%rbp), %eax
addq $0xad0, %rsp            # imm = 0xAD0
popq %rbp
retq
nopw (%rax,%rax)