// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x128ed
movq 0x10(%r15), %r14
movapd (%r15), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x12ddb
testl %eax, %eax
jne 0x2368
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 0x2368
shrb %al
je 0x2368
cmpq %r14, 0x30(%rsp)
jne 0x2368
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x12ade
leaq 0x4(%rsp), %rsi
pushq $0x3
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x128ed
movq 0x10(%r14), %r15
movapd (%r14), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x12ddb
cmpl $0x420008, %eax         # imm = 0x420008
jne 0x237d
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 0x237d
shrb %al
je 0x237d
cmpq %r15, 0x30(%rsp)
jne 0x237d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x12ade
leaq 0x8(%rsp), %rsi
pushq $0x5
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x128ed
movq 0x10(%r14), %r15
movapd (%r14), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x12ddb
cmpl $0x420053, %eax         # imm = 0x420053
jne 0x2392
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 0x2392
shrb %al
je 0x2392
cmpq %r15, 0x30(%rsp)
jne 0x2392
leaq 0x20(%rsp), %rdi
callq 0x12ade
leaq 0x23ec3(%rip), %rdi     # 0x26217
leaq 0x2410e(%rip), %rsi     # 0x26469
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1090
pushq $0x4
jmp 0x23b1
leaq 0x23eb3(%rip), %rdi     # 0x26222
leaq 0x240f3(%rip), %rsi     # 0x26469
movl $0x315, %edx            # imm = 0x315
jmp 0x23a5
leaq 0x23e9e(%rip), %rdi     # 0x26222
leaq 0x240de(%rip), %rsi     # 0x26469
movl $0x321, %edx            # imm = 0x321
jmp 0x23a5
leaq 0x23e89(%rip), %rdi     # 0x26222
leaq 0x240c9(%rip), %rsi     # 0x26469
movl $0x32d, %edx            # imm = 0x32D
xorl %eax, %eax
callq 0x1090
pushq $0x1
popq %rbp
pushq $0x2
popq %rax
incw (%rbx,%rax)
movl %ebp, %eax
addq $0x8b8, %rsp            # imm = 0x8B8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq