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

    uint8 expected[144] = {
        0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x88, 
        0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10, 
        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
        0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17, 
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C, 
        0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00, 
        0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65, 
        0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
    };
    
    uint8 observed[144] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), KMIP_1_0);
    
    uint8 value[16] = {
        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
        0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
    };
    struct byte_string key = {0};
    key.value = value;
    key.size = ARRAY_LENGTH(value);
    
    struct attribute attributes[2] = {0};
    for(int i = 0; i < 2; i++)
    {
        kmip_init_attribute(&attributes[i]);
    }
    
    enum cryptographic_algorithm ca = KMIP_CRYPTOALG_AES;
    int length = 128;
    attributes[0].type = KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM;
    attributes[0].value = &ca;
    attributes[1].type = KMIP_ATTR_CRYPTOGRAPHIC_LENGTH;
    attributes[1].value = &length;
    
    struct key_value kv = {0};
    kv.key_material = &key;
    kv.attributes = attributes;
    kv.attribute_count = ARRAY_LENGTH(attributes);
    
    int result = kmip_encode_key_value(&ctx, KMIP_KEYFORMAT_RAW, &kv);
    result = report_encoding_test_result(
        tracker,
        &ctx,
        expected,
        observed,
        result,
        __func__);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa40, %rsp            # imm = 0xA40
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0xa0(%rbp), %rdi
leaq 0x36735(%rip), %rsi     # 0x42690
movl $0x90, %edx
callq 0x10c0
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x1090
leaq -0x9c8(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x130(%rbp), %rsi
leaq -0x9c8(%rbp), %rdi
movl $0x90, %edx
xorl %ecx, %ecx
callq 0x1c6e0
movq 0x3b1e4(%rip), %rax     # 0x47190
movq %rax, -0x9e0(%rbp)
movq 0x3b1de(%rip), %rax     # 0x47198
movq %rax, -0x9d8(%rbp)
leaq -0x9f0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0x9e0(%rbp), %rax
movq %rax, -0x9f0(%rbp)
movq $0x10, -0x9e8(%rbp)
leaq -0xa10(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
movl $0x0, -0xa14(%rbp)
cmpl $0x2, -0xa14(%rbp)
jge 0xc03e
movslq -0xa14(%rbp), %rax
leaq -0xa10(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x1d330
movl -0xa14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa14(%rbp)
jmp 0xc00a
movl $0x3, -0xa18(%rbp)
movl $0x80, -0xa1c(%rbp)
movl $0x3, -0xa10(%rbp)
leaq -0xa18(%rbp), %rax
movq %rax, -0xa08(%rbp)
movl $0x4, -0xa00(%rbp)
leaq -0xa1c(%rbp), %rax
movq %rax, -0x9f8(%rbp)
leaq -0xa38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1090
leaq -0x9f0(%rbp), %rax
movq %rax, -0xa38(%rbp)
leaq -0xa10(%rbp), %rax
movq %rax, -0xa30(%rbp)
movq $0x2, -0xa28(%rbp)
leaq -0x9c8(%rbp), %rdi
movl $0x1, %esi
leaq -0xa38(%rbp), %rdx
callq 0x27720
movl %eax, -0xa3c(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq -0x130(%rbp), %rcx
movl -0xa3c(%rbp), %r8d
leaq -0x9c8(%rbp), %rsi
leaq 0x33e6f(%rip), %r9      # 0x3ff70
callq 0x11f0
movl %eax, -0xa3c(%rbp)
leaq -0x9c8(%rbp), %rdi
callq 0x1cab0
movl -0xa3c(%rbp), %eax
addq $0xa40, %rsp            # imm = 0xA40
popq %rbp
retq
nopw (%rax,%rax)