// File: jgeumlek[P]moltengamepadctl/source/main.cpp
// Function: handle_message(oscpkt::Message*, oscpkt::Message::ArgReader*, int)
int handle_message(oscpkt::Message* msg, oscpkt::Message::ArgReader* arg, int id) {
  if (msg->match("/text")) {
    std::string text;
    arg->popStr(text);
    std::cout << text << std::endl;
  } else if (msg->match("/error")) {
    std::string text, path;
    int line;
    arg->popStr(text);
    arg->popStr(path);
    arg->popInt32(line);
    std::cerr << text;
    if (!path.empty()) {
      std::cerr << "(" << path;
      if (line >= 0) {
        std::cerr << ":" << line;
      }
      std::cerr << ")";
    }
    std::cerr << std::endl;
  } else {
    //a generic catch-all to print something to the user.
    std::cout << msg->addressPattern() << ": ";
    while (arg->nbArgRemaining() > 0) {
      if (arg->isInt32()) {
        int i;
        arg->popInt32(i);
        std::cout << i << " ";
      } else if (arg->isStr()) {
        std::string s;
        arg->popStr(s);
        std::cout << "\"" << s << "\" ";
      }
    }
    std::cout << std::endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x3480
movq -0x138(%rbp), %rdx
leaq 0xa176(%rip), %rsi      # 0xe175
leaq -0x50(%rbp), %rdi
callq 0x3370
jmp 0x400a
movq -0x140(%rbp), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x5ec0
jmp 0x4020
leaq -0x30(%rbp), %rdi
callq 0x6030
movb %al, -0x141(%rbp)
jmp 0x4031
leaq -0x50(%rbp), %rdi
callq 0x31b0
leaq -0x51(%rbp), %rdi
callq 0x32e0
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x4052
jmp 0x4107
leaq -0x88(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3380
movq -0x150(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x6310
jmp 0x4077
movq 0x10f4a(%rip), %rdi     # 0x14fc8
leaq -0x88(%rbp), %rsi
callq 0x3270
movq %rax, -0x158(%rbp)
jmp 0x4093
movq -0x158(%rbp), %rdi
movq 0x10f07(%rip), %rsi     # 0x14fa8
callq 0x32d0
jmp 0x40a8
leaq -0x88(%rbp), %rdi
callq 0x31b0
jmp 0x4476
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x40dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31b0
leaq -0x51(%rbp), %rdi
callq 0x32e0
jmp 0x4478
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31b0
jmp 0x4478
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3480
movq -0x160(%rbp), %rdx
leaq 0xa048(%rip), %rsi      # 0xe17b
leaq -0xc0(%rbp), %rdi
callq 0x3370
jmp 0x4141
movq -0x168(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x5ec0
jmp 0x415d
leaq -0xa0(%rbp), %rdi
callq 0x6030
movb %al, -0x169(%rbp)
jmp 0x4171
leaq -0xc0(%rbp), %rdi
callq 0x31b0
leaq -0xc1(%rbp), %rdi
callq 0x32e0
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x4198
jmp 0x432f
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x3380
leaq -0x108(%rbp), %rdi
callq 0x3380
movq -0x178(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x6310
jmp 0x41c9
movq -0x10(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x6310
jmp 0x41db
movq -0x10(%rbp), %rdi
leaq -0x10c(%rbp), %rsi
callq 0x5e90
jmp 0x41ed
movq 0x10dfc(%rip), %rdi     # 0x14ff0
leaq -0xe8(%rbp), %rsi
callq 0x3270
jmp 0x4202
leaq -0x108(%rbp), %rdi
callq 0x3430
testb $0x1, %al
jne 0x42fd
movq 0x10dd3(%rip), %rdi     # 0x14ff0
leaq 0x9f5e(%rip), %rsi      # 0xe182
callq 0x32a0
movq %rax, -0x180(%rbp)
jmp 0x4232
movq -0x180(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3270
jmp 0x4247
cmpl $0x0, -0x10c(%rbp)
jl 0x42e6
movq 0x10d95(%rip), %rdi     # 0x14ff0
leaq 0x9f22(%rip), %rsi      # 0xe184
callq 0x32a0
movq %rax, -0x188(%rbp)
jmp 0x4270
movq -0x188(%rbp), %rdi
movl -0x10c(%rbp), %esi
callq 0x3450
jmp 0x4284
jmp 0x42e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x42ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31b0
leaq -0xc1(%rbp), %rdi
callq 0x32e0
jmp 0x4478
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x31b0
leaq -0xe8(%rbp), %rdi
callq 0x31b0
jmp 0x4478
movq 0x10d03(%rip), %rdi     # 0x14ff0
leaq 0xa0ec(%rip), %rsi      # 0xe3e0
callq 0x32a0
jmp 0x42fb
jmp 0x42fd
movq 0x10cec(%rip), %rdi     # 0x14ff0
movq 0x10c9d(%rip), %rsi     # 0x14fa8
callq 0x32d0
jmp 0x4312
leaq -0x108(%rbp), %rdi
callq 0x31b0
leaq -0xe8(%rbp), %rdi
callq 0x31b0
jmp 0x4474
movq -0x8(%rbp), %rdi
callq 0x6370
movq %rax, %rsi
movq 0x10c86(%rip), %rdi     # 0x14fc8
callq 0x3270
movq %rax, %rdi
leaq 0x9e19(%rip), %rsi      # 0xe16a
callq 0x32a0
movq -0x10(%rbp), %rdi
callq 0x6390
cmpq $0x0, %rax
jbe 0x4461
movq -0x10(%rbp), %rdi
callq 0x5e60
testb $0x1, %al
jne 0x4378
jmp 0x43ae
movq -0x10(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x5e90
movl -0x110(%rbp), %esi
movq 0x10c33(%rip), %rdi     # 0x14fc8
callq 0x3450
movq %rax, %rdi
leaq 0x9de5(%rip), %rsi      # 0xe189
callq 0x32a0
jmp 0x445c
movq -0x10(%rbp), %rdi
callq 0x63c0
testb $0x1, %al
jne 0x43c0
jmp 0x445a
leaq -0x130(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3380
movq -0x190(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x6310
jmp 0x43e5
movq 0x10bdc(%rip), %rdi     # 0x14fc8
leaq 0x9d93(%rip), %rsi      # 0xe186
callq 0x32a0
movq %rax, -0x198(%rbp)
jmp 0x4401
movq -0x198(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3270
movq %rax, -0x1a0(%rbp)
jmp 0x441d
movq -0x1a0(%rbp), %rdi
leaq 0x9d5d(%rip), %rsi      # 0xe188
callq 0x32a0
jmp 0x4432
leaq -0x130(%rbp), %rdi
callq 0x31b0
jmp 0x445a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x31b0
jmp 0x4478
jmp 0x445c
jmp 0x4356
movq 0x10b60(%rip), %rdi     # 0x14fc8
movq 0x10b39(%rip), %rsi     # 0x14fa8
callq 0x32d0
jmp 0x4476
ud2
movq -0x60(%rbp), %rdi
callq 0x3470
nopw %cs:(%rax,%rax)