// File: /workspace/github_c_makefile_star2_O1/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 0x13f1(%rip), %rdi      # 0x9de3
movl $0x15, %esi
xorl %eax, %eax
callq 0x20f0
leaq 0x1805(%rip), %rdi      # 0xa20a
callq 0x2080
leaq -0x73e(%rip), %rax      # 0x82d3
leaq 0x4798(%rip), %rcx      # 0xd1b0
movq %rax, (%rcx)
leaq -0x757(%rip), %rax      # 0x82cb
leaq 0x477f(%rip), %rcx      # 0xd1a8
movq %rax, (%rcx)
leaq 0x15bf(%rip), %rdi      # 0x9ff2
callq 0x27e4
movq %rax, %rbx
leaq 0x15c9(%rip), %rsi      # 0xa00b
movq %rax, %rdi
movl $0xb7, %edx
callq 0x7e2b
leaq 0x17c9(%rip), %rdi      # 0xa21f
callq 0x2080
leaq 0x13bc(%rip), %rdx      # 0x9e1e
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2b6a
xorl %edi, %edi
cmpl $0x3e9, 0x10(%r14)      # imm = 0x3E9
setge %dil
leaq 0x159b(%rip), %rsi      # 0xa021
movl $0xbd, %edx
callq 0x7d28
movl 0x46fa(%rip), %esi      # 0xd190
leaq 0x15b3(%rip), %rdx      # 0xa050
movl $0xff, %edi
movl $0xbf, %ecx
callq 0x7c34
movl 0x46e2(%rip), %esi      # 0xd194
leaq 0x15b3(%rip), %rdx      # 0xa06c
movl $0xff, %edi
movl $0xc0, %ecx
callq 0x7c34
movzbl 0x4d09(%rip), %edi      # 0xd7d8
xorl $0x1, %edi
leaq 0x15af(%rip), %rsi      # 0xa088
movl $0xc1, %edx
callq 0x7d28
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 0x854f
movq -0x20(%rbp), %rax
movq %rax, 0x10(%rsp)
movaps -0x30(%rbp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x86e1
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x883c
movl 0x464f(%rip), %esi      # 0xd190
leaq 0x155c(%rip), %rdx      # 0xa0a4
movl $0x20, %edi
movl $0xc5, %ecx
callq 0x7c34
movl 0x4637(%rip), %esi      # 0xd194
leaq 0x1558(%rip), %rdx      # 0xa0bc
movl $0x20, %edi
movl $0xc6, %ecx
callq 0x7c34
movzbl 0x4c5e(%rip), %edi      # 0xd7d8
leaq 0x1553(%rip), %rsi      # 0xa0d4
movl $0xc7, %edx
callq 0x7d28
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x1283(%rip), %rsi      # 0x9e26
movq %rbx, %rdi
callq 0x2cb7
movl 0x45df(%rip), %esi      # 0xd190
leaq 0x1534(%rip), %rdx      # 0xa0ec
movl $0x60, %edi
movl $0xcb, %ecx
callq 0x7c34
movl 0x45c7(%rip), %esi      # 0xd194
leaq 0x152f(%rip), %rdx      # 0xa103
movl $0x60, %edi
movl $0xcc, %ecx
callq 0x7c34
leaq 0x1654(%rip), %rdi      # 0xa23e
callq 0x2080
movl 0x120(%rbx), %esi
leaq 0x151e(%rip), %rdx      # 0xa11a
movl $0x2, %edi
movl $0xd0, %ecx
callq 0x7c34
movl 0x128(%rbx), %esi
leaq 0x1520(%rip), %rdx      # 0xa138
movl $0x3, %edi
movl $0xd2, %ecx
callq 0x7c34
movq %rbx, %rdi
xorl %esi, %esi
callq 0x24de
movq %rbx, %rdi
callq 0x3c61
leaq 0x1513(%rip), %rdx      # 0xa153
xorl %edi, %edi
movl %eax, %esi
movl $0xdf, %ecx
callq 0x7c34
movq %rbx, %rdi
callq 0x8939
movq %rbx, %rdi
callq 0x2974
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x6364
callq 0x827f
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq