// File: /workspace/github_c_makefile_star2_O0/vidarr[P]ringbuffer/test/ringbuffer_test.c
// Function: test_free
void test_free() {

    int a = 1;

    Ringbuffer* buffer = 0;
    assert(0 == free_func(0));

    buffer = ringbuffer_create(1, 0, 0);
    assert(0 == buffer->free(buffer));

    buffer = ringbuffer_create(21, 0, 0);
    assert(0 == buffer->free(buffer));

    buffer = ringbuffer_create(21, 0, 0);
    for(size_t i = 0; i < buffer->capacity(buffer); ++i) {
        buffer->add(buffer, &a);
    }
    assert(0 == buffer->free(buffer));

    size_t count = 0;
    buffer = ringbuffer_create(21, count_free, &count);
    for(size_t i = 0; i < buffer->capacity(buffer); ++i) {
        int* ip = calloc(1, sizeof(int));
        *ip = i;
        buffer->add(buffer, ip);
    }
    assert(0 == buffer->free(buffer));
    assert(21 == count);

    fprintf(stdout, "free() OK\n");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x1, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x14b0
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x172c
jmp 0x174b
leaq 0x199b(%rip), %rdi      # 0x30ce
leaq 0x18d1(%rip), %rsi      # 0x300b
movl $0x4f, %edx
leaq 0x199a(%rip), %rcx      # 0x30e0
callq 0x1040
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1190
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x177a
jmp 0x1799
leaq 0x1970(%rip), %rdi      # 0x30f1
leaq 0x1883(%rip), %rsi      # 0x300b
movl $0x52, %edx
leaq 0x194c(%rip), %rcx      # 0x30e0
callq 0x1040
movl $0x15, %edi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1190
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x17c8
jmp 0x17e7
leaq 0x1922(%rip), %rdi      # 0x30f1
leaq 0x1835(%rip), %rsi      # 0x300b
movl $0x55, %edx
leaq 0x18fe(%rip), %rcx      # 0x30e0
callq 0x1040
movl $0x15, %edi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1190
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
movq -0x38(%rbp), %rax
cmpq %rcx, %rax
jae 0x1845
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x4(%rbp), %rsi
callq *%rax
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1804
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x185f
jmp 0x187e
leaq 0x188b(%rip), %rdi      # 0x30f1
leaq 0x179e(%rip), %rsi      # 0x300b
movl $0x5b, %edx
leaq 0x1867(%rip), %rcx      # 0x30e0
callq 0x1040
movq $0x0, -0x20(%rbp)
movl $0x15, %edi
leaq -0x1e2(%rip), %rsi      # 0x16b0
leaq -0x20(%rbp), %rdx
callq 0x1190
movq %rax, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
jae 0x1907
movl $0x1, %edi
movl $0x4, %esi
callq 0x1060
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq *%rax
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x18a7
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x1921
jmp 0x1940
leaq 0x17c9(%rip), %rdi      # 0x30f1
leaq 0x16dc(%rip), %rsi      # 0x300b
movl $0x64, %edx
leaq 0x17a5(%rip), %rcx      # 0x30e0
callq 0x1040
movl $0x15, %eax
cmpq -0x20(%rbp), %rax
jne 0x194d
jmp 0x196c
leaq 0x17b7(%rip), %rdi      # 0x310b
leaq 0x16b0(%rip), %rsi      # 0x300b
movl $0x65, %edx
leaq 0x1779(%rip), %rcx      # 0x30e0
callq 0x1040
movq 0x366d(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x179a(%rip), %rsi      # 0x3117
movb $0x0, %al
callq 0x1070
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)