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

    uint8 expected[40] = {
        0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
        0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
        0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };
    
    uint8 too_small[30] = {0};
    uint8 large_enough[40] = {0};
    struct kmip ctx = {0};
    kmip_init(&ctx, too_small, ARRAY_LENGTH(too_small), KMIP_1_0);
    
    struct protocol_version pv = {0};
    pv.major = 1;
    pv.minor = 0;
    
    int result = kmip_encode_protocol_version(&ctx, &pv);
    
    if(result == KMIP_ERROR_BUFFER_FULL)
    {
        kmip_reset(&ctx);
        kmip_set_buffer(&ctx, large_enough, ARRAY_LENGTH(large_enough));
        
        result = kmip_encode_protocol_version(&ctx, &pv);
        result = report_encoding_test_result(
            tracker,
            &ctx,
            expected,
            large_enough,
            result,
            __func__);
        
        kmip_destroy(&ctx);
        
        return(result);
    }
    else
    {
        printf("FAIL - %s\n", __func__);
        printf("- expected buffer full\n");
        
        kmip_destroy(&ctx);
        tracker->tests_failed++;
        return(1);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x940, %rsp            # imm = 0x940
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movw (%rax), %cx
addw $0x1, %cx
movw %cx, (%rax)
leaq -0x40(%rbp), %rdi
leaq 0x3f7e8(%rip), %rsi     # 0x41650
movl $0x28, %edx
callq 0x10c0
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x1e, %edx
callq 0x1090
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1090
leaq -0x928(%rbp), %rdi
xorl %esi, %esi
movl $0x898, %edx            # imm = 0x898
callq 0x1090
leaq -0x60(%rbp), %rsi
leaq -0x928(%rbp), %rdi
movl $0x1e, %edx
xorl %ecx, %ecx
callq 0x1c6e0
leaq -0x930(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x1090
movl $0x1, -0x930(%rbp)
movl $0x0, -0x92c(%rbp)
leaq -0x928(%rbp), %rdi
leaq -0x930(%rbp), %rsi
callq 0x26cf0
movl %eax, -0x934(%rbp)
cmpl $-0x2, -0x934(%rbp)
jne 0x1f8f
leaq -0x928(%rbp), %rdi
callq 0x1c9c0
leaq -0x90(%rbp), %rsi
leaq -0x928(%rbp), %rdi
movl $0x28, %edx
callq 0x1ca60
leaq -0x928(%rbp), %rdi
leaq -0x930(%rbp), %rsi
callq 0x26cf0
movl %eax, -0x934(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rdx
leaq -0x90(%rbp), %rcx
movl -0x934(%rbp), %r8d
leaq -0x928(%rbp), %rsi
leaq 0x3d19d(%rip), %r9      # 0x3f10a
callq 0x11f0
movl %eax, -0x934(%rbp)
leaq -0x928(%rbp), %rdi
callq 0x1cab0
movl -0x934(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1fd5
leaq 0x3d06e(%rip), %rdi     # 0x3f004
leaq 0x3d16d(%rip), %rsi     # 0x3f10a
movb $0x0, %al
callq 0x1070
leaq 0x3d17b(%rip), %rdi     # 0x3f126
movb $0x0, %al
callq 0x1070
leaq -0x928(%rbp), %rdi
callq 0x1cab0
movq -0x10(%rbp), %rax
movw 0x2(%rax), %cx
addw $0x1, %cx
movw %cx, 0x2(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x940, %rsp            # imm = 0x940
popq %rbp
retq
nopw %cs:(%rax,%rax)