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

    /* Build an encoding with an arbitrary tag value. Verify that this
       function reads and returns this tag value without changing the
       context buffer.
    */

    uint8 underfull_encoding[1] = {0x42};
    uint8 full_encoding[3] = {0x42, 0x00, 0x08};
    uint8 overfull_encoding[5] = {0x42, 0x00, 0x53, 0x01, 0x00};

    uint32 tag = 0;
    uint8 *prev_buffer = NULL;
    uint8 *prev_index = NULL;
    size_t prev_size = 0;
    KMIP ctx = {0};
    kmip_init(&ctx, underfull_encoding, ARRAY_LENGTH(underfull_encoding), KMIP_1_0);

    prev_buffer = ctx.buffer;
    prev_index = ctx.index;
    prev_size = ctx.size;
    tag = kmip_peek_tag(&ctx);
    if(tag != 0 || ctx.buffer != prev_buffer || ctx.index != prev_index || ctx.size != prev_size)
    {
        TEST_FAILED(tracker, __func__, __LINE__);
    }

    kmip_destroy(&ctx);
    kmip_init(&ctx, full_encoding, ARRAY_LENGTH(full_encoding), KMIP_1_0);

    prev_buffer = ctx.buffer;
    prev_index = ctx.index;
    prev_size = ctx.size;
    tag = kmip_peek_tag(&ctx);
    if(tag != KMIP_TAG_ATTRIBUTE || ctx.buffer != prev_buffer || ctx.index != prev_index || ctx.size != prev_size)
    {
        TEST_FAILED(tracker, __func__, __LINE__);
    }

    kmip_destroy(&ctx);
    kmip_init(&ctx, overfull_encoding, ARRAY_LENGTH(overfull_encoding), KMIP_1_0);

    prev_buffer = ctx.buffer;
    prev_index = ctx.index;
    prev_size = ctx.size;
    tag = kmip_peek_tag(&ctx);
    if(tag != KMIP_TAG_NAME || ctx.buffer != prev_buffer || ctx.index != prev_index || ctx.size != prev_size)
    {
        TEST_FAILED(tracker, __func__, __LINE__);
    }

    kmip_destroy(&ctx);

    TEST_PASSED(tracker, __func__);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8a8, %rsp            # imm = 0x8A8
movq %rdi, %rbx
incw (%rdi)
leaq 0x7(%rsp), %r14
movb $0x42, (%r14)
movb $0x8, 0x6(%rsp)
movw $0x42, 0x4(%rsp)
movb $0x0, 0xc(%rsp)
movl $0x1530042, 0x8(%rsp)   # imm = 0x1530042
leaq 0x10(%rsp), %r15
movl $0x898, %edx            # imm = 0x898
movq %r15, %rdi
xorl %esi, %esi
callq 0x10c0
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x13747
movq (%r15), %r13
movq 0x8(%r15), %r12
movq 0x10(%r15), %r14
movq %r15, %rdi
callq 0x13dbd
testl %eax, %eax
jne 0x24d6
cmpq %r13, 0x10(%rsp)
jne 0x24d6
cmpq %r12, 0x18(%rsp)
jne 0x24d6
cmpq %r14, 0x20(%rsp)
jne 0x24d6
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x13a23
leaq 0x4(%rsp), %rsi
movl $0x3, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x13747
movq (%r14), %r13
movq 0x8(%r14), %r12
movq 0x10(%r14), %r15
movq %r14, %rdi
callq 0x13dbd
cmpl $0x420008, %eax         # imm = 0x420008
jne 0x24eb
cmpq %r13, 0x10(%rsp)
jne 0x24eb
cmpq %r12, 0x18(%rsp)
jne 0x24eb
cmpq %r15, 0x20(%rsp)
jne 0x24eb
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x13a23
leaq 0x8(%rsp), %rsi
movl $0x5, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x13747
movq (%r14), %r13
movq 0x8(%r14), %r12
movq 0x10(%r14), %r15
movq %r14, %rdi
callq 0x13dbd
cmpl $0x420053, %eax         # imm = 0x420053
jne 0x2500
cmpq %r13, 0x10(%rsp)
jne 0x2500
cmpq %r12, 0x18(%rsp)
jne 0x2500
cmpq %r15, 0x20(%rsp)
jne 0x2500
leaq 0x10(%rsp), %rdi
callq 0x13a23
leaq 0x2cd58(%rip), %rdi     # 0x2f217
leaq 0x2cfa3(%rip), %rsi     # 0x2f469
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1090
movl $0x4, %eax
jmp 0x2524
leaq 0x2cd45(%rip), %rdi     # 0x2f222
leaq 0x2cf85(%rip), %rsi     # 0x2f469
movl $0x315, %edx            # imm = 0x315
jmp 0x2513
leaq 0x2cd30(%rip), %rdi     # 0x2f222
leaq 0x2cf70(%rip), %rsi     # 0x2f469
movl $0x321, %edx            # imm = 0x321
jmp 0x2513
leaq 0x2cd1b(%rip), %rdi     # 0x2f222
leaq 0x2cf5b(%rip), %rsi     # 0x2f469
movl $0x32d, %edx            # imm = 0x32D
xorl %eax, %eax
callq 0x1090
movl $0x1, %ebp
movl $0x2, %eax
incw (%rbx,%rax)
movl %ebp, %eax
addq $0x8a8, %rsp            # imm = 0x8A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq