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

    uint8 encoding[168] = {
        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        
    };

    struct kmip ctx = {0};
    kmip_init(&ctx, encoding, ARRAY_LENGTH(encoding), KMIP_1_0);
    
    uint8 *before = ctx.index;
    int result = 0;
    size_t count = 0;
    
    count = kmip_get_num_items_next(&ctx, KMIP_TAG_ATTRIBUTE);
    if(count != 3)
    {
        printf("FAIL - %s\n", __func__);
        printf("- expected item count not found (exp. 3, obs. %zu)\n",
               count);
        tracker->tests_failed++;
        result = 1;
    }
    
    uint8 *after = ctx.index;
    
    if(before != after)
    {
        printf("FAIL - %s\n", __func__);
        printf("- item count checking modifies context buffer index\n");
        tracker->tests_failed++;
        result = 1;
    }
    
    kmip_destroy(&ctx);
    
    if(result == 0)
    {
        printf("PASS - %s\n", __func__);
        tracker->tests_passed++;
    }
    
    return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x940, %rsp            # imm = 0x940
movq %rdi, %rbx
incw (%rdi)
leaq 0x2dc52(%rip), %rsi     # 0x2f7f0
movq %rsp, %r14
movl $0xa8, %edx
movq %r14, %rdi
callq 0x1100
leaq 0xa8(%rsp), %r15
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0xa8, %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x13177
movq 0x8(%r15), %r12
movq %r15, %rdi
movl $0x420008, %esi         # imm = 0x420008
callq 0x136fa
cmpq $0x3, %rax
jne 0x1c22
cmpq 0xb0(%rsp), %r12
jne 0x1c59
leaq 0xa8(%rsp), %rdi
callq 0x13455
leaq 0x2b60b(%rip), %rdi     # 0x2d217
leaq 0x2b691(%rip), %rsi     # 0x2d2a4
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1090
incw 0x4(%rbx)
jmp 0x1c90
movq %rax, %r14
leaq 0x2b5a4(%rip), %rdi     # 0x2d1d0
leaq 0x2b671(%rip), %rsi     # 0x2d2a4
xorl %eax, %eax
callq 0x1090
leaq 0x2b67b(%rip), %rdi     # 0x2d2bc
movq %r14, %rsi
xorl %eax, %eax
callq 0x1090
incw 0x2(%rbx)
cmpq 0xb0(%rsp), %r12
je 0x1c7e
leaq 0x2b570(%rip), %rdi     # 0x2d1d0
leaq 0x2b63d(%rip), %rsi     # 0x2d2a4
xorl %eax, %eax
callq 0x1090
leaq 0x2da0e(%rip), %rdi     # 0x2f683
callq 0x1070
incw 0x2(%rbx)
leaq 0xa8(%rsp), %rdi
callq 0x13455
movl $0x1, %ebp
movl %ebp, %eax
addq $0x940, %rsp            # imm = 0x940
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq