// File: /workspace/github_c_makefile_star2_O0/mruby-zest[P]osc-bridge/src/bridge.c
// Function: br_recv
void br_recv(bridge_t *br, const char *msg)
{
    //char buffer[128];
    //rtosc_message(buffer, 128, "/part0/Pvolume", "i", 74);
    if(!msg)
        return;

    //if(rtosc_narguments(msg) < 3) {
    //    //printf("BR RECEIVE %s:%s\n", msg, rtosc_argument_string(msg));
    //    //printf("MESSAGE IS %d bytes\n", rtosc_message_length(msg, -1));
    //}
    br->last_update = 1e-3*uv_now(br->loop);

    if(!strcmp("/damage", msg) && !strcmp("s", rtosc_argument_string(msg))) {
        const char *dmg = rtosc_argument(msg, 0).s;
        br_damage(br, dmg);
        return;
    }

    const int nargs = rtosc_narguments(msg);
    if(nargs == 1)
        cache_set(br, msg, rtosc_type(msg, 0), rtosc_argument(msg, 0), 0);
    else {
        //Try to handle the vector message cases
        //printf("BRIDGE RECEIVE A VECTOR MESSAGE\n");
        //TODO verify that we've got some sort of uniformity?
        rtosc_arg_itr_t  itr   = rtosc_itr_begin(msg);
        rtosc_arg_t     *args  = (rtosc_arg_t*)calloc(nargs, sizeof(rtosc_arg_t));
        char            *types = strdup(rtosc_argument_string(msg));

        int offset = 0;
        while(!rtosc_itr_end(itr))
            args[offset++] = rtosc_itr_next(&itr).val;

        cache_set_vector(br, msg, types, args);
        free(args);
        free(types);
    }
    //for(int i=0; i<br->callback_len; ++i) {
    //    printf("cb name = %s\n", br->callback[i].path);
    //    bridge_callback_t cb = br->callback[i];
    //    if(!strcmp(cb.path, msg))
    //        cb.cb(msg, cb.data);
    //}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x24af
jmp 0x26bf
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x2170
movq %rax, %xmm0
movaps 0x9b49(%rip), %xmm1     # 0xc010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x9b4d(%rip), %xmm1     # 0xc020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x9b46(%rip), %xmm1     # 0xc030
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
movsd 0x9b33(%rip), %xmm1     # 0xc038
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x130(%rax)
movq -0x10(%rbp), %rsi
leaq 0x9e53(%rip), %rdi      # 0xc37d
callq 0x21a0
cmpl $0x0, %eax
jne 0x257e
movq -0x10(%rbp), %rdi
callq 0x8740
movq %rax, %rsi
leaq 0x9c13(%rip), %rdi      # 0xc15a
callq 0x21a0
cmpl $0x0, %eax
jne 0x257e
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x9e60
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4200
jmp 0x26bf
movq -0x10(%rbp), %rdi
callq 0x87d0
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jne 0x25f9
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x8850
movb %al, -0x81(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x9e60
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq %rax, %rcx
movb -0x81(%rbp), %al
movq %rcx, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
xorl %r9d, %r9d
movsbl %al, %edx
callq 0x36f0
jmp 0x26bf
movq -0x10(%rbp), %rdi
callq 0x9790
movq %rax, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movslq -0x2c(%rbp), %rdi
movl $0x10, %esi
callq 0x2180
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8740
movq %rax, %rdi
callq 0x22a0
movq %rax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x9e20
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2653
jmp 0x2698
movq -0x58(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x98c0
movq -0xa0(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, (%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x2638
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x32f0
movq -0x58(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rdi
callq 0x2030
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)