// File: Thomas1995[P]Rentz/src/client.cpp
// Function: Client::Client(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> const&)
Client(const std::unordered_map<std::string, std::string> &opts) {

    srand (time(NULL));

    const std::string name = opts.count("name") ? opts.at("name") : random_name();

    if(name == "TH")  bot = std::unique_ptr<Bot>(new Bot_Thomas);
    if(name == "ER")  bot = std::unique_ptr<Bot>(new Bot_Eric);
    if(name == "BC")  bot = std::unique_ptr<Bot>(new Bot_Bicsi);
    if(name == "EU")  bot = std::unique_ptr<Bot>(new Bot_Eugen);
    if(name == "RD")  bot = std::unique_ptr<Bot>(new Bot_Random);

    require(bot != nullptr, "Name not available. Choose from: EU | TH | ER | BC | RD\n");

    addrinfo hints, *rez;

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;

    const std::string address = opts.count("address") ? opts.at("address") : "127.0.0.1";

    getaddrinfo(address.c_str(), PORT, &hints, &rez);

    for(addrinfo *p = rez; p != NULL; p = p->ai_next) {
      sfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);

      if(sfd == -1)
        continue;

      if(connect(sfd, p->ai_addr, p->ai_addrlen) != -1) {
        printf("Connected to %s\n", address.c_str());
        break;
      }

      close(sfd);
    }

    fcntl(sfd, F_SETFL, O_NONBLOCK);

    freeaddrinfo(rez);

    handshake(const_cast<char *>(name.c_str()));

    while(true) {
      event e = readEvent();
      event resp;
      resp.type = e.type;
      resp.len = 0;
      resp.data = NULL;

      switch(e.type) {
        case event::EType::SEND_CARDS: {
        //the server is sending us what cards were played
        //and are on the table

        //debug("Receiving cards on table...\n");
          std::vector<Card> cards(e.getCards());
          bot->ReceiveCardsOnTable(cards);
          resp.send(sfd);
          break;
      }

      case event::EType::SEND_HAND: {
      //the server is sending us our hand

            debug("Receiving hand: ");
            std::vector<Card> hand(e.getCards());
            for(auto &x: hand)
              debug("%s ", x.to_string().c_str());
            debug("\n");

            bot->ReceiveHand(hand);
            resp.send(sfd);
            break;
        }

        case event::EType::TURN_END: {
        //the server is telling us that turn has ended

          debug("Turn has ended.\n");
          bot->TurnEnd();
          resp.send(sfd);

          break;
        }

        case event::EType::ROUND_END: {
        //the server is sending us the scores so far

            debug("Round ended.\n Scores: ");

            std::vector<int> scores;
            scores.reserve(e.len / 4);

            for(uint32_t i = 0; i < e.len; i += 4)
              scores.push_back(e.getInt(e.data + i));

            for(auto i: scores)
              debug(" %d", i);
            debug("\n\n");

            bot->RoundEnd(scores);
            resp.send(sfd);
            break;
        }

        case event::EType::ASK_GAME: {
        //the server is asking us for a minigame to choose

            debug("Being asked for minigame...\n");
            uint8_t ans = bot->ChooseMinigame();
            debug("I chose: %s\n", GameName[ans].c_str());
            resp.len = 1;
            resp.data = &ans;
            resp.send(sfd);
            break;
        }

        case event::EType::ROUND_START: {
        //the server is sending us the chosen game type

            debug("Round is starting...\n");
            const uint8_t choice = e.data[0];
            bot->RoundStart(choice);
            resp.send(sfd);
            break;
        }

        case event::EType::ASK_CARD: {
        //the server is asking us for a card to play

            debug("Being asked for card...\n");
            Card c = bot->PlayCard();
            debug("I chose: %s\n", c.to_string().c_str());
            resp.len = 1;
            uint8_t code = c.encode();
            resp.data = &code;
            resp.send(sfd);
            break;
        }

        case event::EType::ASK_NV: {
        //the server is asking us if we want NV
          
            debug("Being asked for NV...\n");
            bool ans = bot->AskIfNV();

            if(ans) debug("Chose NV\n");
            else debug("Did not choose NV\n");

            resp.len = 1;
            resp.data = reinterpret_cast<uint8_t *>(&ans);
            resp.send(sfd);
            break;
        }

        case event::EType::GAME_END: {
        //the server is telling us that game has ended

          debug("The game has ended.\n\n");
          resp.send(sfd);
          goto end;
        }
      }
      e.free();

      std::this_thread::sleep_for(std::chrono::milliseconds(5));
    } // end while

  end:

    return;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0xcb00
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
movq %rdi, -0x318(%rbp)
callq 0x11590
xorl %eax, %eax
movl %eax, %edi
callq 0x32b0
movl %eax, %edi
callq 0x32d0
movq -0x10(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x34a0
movq -0x308(%rbp), %rdx
movb $0x0, -0x8a(%rbp)
movb $0x0, -0x8b(%rbp)
leaq 0xea82(%rip), %rsi      # 0x1e4b6
leaq -0x50(%rbp), %rdi
callq 0x5400
jmp 0xfa3f
movq -0x310(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x115c0
movq %rax, -0x328(%rbp)
jmp 0xfa58
movq -0x328(%rbp), %rax
cmpq $0x0, %rax
je 0xfadd
movq -0x10(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x34a0
movq -0x330(%rbp), %rdx
movb $0x1, -0x8a(%rbp)
leaq 0xea1e(%rip), %rsi      # 0x1e4b6
leaq -0x88(%rbp), %rdi
callq 0x5400
jmp 0xfaa6
movq -0x338(%rbp), %rdi
movb $0x1, -0x8b(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x115f0
movq %rax, -0x340(%rbp)
jmp 0xfac9
movq -0x340(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x3140
jmp 0xfadb
jmp 0xfaf1
movq -0x320(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x11620
jmp 0xfaef
jmp 0xfaf1
testb $0x1, -0x8b(%rbp)
jne 0xfafc
jmp 0xfb08
leaq -0x88(%rbp), %rdi
callq 0x31c0
testb $0x1, -0x8a(%rbp)
jne 0xfb13
jmp 0xfb1f
leaq -0x89(%rbp), %rdi
callq 0x3330
leaq -0x50(%rbp), %rdi
callq 0x31c0
leaq -0x51(%rbp), %rdi
callq 0x3330
leaq 0xe910(%rip), %rsi      # 0x1e448
leaq -0x30(%rbp), %rdi
callq 0x11690
movb %al, -0x341(%rbp)
jmp 0xfb49
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0xfb58
jmp 0xfc69
movl $0xe8, %edi
callq 0x32f0
movq %rax, -0x350(%rbp)
jmp 0xfb6b
movq -0x350(%rbp), %rdi
callq 0x116c0
jmp 0xfb79
movq -0x350(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x11860
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
leaq -0x98(%rbp), %rsi
callq 0x11890
leaq -0x98(%rbp), %rdi
callq 0x118c0
jmp 0xfc69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xfc28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xfc1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xfc06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
testb $0x1, -0x8b(%rbp)
jne 0xfbf8
jmp 0xfc04
leaq -0x88(%rbp), %rdi
callq 0x31c0
jmp 0xfc06
testb $0x1, -0x8a(%rbp)
jne 0xfc11
jmp 0xfc1d
leaq -0x89(%rbp), %rdi
callq 0x3330
jmp 0xfc1f
leaq -0x50(%rbp), %rdi
callq 0x31c0
leaq -0x51(%rbp), %rdi
callq 0x3330
jmp 0x10dcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10dc2
movq -0x350(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xe8, %esi
callq 0x3300
jmp 0x10dc2
leaq 0xe7db(%rip), %rsi      # 0x1e44b
leaq -0x30(%rbp), %rdi
callq 0x11690
movb %al, -0x351(%rbp)
jmp 0xfc81
movb -0x351(%rbp), %al
testb $0x1, %al
jne 0xfc8d
jmp 0xfd0b
movl $0xb8, %edi
callq 0x32f0
movq %rax, -0x360(%rbp)
jmp 0xfca0
movq -0x360(%rbp), %rdi
callq 0x11910
jmp 0xfcae
movq -0x360(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x11860
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
leaq -0xa0(%rbp), %rsi
callq 0x11890
leaq -0xa0(%rbp), %rdi
callq 0x118c0
jmp 0xfd0b
movq -0x360(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xb8, %esi
callq 0x3300
jmp 0x10dc2
leaq 0xe73c(%rip), %rsi      # 0x1e44e
leaq -0x30(%rbp), %rdi
callq 0x11690
movb %al, -0x361(%rbp)
jmp 0xfd23
movb -0x361(%rbp), %al
testb $0x1, %al
jne 0xfd2f
jmp 0xfdad
movl $0xe8, %edi
callq 0x32f0
movq %rax, -0x370(%rbp)
jmp 0xfd42
movq -0x370(%rbp), %rdi
callq 0x11a70
jmp 0xfd50
movq -0x370(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x11860
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
leaq -0xa8(%rbp), %rsi
callq 0x11890
leaq -0xa8(%rbp), %rdi
callq 0x118c0
jmp 0xfdad
movq -0x370(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xe8, %esi
callq 0x3300
jmp 0x10dc2
leaq 0xe733(%rip), %rsi      # 0x1e4e7
leaq -0x30(%rbp), %rdi
callq 0x11690
movb %al, -0x371(%rbp)
jmp 0xfdc5
movb -0x371(%rbp), %al
testb $0x1, %al
jne 0xfdd1
jmp 0xfe4f
movl $0xc8, %edi
callq 0x32f0
movq %rax, -0x380(%rbp)
jmp 0xfde4
movq -0x380(%rbp), %rdi
callq 0x11d20
jmp 0xfdf2
movq -0x380(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x11860
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
leaq -0xb0(%rbp), %rsi
callq 0x11890
leaq -0xb0(%rbp), %rdi
callq 0x118c0
jmp 0xfe4f
movq -0x380(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xc8, %esi
callq 0x3300
jmp 0x10dc2
leaq 0xe5fb(%rip), %rsi      # 0x1e451
leaq -0x30(%rbp), %rdi
callq 0x11690
movb %al, -0x381(%rbp)
jmp 0xfe67
movb -0x381(%rbp), %al
testb $0x1, %al
jne 0xfe73
jmp 0xfef1
movl $0x98, %edi
callq 0x32f0
movq %rax, -0x390(%rbp)
jmp 0xfe86
movq -0x390(%rbp), %rdi
callq 0x11e10
jmp 0xfe94
movq -0x390(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x11860
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
leaq -0xb8(%rbp), %rsi
callq 0x11890
leaq -0xb8(%rbp), %rdi
callq 0x118c0
jmp 0xfef1
movq -0x390(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x98, %esi
callq 0x3300
jmp 0x10dc2
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
xorl %eax, %eax
movl %eax, %esi
callq 0x11ec0
movb %al, -0x399(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x34a0
movq -0x398(%rbp), %rdx
leaq 0xe5bb(%rip), %rsi      # 0x1e4ea
leaq -0xd8(%rbp), %rdi
callq 0x5400
jmp 0xff3d
movb -0x399(%rbp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq -0xd8(%rbp), %rsi
callq 0xca70
jmp 0xff57
leaq -0xd8(%rbp), %rdi
callq 0x31c0
leaq -0xd9(%rbp), %rdi
callq 0x3330
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps %xmm0, -0x110(%rbp)
movl $0x0, -0x10c(%rbp)
movl $0x1, -0x108(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3b0(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x34a0
movq -0x3a8(%rbp), %rdx
movb $0x0, -0x182(%rbp)
movb $0x0, -0x183(%rbp)
movb $0x0, -0x185(%rbp)
leaq 0xe4c0(%rip), %rsi      # 0x1e49c
leaq -0x158(%rbp), %rdi
callq 0x5400
jmp 0xffea
movq -0x3b0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x115c0
movq %rax, -0x3b8(%rbp)
jmp 0x10006
movq -0x3b8(%rbp), %rax
cmpq $0x0, %rax
je 0x1008e
movq -0x10(%rbp), %rax
movq %rax, -0x3c8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x34a0
movq -0x3c0(%rbp), %rdx
movb $0x1, -0x182(%rbp)
leaq 0xe456(%rip), %rsi      # 0x1e49c
leaq -0x180(%rbp), %rdi
callq 0x5400
jmp 0x10054
movq -0x3c8(%rbp), %rdi
movb $0x1, -0x183(%rbp)
leaq -0x180(%rbp), %rsi
callq 0x115f0
movq %rax, -0x3d0(%rbp)
jmp 0x10077
movq -0x3d0(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x3140
jmp 0x1008c
jmp 0x100c6
leaq -0x184(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x34a0
movq -0x3d8(%rbp), %rdx
movb $0x1, -0x185(%rbp)
leaq 0xe46d(%rip), %rsi      # 0x1e523
leaq -0x138(%rbp), %rdi
callq 0x5400
jmp 0x100c4
jmp 0x100c6
testb $0x1, -0x185(%rbp)
jne 0x100d1
jmp 0x100dd
leaq -0x184(%rbp), %rdi
callq 0x3330
testb $0x1, -0x183(%rbp)
jne 0x100e8
jmp 0x100f4
leaq -0x180(%rbp), %rdi
callq 0x31c0
testb $0x1, -0x182(%rbp)
jne 0x100ff
jmp 0x1010b
leaq -0x181(%rbp), %rdi
callq 0x3330
leaq -0x158(%rbp), %rdi
callq 0x31c0
leaq -0x159(%rbp), %rdi
callq 0x3330
leaq -0x138(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
leaq 0xe693(%rip), %rsi      # 0x1e7cc
leaq -0x110(%rbp), %rdx
leaq -0x118(%rbp), %rcx
callq 0x33a0
jmp 0x1014e
movq -0x118(%rbp), %rax
movq %rax, -0x190(%rbp)
cmpq $0x0, -0x190(%rbp)
je 0x10326
movq -0x190(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x190(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x190(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x30a0
movl %eax, %ecx
movq -0x320(%rbp), %rax
movl %ecx, 0x201c(%rax)
cmpl $-0x1, 0x201c(%rax)
jne 0x102a5
jmp 0x1030f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x101d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x31c0
leaq -0xd9(%rbp), %rdi
callq 0x3330
jmp 0x10dc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10283
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10277
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1025e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10245
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
testb $0x1, -0x185(%rbp)
jne 0x10237
jmp 0x10243
leaq -0x184(%rbp), %rdi
callq 0x3330
jmp 0x10245
testb $0x1, -0x183(%rbp)
jne 0x10250
jmp 0x1025c
leaq -0x180(%rbp), %rdi
callq 0x31c0
jmp 0x1025e
testb $0x1, -0x182(%rbp)
jne 0x10269
jmp 0x10275
leaq -0x181(%rbp), %rdi
callq 0x3330
jmp 0x10277
leaq -0x158(%rbp), %rdi
callq 0x31c0
leaq -0x159(%rbp), %rdi
callq 0x3330
jmp 0x10dc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10db6
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %edi
movq -0x190(%rbp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
callq 0x3270
movl %eax, -0x3dc(%rbp)
jmp 0x102cd
movl -0x3dc(%rbp), %eax
cmpl $-0x1, %eax
je 0x102f9
leaq -0x138(%rbp), %rdi
callq 0x3130
movq %rax, %rsi
leaq 0xe23f(%rip), %rdi      # 0x1e52d
xorl %eax, %eax
callq 0x3060
jmp 0x102f7
jmp 0x10326
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %edi
callq 0x34d0
jmp 0x1030d
jmp 0x1030f
movq -0x190(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x190(%rbp)
jmp 0x1015c
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %edi
xorl %eax, %eax
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x31a0
jmp 0x10346
movq -0x118(%rbp), %rdi
callq 0x33e0
leaq -0x30(%rbp), %rdi
callq 0x3130
movq -0x320(%rbp), %rdi
movq %rax, %rsi
callq 0x11ef0
jmp 0x1036c
jmp 0x1036e
jmp 0x10370
movq -0x320(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0xcf00
jmp 0x10385
movl -0x1a8(%rbp), %eax
movl %eax, -0x1c0(%rbp)
movq $0x0, -0x1b8(%rbp)
movq $0x0, -0x1b0(%rbp)
movl -0x1a8(%rbp), %eax
movq %rax, -0x3e8(%rbp)
subq $0xa, %rax
ja 0x10d58
movq -0x3e8(%rbp), %rax
leaq 0xe004(%rip), %rcx      # 0x1e3d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x1d8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x12080
jmp 0x103ea
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, -0x3f0(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x6140
jmp 0x10419
movq -0x3f0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x4fb0
jmp 0x1042e
leaq -0x1f0(%rbp), %rdi
callq 0x63a0
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10455
leaq -0x1d8(%rbp), %rdi
callq 0x63a0
jmp 0x10d58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1048c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x63a0
leaq -0x1d8(%rbp), %rdi
callq 0x63a0
jmp 0x10db6
movq 0x1bb2c(%rip), %rax     # 0x2bfd0
movq %rax, -0x3f8(%rbp)
movq (%rax), %rdi
leaq 0xe089(%rip), %rsi      # 0x1e53e
xorl %eax, %eax
callq 0x3410
movq -0x3f8(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x104cd
leaq -0x208(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x12080
jmp 0x104e2
leaq -0x208(%rbp), %rax
movq %rax, -0x210(%rbp)
movq -0x210(%rbp), %rdi
callq 0x5b00
movq %rax, -0x218(%rbp)
movq -0x210(%rbp), %rdi
callq 0x5b30
movq %rax, -0x220(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x5b60
testb $0x1, %al
jne 0x10532
jmp 0x105d7
leaq -0x218(%rbp), %rdi
callq 0x5ba0
movq %rax, -0x228(%rbp)
movq 0x1ba84(%rip), %rax     # 0x2bfd0
movq (%rax), %rax
movq %rax, -0x400(%rbp)
movq -0x228(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0xb9e0
jmp 0x1056b
leaq -0x248(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x3130
movq -0x400(%rbp), %rdi
movq %rax, %rdx
leaq 0xdb55(%rip), %rsi      # 0x1e0e4
xorl %eax, %eax
callq 0x3410
movq -0x408(%rbp), %rdi
callq 0x31c0
movq 0x1ba27(%rip), %rax     # 0x2bfd0
movq (%rax), %rdi
callq 0x3370
jmp 0x105b3
jmp 0x105b5
leaq -0x218(%rbp), %rdi
callq 0x5bc0
jmp 0x10516
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1069b
movq 0x1b9f2(%rip), %rax     # 0x2bfd0
movq %rax, -0x410(%rbp)
movq (%rax), %rdi
leaq 0xdb1e(%rip), %rsi      # 0x1e10d
xorl %eax, %eax
callq 0x3410
movq -0x410(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10607
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, -0x418(%rbp)
leaq -0x260(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x6140
jmp 0x10636
movq -0x418(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x4b00
jmp 0x1064b
leaq -0x260(%rbp), %rdi
callq 0x63a0
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10672
leaq -0x208(%rbp), %rdi
callq 0x63a0
jmp 0x10d58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x63a0
leaq -0x208(%rbp), %rdi
callq 0x63a0
jmp 0x10db6
movq 0x1b91d(%rip), %rax     # 0x2bfd0
movq %rax, -0x420(%rbp)
movq (%rax), %rdi
leaq 0xde8b(%rip), %rsi      # 0x1e54f
xorl %eax, %eax
callq 0x3410
movq -0x420(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x106dc
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, %rdi
callq 0x5110
jmp 0x106f9
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10714
jmp 0x10d58
movq 0x1b8b0(%rip), %rax     # 0x2bfd0
movq %rax, -0x428(%rbp)
movq (%rax), %rdi
leaq 0xde2f(%rip), %rsi      # 0x1e560
xorl %eax, %eax
callq 0x3410
movq -0x428(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10749
leaq -0x278(%rbp), %rdi
movq %rdi, -0x430(%rbp)
callq 0xcf70
movq -0x430(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
shrq $0x2, %rsi
callq 0x124a0
jmp 0x10775
movl $0x0, -0x27c(%rbp)
movl -0x27c(%rbp), %eax
cmpq -0x1a0(%rbp), %rax
jae 0x107f7
movq -0x198(%rbp), %rsi
movl -0x27c(%rbp), %eax
addq %rax, %rsi
leaq -0x1a8(%rbp), %rdi
callq 0xd440
movl %eax, -0x434(%rbp)
jmp 0x107b2
movl -0x434(%rbp), %eax
movl %eax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x125a0
jmp 0x107d3
jmp 0x107d5
movl -0x27c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x27c(%rbp)
jmp 0x1077f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x10962
leaq -0x278(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
callq 0x5940
movq %rax, -0x290(%rbp)
movq -0x288(%rbp), %rdi
callq 0x5970
movq %rax, -0x298(%rbp)
leaq -0x290(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x59a0
testb $0x1, %al
jne 0x10844
jmp 0x1089e
leaq -0x290(%rbp), %rdi
callq 0x59e0
movl (%rax), %eax
movl %eax, -0x29c(%rbp)
movq 0x1b771(%rip), %rax     # 0x2bfd0
movq %rax, -0x440(%rbp)
movq (%rax), %rdi
movl -0x29c(%rbp), %edx
leaq 0xdd01(%rip), %rsi      # 0x1e577
xorl %eax, %eax
callq 0x3410
movq -0x440(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x1088e
jmp 0x10890
leaq -0x290(%rbp), %rdi
callq 0x5a00
jmp 0x1082b
movq 0x1b72b(%rip), %rax     # 0x2bfd0
movq %rax, -0x448(%rbp)
movq (%rax), %rdi
leaq 0xd856(%rip), %rsi      # 0x1e10c
xorl %eax, %eax
callq 0x3410
movq -0x448(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x108ce
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, -0x450(%rbp)
leaq -0x2b8(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x6050
jmp 0x108fd
movq -0x450(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x5130
jmp 0x10912
leaq -0x2b8(%rbp), %rdi
callq 0x6460
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10939
leaq -0x278(%rbp), %rdi
callq 0x6460
jmp 0x10d58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x6460
leaq -0x278(%rbp), %rdi
callq 0x6460
jmp 0x10db6
movq 0x1b656(%rip), %rax     # 0x2bfd0
movq %rax, -0x458(%rbp)
movq (%rax), %rdi
leaq 0xdbf0(%rip), %rsi      # 0x1e57b
xorl %eax, %eax
callq 0x3410
movq -0x458(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x109a3
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, %rdi
callq 0x4fe0
movl %eax, -0x45c(%rbp)
jmp 0x109c6
movl -0x45c(%rbp), %eax
movb %al, -0x2b9(%rbp)
movq 0x1b5f7(%rip), %rax     # 0x2bfd0
movq %rax, -0x468(%rbp)
movq (%rax), %rax
movq %rax, -0x470(%rbp)
movzbl -0x2b9(%rbp), %eax
movl %eax, %esi
leaq 0x1b8fe(%rip), %rdi     # 0x2c2f8
callq 0x125d0
movq %rax, %rdi
callq 0x3130
movq -0x470(%rbp), %rdi
movq %rax, %rdx
leaq 0xdb80(%rip), %rsi      # 0x1e598
xorl %eax, %eax
callq 0x3410
movq -0x468(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10a30
movq -0x320(%rbp), %rax
movq $0x1, -0x1b8(%rbp)
leaq -0x2b9(%rbp), %rcx
movq %rcx, -0x1b0(%rbp)
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10a64
jmp 0x10d58
movq 0x1b560(%rip), %rax     # 0x2bfd0
movq %rax, -0x478(%rbp)
movq (%rax), %rdi
leaq 0xdb24(%rip), %rsi      # 0x1e5a5
xorl %eax, %eax
callq 0x3410
movq -0x478(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10a99
movq -0x320(%rbp), %rdi
movq -0x198(%rbp), %rax
movb (%rax), %al
movb %al, -0x2ba(%rbp)
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, %rdi
movzbl -0x2ba(%rbp), %esi
callq 0x50d0
jmp 0x10acc
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10ae7
jmp 0x10d58
movq 0x1b4dd(%rip), %rax     # 0x2bfd0
movq %rax, -0x480(%rbp)
movq (%rax), %rdi
leaq 0xdab7(%rip), %rsi      # 0x1e5bb
xorl %eax, %eax
callq 0x3410
movq -0x480(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10b1c
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, %rsi
leaq -0x2c4(%rbp), %rdi
callq 0x5190
jmp 0x10b40
movq 0x1b489(%rip), %rax     # 0x2bfd0
movq (%rax), %rax
movq %rax, -0x488(%rbp)
leaq -0x2e8(%rbp), %rdi
leaq -0x2c4(%rbp), %rsi
callq 0xb9e0
jmp 0x10b66
leaq -0x2e8(%rbp), %rdi
movq %rdi, -0x490(%rbp)
callq 0x3130
movq -0x488(%rbp), %rdi
movq %rax, %rdx
leaq 0xda0e(%rip), %rsi      # 0x1e598
xorl %eax, %eax
callq 0x3410
movq -0x490(%rbp), %rdi
callq 0x31c0
movq 0x1b42c(%rip), %rax     # 0x2bfd0
movq (%rax), %rdi
callq 0x3370
jmp 0x10bae
movq $0x1, -0x1b8(%rbp)
leaq -0x2c4(%rbp), %rdi
callq 0xbd30
movb %al, -0x491(%rbp)
jmp 0x10bcd
movq -0x320(%rbp), %rax
movb -0x491(%rbp), %cl
movb %cl, -0x2e9(%rbp)
leaq -0x2e9(%rbp), %rcx
movq %rcx, -0x1b0(%rbp)
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10c02
jmp 0x10d58
movq 0x1b3c2(%rip), %rax     # 0x2bfd0
movq %rax, -0x4a0(%rbp)
movq (%rax), %rdi
leaq 0xd9b5(%rip), %rsi      # 0x1e5d4
xorl %eax, %eax
callq 0x3410
movq -0x4a0(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10c37
movq -0x320(%rbp), %rdi
addq $0x2028, %rdi           # imm = 0x2028
callq 0x12130
movq %rax, %rdi
callq 0x50b0
movb %al, -0x4a1(%rbp)
jmp 0x10c5a
movb -0x4a1(%rbp), %al
andb $0x1, %al
movb %al, -0x2ea(%rbp)
testb $0x1, -0x2ea(%rbp)
je 0x10ca3
movq 0x1b358(%rip), %rax     # 0x2bfd0
movq %rax, -0x4b0(%rbp)
movq (%rax), %rdi
leaq 0xd962(%rip), %rsi      # 0x1e5eb
xorl %eax, %eax
callq 0x3410
movq -0x4b0(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10ca1
jmp 0x10cd5
movq 0x1b326(%rip), %rax     # 0x2bfd0
movq %rax, -0x4b8(%rbp)
movq (%rax), %rdi
leaq 0xd93a(%rip), %rsi      # 0x1e5f5
xorl %eax, %eax
callq 0x3410
movq -0x4b8(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10cd3
jmp 0x10cd5
movq -0x320(%rbp), %rax
movq $0x1, -0x1b8(%rbp)
leaq -0x2ea(%rbp), %rcx
movq %rcx, -0x1b0(%rbp)
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10d09
jmp 0x10d58
movq 0x1b2be(%rip), %rax     # 0x2bfd0
movq %rax, -0x4c0(%rbp)
movq (%rax), %rdi
leaq 0xd8e5(%rip), %rsi      # 0x1e608
xorl %eax, %eax
callq 0x3410
movq -0x4c0(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
jmp 0x10d3b
movq -0x320(%rbp), %rax
movl 0x201c(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x12150
jmp 0x10d56
jmp 0x10d98
leaq -0x1a8(%rbp), %rdi
callq 0x125f0
jmp 0x10d66
movl $0x5, -0x2fc(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x2fc(%rbp), %rsi
callq 0x126d0
jmp 0x10d85
leaq -0x2f8(%rbp), %rdi
callq 0x12620
jmp 0x10d93
jmp 0x1036e
leaq -0x138(%rbp), %rdi
callq 0x31c0
leaq -0x30(%rbp), %rdi
callq 0x31c0
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
leaq -0x138(%rbp), %rdi
callq 0x31c0
leaq -0x30(%rbp), %rdi
callq 0x31c0
movq -0x318(%rbp), %rdi
callq 0x118c0
movq -0x320(%rbp), %rdi
callq 0x126f0
movq -0x60(%rbp), %rdi
callq 0x3490
nopl (%rax)