// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x8d0, %rsp            # imm = 0x8D0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
movb 0x3ed26(%rip), %al      # 0x418f9
movb %al, -0x11(%rbp)
movw 0x3ed1d(%rip), %ax      # 0x418fa
movw %ax, -0x14(%rbp)
movb 0x3ed15(%rip), %al      # 0x418fc
movb %al, -0x12(%rbp)
movl 0x3ed0d(%rip), %eax     # 0x418fd
movl %eax, -0x19(%rbp)
movb 0x3ed08(%rip), %al      # 0x41901
movb %al, -0x15(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x8d0(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x11(%rbp), %rsi
leaq -0x8d0(%rbp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x1c6e0
movq -0x8d0(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8c8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8c0(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x8d0(%rbp), %rdi
callq 0x1d110
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x2ca2
movq -0x8d0(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x2ca2
movq -0x8c8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x2ca2
movq -0x8c0(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x2cda
jmp 0x2ca4
leaq 0x3c40a(%rip), %rdi     # 0x3f0b5
leaq 0x3c6e1(%rip), %rsi     # 0x3f393
movl $0x315, %edx            # imm = 0x315
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movw 0x2(%rax), %cx
addw $0x1, %cx
movw %cx, 0x2(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2e85
leaq -0x8d0(%rbp), %rdi
callq 0x1cab0
leaq -0x14(%rbp), %rsi
leaq -0x8d0(%rbp), %rdi
movl $0x3, %edx
xorl %ecx, %ecx
callq 0x1c6e0
movq -0x8d0(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8c8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8c0(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x8d0(%rbp), %rdi
callq 0x1d110
movl %eax, -0x20(%rbp)
cmpl $0x420008, -0x20(%rbp)  # imm = 0x420008
jne 0x2d5d
movq -0x8d0(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x2d5d
movq -0x8c8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x2d5d
movq -0x8c0(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x2d95
jmp 0x2d5f
leaq 0x3c34f(%rip), %rdi     # 0x3f0b5
leaq 0x3c626(%rip), %rsi     # 0x3f393
movl $0x321, %edx            # imm = 0x321
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movw 0x2(%rax), %cx
addw $0x1, %cx
movw %cx, 0x2(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2e85
leaq -0x8d0(%rbp), %rdi
callq 0x1cab0
leaq -0x19(%rbp), %rsi
leaq -0x8d0(%rbp), %rdi
movl $0x5, %edx
xorl %ecx, %ecx
callq 0x1c6e0
movq -0x8d0(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8c8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8c0(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x8d0(%rbp), %rdi
callq 0x1d110
movl %eax, -0x20(%rbp)
cmpl $0x420053, -0x20(%rbp)  # imm = 0x420053
jne 0x2e18
movq -0x8d0(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x2e18
movq -0x8c8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x2e18
movq -0x8c0(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x2e4d
jmp 0x2e1a
leaq 0x3c294(%rip), %rdi     # 0x3f0b5
leaq 0x3c56b(%rip), %rsi     # 0x3f393
movl $0x32d, %edx            # imm = 0x32D
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movw 0x2(%rax), %cx
addw $0x1, %cx
movw %cx, 0x2(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2e85
leaq -0x8d0(%rbp), %rdi
callq 0x1cab0
leaq 0x3c1eb(%rip), %rdi     # 0x3f04b
leaq 0x3c52c(%rip), %rsi     # 0x3f393
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rax
movw 0x4(%rax), %cx
addw $0x1, %cx
movw %cx, 0x4(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x8d0, %rsp            # imm = 0x8D0
popq %rbp
retq
nopw %cs:(%rax,%rax)