// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x8b8, %rsp            # imm = 0x8B8
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 0x20(%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 0x13177
movq 0x10(%r15), %r14
movapd (%r15), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x137ef
testl %eax, %eax
jne 0x243d
movdqa 0x10(%rsp), %xmm1
pcmpeqd 0x20(%rsp), %xmm1
pshufd $0xb1, %xmm1, %xmm0     # xmm0 = xmm1[1,0,3,2]
pand %xmm1, %xmm0
movmskpd %xmm0, %eax
testb $0x1, %al
je 0x243d
shrb %al
je 0x243d
cmpq %r14, 0x30(%rsp)
jne 0x243d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x13455
leaq 0x4(%rsp), %rsi
movl $0x3, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x13177
movq 0x10(%r14), %r15
movapd (%r14), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x137ef
cmpl $0x420008, %eax         # imm = 0x420008
jne 0x2452
movdqa 0x10(%rsp), %xmm1
pcmpeqd 0x20(%rsp), %xmm1
pshufd $0xb1, %xmm1, %xmm0     # xmm0 = xmm1[1,0,3,2]
pand %xmm1, %xmm0
movmskpd %xmm0, %eax
testb $0x1, %al
je 0x2452
shrb %al
je 0x2452
cmpq %r15, 0x30(%rsp)
jne 0x2452
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x13455
leaq 0x8(%rsp), %rsi
movl $0x5, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x13177
movq 0x10(%r14), %r15
movapd (%r14), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x137ef
cmpl $0x420053, %eax         # imm = 0x420053
jne 0x2467
movdqa 0x10(%rsp), %xmm1
pcmpeqd 0x20(%rsp), %xmm1
pshufd $0xb1, %xmm1, %xmm0     # xmm0 = xmm1[1,0,3,2]
pand %xmm1, %xmm0
movmskpd %xmm0, %eax
testb $0x1, %al
je 0x2467
shrb %al
je 0x2467
cmpq %r15, 0x30(%rsp)
jne 0x2467
leaq 0x20(%rsp), %rdi
callq 0x13455
leaq 0x2adf1(%rip), %rdi     # 0x2d217
leaq 0x2b03c(%rip), %rsi     # 0x2d469
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1090
movl $0x4, %eax
jmp 0x248b
leaq 0x2adde(%rip), %rdi     # 0x2d222
leaq 0x2b01e(%rip), %rsi     # 0x2d469
movl $0x315, %edx            # imm = 0x315
jmp 0x247a
leaq 0x2adc9(%rip), %rdi     # 0x2d222
leaq 0x2b009(%rip), %rsi     # 0x2d469
movl $0x321, %edx            # imm = 0x321
jmp 0x247a
leaq 0x2adb4(%rip), %rdi     # 0x2d222
leaq 0x2aff4(%rip), %rsi     # 0x2d469
movl $0x32d, %edx            # imm = 0x32D
xorl %eax, %eax
callq 0x1090
movl $0x1, %ebp
movl $0x2, %eax
incw (%rbx,%rax)
movl %ebp, %eax
addq $0x8b8, %rsp            # imm = 0x8B8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq