// File: Themaister[P]umusd/command.cpp
// Function: Command::init_command_map()
void Command::init_command_map()
{
   command_map["NOOP"] = [](EventHandler &, std::vector<std::string> arg) -> std::string {
      std::cerr << "NOOP begin" << std::endl;
      std::cerr << string_join(arg, "\n") << std::endl << "end" << std::endl;
      return "OK";
   };

   command_map["PLAY"] = [this](EventHandler &, std::vector<std::string> arg) -> std::string {
      if (arg.empty())
         arg.push_back("");

      try
      {
         remote->play(arg.front());
         arg.erase(arg.begin());
         for (auto &str : arg)
            remote->add(str);
         return "OK";
      }
      catch(const std::exception &e)
      {
         std::cerr << e.what() << std::endl;
         return "ERROR";
      }
   };

   command_map["QUEUE"] = [this](EventHandler &, std::vector<std::string> arg) -> std::string {
      if (arg.empty())
         arg.push_back("");

      try
      {
         for (auto &str : arg)
         remote->add(str);
         return "OK";
      }
      catch(const std::exception &e)
      {
         std::cerr << e.what() << std::endl;
         return "ERROR";
      }
   };

   command_map["NEXT"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return plain_action(std::bind(&Remote::next, remote));
   };

   command_map["PREV"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return plain_action(std::bind(&Remote::prev, remote));
   };

   command_map["STOP"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return plain_action(std::bind(&Remote::stop, remote));
   };

   command_map["PAUSE"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return plain_action(std::bind(&Remote::pause, remote));
   };

   command_map["UNPAUSE"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return plain_action(std::bind(&Remote::unpause, remote));
   };

   command_map["SEEK"] = [this](EventHandler &, std::vector<std::string> arg) -> std::string {
      if (arg.empty())
         throw std::logic_error("SEEK requires argument.");

      int time = std::strtol(arg[0].c_str(), nullptr, 0);
      return plain_action(std::bind(&Remote::seek, remote, time));
   };

   command_map["POS"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      try
      {
         auto pos = remote->pos();
         return stringify(static_cast<int>(pos.first), " ", static_cast<int>(pos.second));
      }
      catch (const std::exception &e)
      {
         std::cerr << e.what() << std::endl;
         return "ERROR";
      }
   };

   command_map["DIE"] = [this](EventHandler &event, std::vector<std::string>) -> std::string {
      event.kill();
      return "OK";
   };

   command_map["TITLE"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return metadata_action(*remote, [](const FF::MediaInfo &info) { return info.title; });
   };

   command_map["ARTIST"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return metadata_action(*remote, [](const FF::MediaInfo &info) { return info.artist; });
   };

   command_map["ALBUM"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return metadata_action(*remote, [](const FF::MediaInfo &info) { return info.album; });
   };

   command_map["STATUS"] = [this](EventHandler &, std::vector<std::string>) -> std::string {
      return remote->status();
   };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x300(%rbp)
addq $0x20, %rax
movq %rax, -0x2f8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x5370
movq -0x2f0(%rbp), %rdx
leaq 0x1d04d(%rip), %rsi     # 0x26530
leaq -0x30(%rbp), %rdi
callq 0x67d0
jmp 0x94ee
movq -0x2f8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x10450
movq %rax, -0x308(%rbp)
jmp 0x9507
movq -0x308(%rbp), %rdi
leaq -0x9(%rbp), %rsi
callq 0xa390
leaq -0x30(%rbp), %rdi
callq 0x5670
leaq -0x31(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x50(%rbp)
addq $0x20, %rax
movq %rax, -0x318(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x5370
movq -0x310(%rbp), %rdx
leaq 0x1cfd8(%rip), %rsi     # 0x26535
leaq -0x70(%rbp), %rdi
callq 0x67d0
jmp 0x9568
movq -0x318(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x10450
movq %rax, -0x320(%rbp)
jmp 0x9581
movq -0x320(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa3e0
leaq -0x70(%rbp), %rdi
callq 0x5670
leaq -0x71(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x80(%rbp)
addq $0x20, %rax
movq %rax, -0x330(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x5370
movq -0x328(%rbp), %rdx
leaq 0x1cf60(%rip), %rsi     # 0x2653a
leaq -0xa0(%rbp), %rdi
callq 0x67d0
jmp 0x95e8
movq -0x330(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x10450
movq %rax, -0x338(%rbp)
jmp 0x9604
movq -0x338(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xa430
leaq -0xa0(%rbp), %rdi
callq 0x5670
leaq -0xa1(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0xb0(%rbp)
addq $0x20, %rax
movq %rax, -0x348(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x5370
movq -0x340(%rbp), %rdx
leaq 0x1ceda(%rip), %rsi     # 0x26540
leaq -0xd0(%rbp), %rdi
callq 0x67d0
jmp 0x9674
movq -0x348(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x10450
movq %rax, -0x350(%rbp)
jmp 0x9690
movq -0x350(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xa480
leaq -0xd0(%rbp), %rdi
callq 0x5670
leaq -0xd1(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0xe0(%rbp)
addq $0x20, %rax
movq %rax, -0x360(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x5370
movq -0x358(%rbp), %rdx
leaq 0x1ce50(%rip), %rsi     # 0x26545
leaq -0x100(%rbp), %rdi
callq 0x67d0
jmp 0x9703
movq -0x360(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x10450
movq %rax, -0x368(%rbp)
jmp 0x971f
movq -0x368(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xa4d0
leaq -0x100(%rbp), %rdi
callq 0x5670
leaq -0x101(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x110(%rbp)
addq $0x20, %rax
movq %rax, -0x378(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x5370
movq -0x370(%rbp), %rdx
leaq 0x1cdc6(%rip), %rsi     # 0x2654a
leaq -0x130(%rbp), %rdi
callq 0x67d0
jmp 0x9792
movq -0x378(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x10450
movq %rax, -0x380(%rbp)
jmp 0x97ae
movq -0x380(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xa520
leaq -0x130(%rbp), %rdi
callq 0x5670
leaq -0x131(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x140(%rbp)
addq $0x20, %rax
movq %rax, -0x390(%rbp)
leaq -0x161(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x5370
movq -0x388(%rbp), %rdx
leaq 0x1cd3e(%rip), %rsi     # 0x26551
leaq -0x160(%rbp), %rdi
callq 0x67d0
jmp 0x9821
movq -0x390(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x10450
movq %rax, -0x398(%rbp)
jmp 0x983d
movq -0x398(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xa570
leaq -0x160(%rbp), %rdi
callq 0x5670
leaq -0x161(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x170(%rbp)
addq $0x20, %rax
movq %rax, -0x3a8(%rbp)
leaq -0x191(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x5370
movq -0x3a0(%rbp), %rdx
leaq 0x1ccad(%rip), %rsi     # 0x2654f
leaq -0x190(%rbp), %rdi
callq 0x67d0
jmp 0x98b0
movq -0x3a8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x10450
movq %rax, -0x3b0(%rbp)
jmp 0x98cc
movq -0x3b0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xa5c0
leaq -0x190(%rbp), %rdi
callq 0x5670
leaq -0x191(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x1a0(%rbp)
addq $0x20, %rax
movq %rax, -0x3c0(%rbp)
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x5370
movq -0x3b8(%rbp), %rdx
leaq 0x1cc26(%rip), %rsi     # 0x26557
leaq -0x1c0(%rbp), %rdi
callq 0x67d0
jmp 0x993f
movq -0x3c0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x10450
movq %rax, -0x3c8(%rbp)
jmp 0x995b
movq -0x3c8(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0xa610
leaq -0x1c0(%rbp), %rdi
callq 0x5670
leaq -0x1c1(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x1d0(%rbp)
addq $0x20, %rax
movq %rax, -0x3d8(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x5370
movq -0x3d0(%rbp), %rdx
leaq 0x1cb9c(%rip), %rsi     # 0x2655c
leaq -0x1f0(%rbp), %rdi
callq 0x67d0
jmp 0x99ce
movq -0x3d8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x10450
movq %rax, -0x3e0(%rbp)
jmp 0x99ea
movq -0x3e0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0xa660
leaq -0x1f0(%rbp), %rdi
callq 0x5670
leaq -0x1f1(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x200(%rbp)
addq $0x20, %rax
movq %rax, -0x3f0(%rbp)
leaq -0x221(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x5370
movq -0x3e8(%rbp), %rdx
leaq 0x1cb11(%rip), %rsi     # 0x26560
leaq -0x220(%rbp), %rdi
callq 0x67d0
jmp 0x9a5d
movq -0x3f0(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x10450
movq %rax, -0x3f8(%rbp)
jmp 0x9a79
movq -0x3f8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0xa6b0
leaq -0x220(%rbp), %rdi
callq 0x5670
leaq -0x221(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x230(%rbp)
addq $0x20, %rax
movq %rax, -0x408(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x5370
movq -0x400(%rbp), %rdx
leaq 0x1ca86(%rip), %rsi     # 0x26564
leaq -0x250(%rbp), %rdi
callq 0x67d0
jmp 0x9aec
movq -0x408(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x10450
movq %rax, -0x410(%rbp)
jmp 0x9b08
movq -0x410(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xa700
leaq -0x250(%rbp), %rdi
callq 0x5670
leaq -0x251(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x260(%rbp)
addq $0x20, %rax
movq %rax, -0x420(%rbp)
leaq -0x281(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x5370
movq -0x418(%rbp), %rdx
leaq 0x1c9fd(%rip), %rsi     # 0x2656a
leaq -0x280(%rbp), %rdi
callq 0x67d0
jmp 0x9b7b
movq -0x420(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x10450
movq %rax, -0x428(%rbp)
jmp 0x9b97
movq -0x428(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0xa750
leaq -0x280(%rbp), %rdi
callq 0x5670
leaq -0x281(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x290(%rbp)
addq $0x20, %rax
movq %rax, -0x438(%rbp)
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x430(%rbp)
callq 0x5370
movq -0x430(%rbp), %rdx
leaq 0x1c975(%rip), %rsi     # 0x26571
leaq -0x2b0(%rbp), %rdi
callq 0x67d0
jmp 0x9c0a
movq -0x438(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x10450
movq %rax, -0x440(%rbp)
jmp 0x9c26
movq -0x440(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0xa7a0
leaq -0x2b0(%rbp), %rdi
callq 0x5670
leaq -0x2b1(%rbp), %rdi
callq 0x5040
movq -0x300(%rbp), %rax
movq %rax, -0x2c0(%rbp)
addq $0x20, %rax
movq %rax, -0x450(%rbp)
leaq -0x2e1(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x5370
movq -0x448(%rbp), %rdx
leaq 0x1c8ec(%rip), %rsi     # 0x26577
leaq -0x2e0(%rbp), %rdi
callq 0x67d0
jmp 0x9c99
movq -0x450(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x10450
movq %rax, -0x458(%rbp)
jmp 0x9cb5
movq -0x458(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xa7f0
leaq -0x2e0(%rbp), %rdi
callq 0x5670
leaq -0x2e1(%rbp), %rdi
callq 0x5040
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9d0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5670
leaq -0x31(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5670
leaq -0x71(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9d71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5670
leaq -0xa1(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9da8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5670
leaq -0xd1(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9ddf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5670
leaq -0x101(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9e16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x5670
leaq -0x131(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9e4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x5670
leaq -0x161(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9e84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x5670
leaq -0x191(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9ebb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x5670
leaq -0x1c1(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9ef2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5670
leaq -0x1f1(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9f29
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x5670
leaq -0x221(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9f60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x5670
leaq -0x251(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9f97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x5670
leaq -0x281(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9fcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x5670
leaq -0x2b1(%rbp), %rdi
callq 0x5040
jmp 0xa00b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9fff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x5670
leaq -0x2e1(%rbp), %rdi
callq 0x5040
movq -0x40(%rbp), %rdi
callq 0x52a0
nopw %cs:(%rax,%rax)