// File: /workspace/github_c_makefile_star2_O2/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 0x60ac
movq %rax, %r15
leaq 0x2469(%rip), %rsi      # 0x9dd6
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x797f
cmpb $0x0, (%r15)
je 0x79d8
leaq 0x2458(%rip), %rsi      # 0x9dde
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x799c
cmpb $0x0, (%r15)
je 0x7a2b
leaq 0x244a(%rip), %rsi      # 0x9ded
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x79b9
cmpb $0x0, (%r15)
je 0x7a76
leaq 0x243f(%rip), %rsi      # 0x9dff
movq %r14, %rdi
callq 0x2190
testl %eax, %eax
jne 0x7ada
xorl %r14d, %r14d
jmp 0x7ac1
leaq 0x23f7(%rip), %rdx      # 0x9dd6
leaq 0x1774(%rip), %r12      # 0x915a
leaq 0x19bf(%rip), %r13      # 0x93ac
xorl %edi, %edi
xorl %esi, %esi
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x617b
movq %rax, %r15
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
leaq 0x23bd(%rip), %rdx      # 0x9dd6
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x617b
jmp 0x7ab6
leaq 0x23ac(%rip), %r15      # 0x9dde
leaq 0x1750(%rip), %r12      # 0x9189
pushq $0x20
popq %r13
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x617b
movq %rax, %rdi
callq 0x21f0
movq %rax, %r14
movl $0x80, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x617b
jmp 0x7ab6
leaq 0x2370(%rip), %r15      # 0x9ded
leaq 0x2379(%rip), %r12      # 0x9dfd
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x617b
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 0x617b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x244c
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 0x265d(%rip), %rdi      # 0xa13e
callq 0x2080
leaq 0x231f(%rip), %rdi      # 0x9e0c
leaq 0x231e(%rip), %rsi      # 0x9e12
leaq 0x2328(%rip), %rcx      # 0x9e23
pushq $0x30
popq %rdx
callq 0x2120