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

    /* This encoding matches the following set of values:
    *  Attributes
    *      Cryptographic Algorithm - AES
    *      Cryptographic Length - 128
    */
    uint8 expected[40] = {
        0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
        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
    };
    
    uint8 observed[40] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), KMIP_2_0);

    LinkedList attribute_list = {0};

    LinkedListItem item_1 = {0};
    Attribute attr_1 = {0};
    kmip_init_attribute(&attr_1);
    enum cryptographic_algorithm algorithm = KMIP_CRYPTOALG_AES;
    attr_1.type = KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM;
    attr_1.value = &algorithm;
    item_1.data = &attr_1;

    LinkedListItem item_2 = {0};
    Attribute attr_2 = {0};
    kmip_init_attribute(&attr_2);
    int32 length = 128;
    attr_2.type = KMIP_ATTR_CRYPTOGRAPHIC_LENGTH;
    attr_2.value = &length;
    item_2.data = &attr_2;

    kmip_linked_list_enqueue(&attribute_list, &item_1);
    kmip_linked_list_enqueue(&attribute_list, &item_2);

    Attributes attributes = {0};
    attributes.attribute_list = &attribute_list;

    int result = kmip_encode_attributes(&ctx, &attributes);
    result = report_encoding_test_result(tracker, &ctx, expected, observed, result, __func__);

    kmip_destroy(&ctx);

    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x968, %rsp            # imm = 0x968
movq %rdi, 0x8(%rsp)
incw (%rdi)
xorl %ebx, %ebx
leaq 0xa0(%rsp), %r15
movq %rbx, 0x20(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0xd0(%rsp), %r14
movl $0x898, %edx            # imm = 0x898
movq %r14, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0x28, %edx
movq %r14, %rdi
movq %r15, %rsi
movl $0x5, %ecx
callq 0x13747
leaq 0x80(%rsp), %r12
movq %rbx, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
leaq 0x60(%rsp), %r13
movq %rbx, 0x10(%r13)
movaps %xmm0, (%r13)
leaq 0x30(%rsp), %rbp
movaps %xmm0, (%rbp)
movq %rbp, %rdi
callq 0x13e59
movl $0x3, %eax
leaq 0x14(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, (%rbp)
movq %rcx, 0x8(%rbp)
movq %rbp, 0x10(%r13)
leaq 0x40(%rsp), %rbp
movq %rbx, 0x10(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbp)
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
movq %rbx, %rdi
callq 0x13e59
leaq 0x10(%rsp), %rax
movl $0x80, (%rax)
movl $0x4, (%rbx)
movq %rax, 0x8(%rbx)
movq %rbx, 0x10(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x12ebd
movq %r12, %rdi
movq %rbp, %rsi
callq 0x12ebd
leaq 0x18(%rsp), %rsi
movq %r12, (%rsi)
movq %r14, %rdi
callq 0x19570
leaq 0x26ffb(%rip), %rdx     # 0x33930
leaq 0x23f83(%rip), %r9      # 0x308bf
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rcx
movl %eax, %r8d
callq 0x123c
movl %eax, %ebx
movq %r14, %rdi
callq 0x13a23
movl %ebx, %eax
addq $0x968, %rsp            # imm = 0x968
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq