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

    uint8 expected[288] = {
        0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x01, 0x18, 
        0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28, 
        0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09, 
        0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65, 
        0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
        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, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18, 
        0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72, 
        0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73, 
        0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B, 
        0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x38, 
        0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04, 
        0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x20, 
        0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x04, 
        0x4B, 0x65, 0x79, 0x31, 0x00, 0x00, 0x00, 0x00, 
        0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04, 
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
    };
    
    uint8 observed[288] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, observed, ARRAY_LENGTH(observed), KMIP_1_0);
    
    struct text_string v = {0};
    v.value = "Template1";
    v.size = 9;
    
    struct name n = {0};
    n.value = &v;
    n.type = KMIP_NAME_UNINTERPRETED_TEXT_STRING;
    
    struct attribute a[4] = {0};
    for(int i = 0; i < 4; 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;
    
    struct text_string value = {0};
    value.value = "Key1";
    value.size = 4;
    
    struct name name = {0};
    name.value = &value;
    name.type = KMIP_NAME_UNINTERPRETED_TEXT_STRING;
    a[3].type = KMIP_ATTR_NAME;
    a[3].value = &name;
    
    struct template_attribute ta = {0};
    ta.names = &n;
    ta.name_count = 1;
    ta.attributes = a;
    ta.attribute_count = ARRAY_LENGTH(a);
    
    int result = kmip_encode_template_attribute(&ctx, &ta);
    result = report_encoding_test_result(
        tracker,
        &ctx,
        expected,
        observed,
        result,
        __func__);
    kmip_destroy(&ctx);
    return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xbb0, %rsp            # imm = 0xBB0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x130(%rbp), %rdi
leaq 0x30435(%rip), %rsi     # 0x45830
movl $0x120, %edx            # imm = 0x120
callq 0x10c0
leaq -0x250(%rbp), %rdi
xorl %esi, %esi
movl $0x120, %edx            # imm = 0x120
callq 0x1090
leaq -0xae8(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x250(%rbp), %rsi
leaq -0xae8(%rbp), %rdi
movl $0x120, %edx            # imm = 0x120
xorl %ecx, %ecx
callq 0x1c6e0
leaq -0xaf8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x2a2b3(%rip), %rax     # 0x3f712
movq %rax, -0xaf8(%rbp)
movq $0x9, -0xaf0(%rbp)
leaq -0xb08(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xaf8(%rbp), %rax
movq %rax, -0xb08(%rbp)
movl $0x1, -0xb00(%rbp)
leaq -0xb50(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x1090
movl $0x0, -0xb54(%rbp)
cmpl $0x4, -0xb54(%rbp)
jge 0x154ed
movslq -0xb54(%rbp), %rax
leaq -0xb50(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0x1d330
movl -0xb54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb54(%rbp)
jmp 0x154b9
movl $0x3, -0xb58(%rbp)
movl $0x3, -0xb50(%rbp)
leaq -0xb58(%rbp), %rax
movq %rax, -0xb48(%rbp)
movl $0x80, -0xb5c(%rbp)
movl $0x4, -0xb40(%rbp)
leaq -0xb5c(%rbp), %rax
movq %rax, -0xb38(%rbp)
movl $0xc, -0xb60(%rbp)
movl $0x6, -0xb30(%rbp)
leaq -0xb60(%rbp), %rax
movq %rax, -0xb28(%rbp)
leaq -0xb70(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq 0x2b8d1(%rip), %rax     # 0x40e3e
movq %rax, -0xb70(%rbp)
movq $0x4, -0xb68(%rbp)
leaq -0xb80(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x1090
leaq -0xb70(%rbp), %rax
movq %rax, -0xb80(%rbp)
movl $0x1, -0xb78(%rbp)
movl $0x1, -0xb20(%rbp)
leaq -0xb80(%rbp), %rax
movq %rax, -0xb18(%rbp)
leaq -0xba0(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1090
leaq -0xb08(%rbp), %rax
movq %rax, -0xba0(%rbp)
movq $0x1, -0xb98(%rbp)
leaq -0xb50(%rbp), %rax
movq %rax, -0xb90(%rbp)
movq $0x4, -0xb88(%rbp)
leaq -0xae8(%rbp), %rdi
leaq -0xba0(%rbp), %rsi
callq 0x26b30
movl %eax, -0xba4(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x130(%rbp), %rdx
leaq -0x250(%rbp), %rcx
movl -0xba4(%rbp), %r8d
leaq -0xae8(%rbp), %rsi
leaq 0x2b7fc(%rip), %r9      # 0x40e43
callq 0x11f0
movl %eax, -0xba4(%rbp)
leaq -0xae8(%rbp), %rdi
callq 0x1cab0
movl -0xba4(%rbp), %eax
addq $0xbb0, %rsp            # imm = 0xBB0
popq %rbp
retq
nopl (%rax)