// File: /workspace/github_c_makefile_star2_O3/mruby-zest[P]osc-bridge/test/mock-test.c
// Function: osc_request_hook_fn
int osc_request_hook_fn(bridge_t *br, const char *msg)
{
    // /schema        - return the schema file
    // /part0/Pvolume - return the volume
    char *buffer = NULL;

    const char *args = rtosc_argument_string(msg);
    //printf("[REQUEST] osc_request_hook_fn(%p,%s,%s)\n", br, msg,args);
    if(!strcmp(msg, "/schema") && !strcmp(args, "")) {
        size_t buf_size = rtosc_message(NULL, 0, "/schema", "s", "");
        buffer = malloc(buf_size);
        rtosc_message(buffer, buf_size, "/schema", "s", "");
        br_recv(br, buffer);
    } else if(!strcmp(msg, "/part0/Pvolume") && !strcmp(args, "")) {
        size_t buf_size = rtosc_message(NULL, 0, "/part0/Pvolume", "i", 32);
        buffer = malloc(buf_size);
        rtosc_message(buffer, 128, "/part0/Pvolume", "i", 32);
        br_recv(br, buffer);
    } else if(!strcmp(msg, "/part0/Penabled") && !strcmp(args, "")) {
        size_t buf_size = rtosc_message(NULL, 0, "/part0/Penabled", "T");
        buffer = malloc(buf_size);
        rtosc_message(buffer, buf_size, "/part0/Penabled", "T");
        br_recv(br, buffer);
    } else if(!strcmp(msg, "/vector/test")) {
        //do nothing
    } else {
        printf("[ERROR] unexpected message...\n");
        assert(false);
        return 0;
    }

    //TODO send the message

    free(buffer);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x6658
movq %rax, %r15
leaq 0x1c1b(%rip), %rsi      # 0x9e1e
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x8215
cmpb $0x0, (%r15)
je 0x826e
leaq 0x1c0a(%rip), %rsi      # 0x9e26
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x8232
cmpb $0x0, (%r15)
je 0x82c1
leaq 0x1bfc(%rip), %rsi      # 0x9e35
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x824f
cmpb $0x0, (%r15)
je 0x830e
leaq 0x1bf1(%rip), %rsi      # 0x9e47
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x8372
xorl %r14d, %r14d
jmp 0x8359
leaq 0x1ba9(%rip), %rdx      # 0x9e1e
leaq 0xede(%rip), %r12       # 0x915a
leaq 0x1129(%rip), %r13      # 0x93ac
xorl %edi, %edi
xorl %esi, %esi
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x6730
movq %rax, %r15
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
leaq 0x1b6f(%rip), %rdx      # 0x9e1e
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x6730
jmp 0x834e
leaq 0x1b5e(%rip), %r15      # 0x9e26
leaq 0xeba(%rip), %r12       # 0x9189
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x20, %r8d
xorl %eax, %eax
callq 0x6730
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movl $0x80, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x20, %r8d
xorl %eax, %eax
callq 0x6730
jmp 0x834e
leaq 0x1b20(%rip), %r15      # 0x9e35
leaq 0x1b29(%rip), %r12      # 0x9e45
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6730
movq %rax, %r13
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6730
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24de
movq %r14, %rdi
callq 0x2030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e0d(%rip), %rdi      # 0xa186
callq 0x2080
leaq 0x1acf(%rip), %rdi      # 0x9e54
leaq 0x1ace(%rip), %rsi      # 0x9e5a
leaq 0x1ad8(%rip), %rcx      # 0x9e6b
movl $0x30, %edx
callq 0x2120