// File: /workspace/github_c_makefile_star2_O3/mruby-zest[P]osc-bridge/test/mock-test.c
// Function: main
int main()
{
    bool verbose = false;
    test_plan(21);

    //Apply Debug Hooks
    printf("#Setting up hooks...\n");
    osc_request_hook = osc_request_hook_fn;
    osc_socket_hook  = osc_socket_hook_fn;

    //Define that there is a bridge on localhost:1337
    bridge_t *bridge = br_create("osc.udp://localhost:1337");
    assert_non_null(bridge, "A Bridge is allocated", __LINE__);

    //Get the bridge to obtain the schema
    printf("#Creating Schema For Remote...\n");
    schema_t schema = br_get_schema(bridge, "/schema");
    assert_true(1000 <  schema.elements,
            "Schema has around the right number of elements", __LINE__);

    assert_int_eq(255, v1, "Verify pre-callback #1 data", __LINE__);
    assert_int_eq(255, v2, "Verify pre-callback #2 data", __LINE__);
    assert_false(v3, "Verify pre-callback #3 data", __LINE__);

    test_part_level(schema, bridge);
    test_options(schema, bridge);
    assert_int_eq(32, v1, "Callback #1 was applied", __LINE__);
    assert_int_eq(32, v2, "Callback #2 was applied", __LINE__);
    assert_true(v3, "Callback #3 was applied", __LINE__);

    br_default(bridge, schema, "/part0/Pvolume");

    assert_int_eq(96, v1, "Default #1 was applied", __LINE__);
    assert_int_eq(96, v2, "Default #2 was applied", __LINE__);

    printf("#bridge receive...\n");
    assert_int_eq(2, bridge->cache_len,
            "Verify number of cache fields", __LINE__);
    assert_int_eq(3, bridge->callback_len,
            "Verify number of callbacks", __LINE__);
    br_recv(bridge, 0);

    if(verbose) {
        for(int i=0; i<bridge->callback_len; ++i)
            printf("callback[%d][%s][%p]\n", i, bridge->callback[i].path,
                    bridge->callback[i].data);
        for(int i=0; i<bridge->cache_len; ++i)
            printf("cache[%d][%s][%d]\n", i, bridge->cache[i].path,
                    bridge->cache[i].pending);
    }

    assert_int_eq(0, br_pending(bridge),
            "No Cache Line is Pending", __LINE__);

    test_vector_functionality(bridge);

    //cleanup
    br_destroy(bridge);
    br_destroy_schema(schema);


    return test_summary();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
leaq 0x14e7(%rip), %rdi      # 0x9de3
movl $0x15, %esi
xorl %eax, %eax
callq 0x20f0
leaq 0x18fb(%rip), %rdi      # 0xa20a
callq 0x2080
leaq -0x73e(%rip), %rax      # 0x81dd
leaq 0x488e(%rip), %rcx      # 0xd1b0
movq %rax, (%rcx)
leaq -0x757(%rip), %rax      # 0x81d5
leaq 0x4875(%rip), %rcx      # 0xd1a8
movq %rax, (%rcx)
leaq 0x16b5(%rip), %rdi      # 0x9ff2
callq 0x27e7
movq %rax, %rbx
leaq 0x16bf(%rip), %rsi      # 0xa00b
movq %rax, %rdi
movl $0xb7, %edx
callq 0x7d6f
leaq 0x18bf(%rip), %rdi      # 0xa21f
callq 0x2080
leaq 0x14b2(%rip), %rdx      # 0x9e1e
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2b70
xorl %edi, %edi
cmpl $0x3e9, 0x10(%r14)      # imm = 0x3E9
setge %dil
leaq 0x1691(%rip), %rsi      # 0xa021
movl $0xbd, %edx
callq 0x7c6c
movl 0x47f0(%rip), %esi      # 0xd190
leaq 0x16a9(%rip), %rdx      # 0xa050
movl $0xff, %edi
movl $0xbf, %ecx
callq 0x7b78
movl 0x47d8(%rip), %esi      # 0xd194
leaq 0x16a9(%rip), %rdx      # 0xa06c
movl $0xff, %edi
movl $0xc0, %ecx
callq 0x7b78
movzbl 0x4dff(%rip), %edi      # 0xd7d8
xorl $0x1, %edi
leaq 0x16a5(%rip), %rsi      # 0xa088
movl $0xc1, %edx
callq 0x7c6c
movq 0x10(%r14), %rax
movq %rax, -0x20(%rbp)
movups (%r14), %xmm0
movaps %xmm0, -0x30(%rbp)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x8459
movq -0x20(%rbp), %rax
movq %rax, 0x10(%rsp)
movaps -0x30(%rbp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x85eb
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x8746
movl 0x4745(%rip), %esi      # 0xd190
leaq 0x1652(%rip), %rdx      # 0xa0a4
movl $0x20, %edi
movl $0xc5, %ecx
callq 0x7b78
movl 0x472d(%rip), %esi      # 0xd194
leaq 0x164e(%rip), %rdx      # 0xa0bc
movl $0x20, %edi
movl $0xc6, %ecx
callq 0x7b78
movzbl 0x4d54(%rip), %edi      # 0xd7d8
leaq 0x1649(%rip), %rsi      # 0xa0d4
movl $0xc7, %edx
callq 0x7c6c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x1379(%rip), %rsi      # 0x9e26
movq %rbx, %rdi
callq 0x2cb2
movl 0x46d5(%rip), %esi      # 0xd190
leaq 0x162a(%rip), %rdx      # 0xa0ec
movl $0x60, %edi
movl $0xcb, %ecx
callq 0x7b78
movl 0x46bd(%rip), %esi      # 0xd194
leaq 0x1625(%rip), %rdx      # 0xa103
movl $0x60, %edi
movl $0xcc, %ecx
callq 0x7b78
leaq 0x174a(%rip), %rdi      # 0xa23e
callq 0x2080
movl 0x120(%rbx), %esi
leaq 0x1614(%rip), %rdx      # 0xa11a
movl $0x2, %edi
movl $0xd0, %ecx
callq 0x7b78
movl 0x128(%rbx), %esi
leaq 0x1616(%rip), %rdx      # 0xa138
movl $0x3, %edi
movl $0xd2, %ecx
callq 0x7b78
movq %rbx, %rdi
xorl %esi, %esi
callq 0x24de
movq %rbx, %rdi
callq 0x3c33
leaq 0x1609(%rip), %rdx      # 0xa153
xorl %edi, %edi
movl %eax, %esi
movl $0xdf, %ecx
callq 0x7b78
movq %rbx, %rdi
callq 0x8843
movq %rbx, %rdi
callq 0x297a
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x62ac
callq 0x8189
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq