// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8720
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x2920(%rip), %rsi      # 0xe070
callq 0x2190
cmpl $0x0, %eax
jne 0xb7d9
movq -0x20(%rbp), %rdi
leaq 0x1d8d(%rip), %rsi      # 0xd4f2
callq 0x2190
cmpl $0x0, %eax
jne 0xb7d9
xorl %eax, %eax
movl %eax, %esi
leaq 0x28f6(%rip), %rdx      # 0xe070
leaq 0x19d9(%rip), %rcx      # 0xd15a
leaq 0x1d6a(%rip), %r8       # 0xd4f2
movq %rsi, %rdi
movb $0x0, %al
callq 0x88e0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x21f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0x28be(%rip), %rdx      # 0xe070
leaq 0x19a1(%rip), %rcx      # 0xd15a
leaq 0x1d32(%rip), %r8       # 0xd4f2
movb $0x0, %al
callq 0x88e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2470
jmp 0xb939
movq -0x10(%rbp), %rdi
leaq 0x2894(%rip), %rsi      # 0xe078
callq 0x2190
cmpl $0x0, %eax
jne 0xb86c
movq -0x20(%rbp), %rdi
leaq 0x1cf9(%rip), %rsi      # 0xd4f2
callq 0x2190
cmpl $0x0, %eax
jne 0xb86c
xorl %eax, %eax
movl %eax, %esi
leaq 0x286a(%rip), %rdx      # 0xe078
leaq 0x1c83(%rip), %rcx      # 0xd498
movl $0x20, %r8d
movq %rsi, %rdi
movb $0x0, %al
callq 0x88e0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x21f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl $0x80, %esi
leaq 0x2832(%rip), %rdx      # 0xe078
leaq 0x1c4b(%rip), %rcx      # 0xd498
movl $0x20, %r8d
movb $0x0, %al
callq 0x88e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2470
jmp 0xb937
movq -0x10(%rbp), %rdi
leaq 0x2810(%rip), %rsi      # 0xe087
callq 0x2190
cmpl $0x0, %eax
jne 0xb8ef
movq -0x20(%rbp), %rdi
leaq 0x1c66(%rip), %rsi      # 0xd4f2
callq 0x2190
cmpl $0x0, %eax
jne 0xb8ef
xorl %eax, %eax
movl %eax, %esi
leaq 0x27e6(%rip), %rdx      # 0xe087
leaq 0x27ef(%rip), %rcx      # 0xe097
movq %rsi, %rdi
movb $0x0, %al
callq 0x88e0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x21f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x27b5(%rip), %rdx      # 0xe087
leaq 0x27be(%rip), %rcx      # 0xe097
movb $0x0, %al
callq 0x88e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2470
jmp 0xb935
movq -0x10(%rbp), %rdi
leaq 0x279f(%rip), %rsi      # 0xe099
callq 0x2190
cmpl $0x0, %eax
jne 0xb906
jmp 0xb933
leaq 0x2799(%rip), %rdi      # 0xe0a6
movb $0x0, %al
callq 0x20e0
leaq 0x27aa(%rip), %rdi      # 0xe0c5
leaq 0x27a9(%rip), %rsi      # 0xe0cb
movl $0x30, %edx
leaq 0x27ae(%rip), %rcx      # 0xe0dc
callq 0x2110
jmp 0xb935
jmp 0xb937
jmp 0xb939
movq -0x18(%rbp), %rdi
callq 0x2030
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)