// File: /workspace/github_c_makefile_star2_O2/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 $0x958, %rsp            # imm = 0x958
movq %rdi, %r14
incw (%rdi)
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %r15
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
andq $0x0, 0x20(%r15)
leaq 0xc0(%rsp), %rbx
movl $0x898, %edx            # imm = 0x898
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10c0
pushq $0x28
popq %rdx
pushq $0x5
popq %rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x128ed
leaq 0x70(%rsp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
leaq 0x50(%rsp), %r13
movaps %xmm0, (%r13)
leaq 0x20(%rsp), %rbp
movaps %xmm0, (%rbp)
movq %rbp, %rdi
callq 0x12e6d
pushq $0x3
popq %rax
leaq 0x4(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, (%rbp)
movq %rcx, 0x8(%rbp)
movq %rbp, 0x10(%r13)
leaq 0x30(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, (%rbp)
leaq 0x10(%rsp), %rbx
movaps %xmm0, (%rbx)
movq %rbx, %rdi
callq 0x12e6d
movq %rsp, %rax
movl $0x80, (%rax)
movl $0x4, (%rbx)
movq %rax, 0x8(%rbx)
movq %rbx, 0x10(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x12233
movq %r12, %rdi
movq %rbp, %rsi
callq 0x12233
leaq 0x8(%rsp), %rsi
movq %r12, (%rsi)
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x17866
leaq 0x1e7de(%rip), %rdx     # 0x2a920
leaq 0x1b776(%rip), %r9      # 0x278bf
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %r14
movq %r15, %rcx
movl %eax, %r8d
callq 0x123c
movl %eax, %ebx
movq %r14, %rdi
callq 0x12ade
movl %ebx, %eax
addq $0x958, %rsp            # imm = 0x958
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq