// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movb $0x0, -0x5(%rbp)
movl $0x15, %edi
callq 0xb670
leaq 0x21a8(%rip), %rdi      # 0xe2cc
movb $0x0, %al
callq 0x20e0
leaq 0x506e(%rip), %rax      # 0x111a0
leaq -0xa19(%rip), %rcx      # 0xb720
movq %rcx, (%rax)
leaq 0x5055(%rip), %rax      # 0x11198
leaq -0xa3a(%rip), %rcx      # 0xb710
movq %rcx, (%rax)
leaq 0x218e(%rip), %rdi      # 0xe2e2
callq 0x2840
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x2193(%rip), %rsi      # 0xe2fb
movl $0xb7, %edx
callq 0xb0d0
leaq 0x2198(%rip), %rdi      # 0xe311
movb $0x0, %al
callq 0x20e0
movq -0x10(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq 0x1ee1(%rip), %rdx      # 0xe070
callq 0x2df0
movl $0x3e8, %eax            # imm = 0x3E8
cmpl -0x18(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2186(%rip), %rsi      # 0xe331
movl $0xbd, %edx
callq 0xaf50
movl 0x4fc5(%rip), %esi      # 0x11180
movl $0xff, %edi
leaq 0x2199(%rip), %rdx      # 0xe360
movl $0xbf, %ecx
callq 0xae00
movl 0x4fad(%rip), %esi      # 0x11184
movl $0xff, %edi
leaq 0x2199(%rip), %rdx      # 0xe37c
movl $0xc0, %ecx
callq 0xae00
movb 0x55d5(%rip), %al       # 0x117c8
andb $0x1, %al
movzbl %al, %edi
leaq 0x2199(%rip), %rsi      # 0xe398
movl $0xc1, %edx
callq 0xaff0
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbfd0
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbec0
movl 0x4f25(%rip), %esi      # 0x11180
movl $0x20, %edi
leaq 0x214d(%rip), %rdx      # 0xe3b4
movl $0xc5, %ecx
callq 0xae00
movl 0x4f0d(%rip), %esi      # 0x11184
movl $0x20, %edi
leaq 0x2149(%rip), %rdx      # 0xe3cc
movl $0xc6, %ecx
callq 0xae00
movb 0x5535(%rip), %al       # 0x117c8
andb $0x1, %al
movzbl %al, %edi
leaq 0x2145(%rip), %rsi      # 0xe3e4
movl $0xc7, %edx
callq 0xaf50
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rax
leaq 0x1dc0(%rip), %rsi      # 0xe078
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x2fd0
movl 0x4ea4(%rip), %esi      # 0x11180
movl $0x60, %edi
leaq 0x2114(%rip), %rdx      # 0xe3fc
movl $0xcb, %ecx
callq 0xae00
movl 0x4e8c(%rip), %esi      # 0x11184
movl $0x60, %edi
leaq 0x210f(%rip), %rdx      # 0xe413
movl $0xcc, %ecx
callq 0xae00
leaq 0x2115(%rip), %rdi      # 0xe42a
movb $0x0, %al
callq 0x20e0
movq -0x10(%rbp), %rax
movl 0x120(%rax), %esi
movl $0x2, %edi
leaq 0x210c(%rip), %rdx      # 0xe43e
movl $0xd0, %ecx
callq 0xae00
movq -0x10(%rbp), %rax
movl 0x128(%rax), %esi
movl $0x3, %edi
leaq 0x210a(%rip), %rdx      # 0xe45c
movl $0xd2, %ecx
callq 0xae00
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2470
testb $0x1, -0x5(%rbp)
je 0xc447
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x128(%rcx), %eax
jge 0xc3d8
movl -0x2c(%rbp), %esi
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
leaq 0x20b1(%rip), %rdi      # 0xe477
movb $0x0, %al
callq 0x20e0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc37a
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x120(%rcx), %eax
jge 0xc445
movl -0x30(%rbp), %esi
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x8(%rax), %al
shlb $0x6, %al
sarb $0x7, %al
movsbl %al, %ecx
leaq 0x205a(%rip), %rdi      # 0xe48d
movb $0x0, %al
callq 0x20e0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc3df
jmp 0xc447
movq -0x10(%rbp), %rdi
callq 0x45b0
movl %eax, %esi
xorl %edi, %edi
leaq 0x2045(%rip), %rdx      # 0xe4a0
movl $0xdf, %ecx
callq 0xae00
movq -0x10(%rbp), %rdi
callq 0xc040
movq -0x10(%rbp), %rdi
callq 0x2a90
leaq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x80a0
callq 0xb6a0
addq $0x50, %rsp
popq %rbp
retq