// File: /workspace/github_cpp_makefile_star2_O2/rohitrangan[P]3PC/src/termination.cpp
// Function: termination_protocol(int, int, Socket&, bool, std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int>>>&, std::set<int, std::less<int>, std::allocator<int>>&, std::map<int, transaction_info, std::less<int>, std::allocator<std::pair<int const, transaction_info>>>&)
bool termination_protocol (int site_id, int failed_site, Socket& site, bool b,
        map<int, int>& sites, set<int>& txLive,
        map<int, transaction_info>& trans_table)
{
    int new_coordinator = (failed_site != 0) ? 0 : 1;
    bool flag = false;
    int numAcks = 0;
    cout << "Site " << site_id << " entered termination protocol" << endl;

    if (b)
    {
        Message start_term (TERMINATION, 0, site_id, failed_site);
        string msg_start_term = start_term.createMessage ();
        for (int i = 0; i < sites.size (); ++i)
        {
            Socket tmp;
            if (i != site_id && i != failed_site)
            {
                tmp.connect ("localhost", sites[i]);
                tmp.send (msg_start_term);
                cout << "Site " << site_id
                    << " sent TERMINATION to Site " << i << endl;
            }
        }
        while (1)
        {
            Socket inc = site.accept ();
            string str;
            str = inc.recv ((size_t) 1024);
            //cout << "Received str:- " << str << endl;
            Message msg (str);
            string tempStr, snd_msg;
            switch (msg.message)
            {
                case TERMINATION:
                {
                    cout << "Site " << site_id << " received TERMINATION from "
                        "Site " << msg.site_id << endl;
                    failed_site = msg.failed_id;
                    Message tempMsg(ACK, msg.transaction_id, site_id);
                    tempStr = tempMsg.createMessage();
                    Socket temp;
                    temp.connect ("localhost", sites[msg.site_id]);
                    temp.send (tempStr);
                    cout << "Site " << site_id << " sent ACK to Site " <<
                        msg.site_id << endl;
                    break;
                }
                case ACK:
                {
                    cout << "Site " << site_id << " got ACK from Site " <<
                        msg.site_id << endl;
                    ++numAcks;
                    if (numAcks == (sites.size () - 2))
                    {
                        flag = true;
                    }
                    break;
                }
                default:
                    break;
            }
            if (flag)
                break;
        }
    }

    for (set<int>::iterator it = txLive.begin (); it != txLive.end (); )
    {
        int t_chkid = *it;
        /* Handling the case for transactions being its own and if it is the new
         * coordinator.
         */
        if ((trans_table[t_chkid].coordinator == site_id) ||
                ((trans_table[t_chkid].coordinator == failed_site) &&
                 (new_coordinator == site_id)))
        {
            switch (trans_table[t_chkid].site_st)
            {
                case S_INIT:

                case S_READY:

                case S_WAIT:
                {
                    cout << "[" << t_chkid << "]Site " << site_id <<
                        " is aborting transaction in TERMINATION" << endl;
                    Message snd_msg_all (ABORT, t_chkid, site_id);
                    string tmp_msg = snd_msg_all.createMessage ();
                    for (int i = 0; i < sites.size (); ++i)
                    {
                        Socket tmp;
                        if (i != site_id && i != failed_site)
                        {
                            tmp.connect ("localhost", sites[i]);
                            tmp.send (tmp_msg);
                            cout << "[" << t_chkid << "]Site " << site_id
                                << " sent ABORT to Site " << i << endl;
                        }
                    }
                    trans_table[t_chkid].site_st = S_ABORT;
                    cout << "[" << t_chkid << "]Site " << site_id
                        << " ABORTED in TERMINATION" << "\n\n\n";
                    it = txLive.erase (it);
                    break;
                }
                case S_PRE_COMMIT:
                {
                    cout << "[" << t_chkid << "]Site " << site_id <<
                        " is going to commit transaction in TERMINATION"
                        << endl;
                    Message snd_msg_all (COMMIT, t_chkid, site_id);
                    string tmp_msg = snd_msg_all.createMessage ();
                    for (int i = 0; i < sites.size (); ++i)
                    {
                        Socket tmp;
                        if (i != site_id && i != failed_site)
                        {
                            tmp.connect ("localhost", sites[i]);
                            tmp.send (tmp_msg);
                            cout << "[" << t_chkid << "]Site " << site_id
                                << " sent COMMIT to Site " << i <<
                                " in TERMINATION" << endl;
                        }
                    }
                    trans_table[t_chkid].site_st = S_COMMIT;
                    cout << "[" << t_chkid << "]Site " << site_id
                        << " COMMITTED in TERMINATION" << "\n\n\n";
                    it = txLive.erase (it);
                    break;
                }
                case S_ABORT:
                {
                    cout << "[" << t_chkid << "]Site " << site_id <<
                        " is aborting transaction in TERMINATION" << endl;
                    Message snd_msg_all (ABORT, t_chkid, site_id);
                    string tmp_msg = snd_msg_all.createMessage ();
                    for (int i = 0; i < sites.size (); ++i)
                    {
                        Socket tmp;
                        if (i != site_id && i != failed_site)
                        {
                            tmp.connect ("localhost", sites[i]);
                            tmp.send (tmp_msg);
                            cout << "[" << t_chkid << "]Site " << site_id
                                << " sent ABORT to Site " << i << 
                                " in TERMINATION" << endl;
                        }
                    }
                    trans_table[t_chkid].site_st = S_ABORT;
                    cout << "[" << t_chkid << "]Site " << site_id
                        << " ABORTED in TERMINATION" << "\n\n\n";
                    it = txLive.erase (it);
                    break;
                }
                default:
                    cout << "State is:- " << trans_table[t_chkid].site_st << endl;
                    ++it;
                    break;
            }
        }
        else
            ++it;
    }

    if (txLive.empty ())
        return false;

    flag = false;
    while (1)
    {
        Socket inc = site.accept ();
		string str;
        str = inc.recv ((size_t) 1024);
		Message msg (str);
        string tempStr, snd_msg;
		switch (msg.message)
		{
			case COMMIT:
            {
                cout << "[" << msg.transaction_id << "]Site " << site_id <<
                    " received COMMIT from Site " << msg.site_id <<
                    " in TERMINATION" << endl;
                trans_table[msg.transaction_id].site_st = S_COMMIT;
                cout << "[" << msg.transaction_id << "]Site " << site_id
                    << " COMMITTED in TERMINATION" << "\n\n\n";
                txLive.erase (msg.transaction_id);
                if (txLive.empty ())
                    flag = true;
				break;
            }
			case ABORT:
            {
                cout << "[" << msg.transaction_id << "]Site " << site_id <<
                    " received ABORT from Site " << msg.site_id <<
                    " in TERMINATION" << endl;
                trans_table[msg.transaction_id].site_st = S_ABORT;
                cout << "[" << msg.transaction_id << "]Site " << site_id
                    << " ABORTED in TERMINATION" << "\n\n\n";
                txLive.erase (msg.transaction_id);
                if (txLive.empty ())
                    flag = true;
				break;
            }
            default:
                break;
		}
        if (flag)
            break;
    }

	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %r9, 0x20(%rsp)
movq %r8, 0x10(%rsp)
movl %ecx, %ebx
movq %rdx, 0x108(%rsp)
movl %esi, %r13d
movl %edi, %ebp
movl $0x0, 0x48(%rsp)
testl %esi, %esi
sete 0xa0(%rsp)
movq 0x60b5(%rip), %rdi      # 0xbfc8
leaq 0x2337(%rip), %rsi      # 0x8251
callq 0x2240
movq %rax, %rdi
movl %ebp, %esi
callq 0x23a0
leaq 0x24c8(%rip), %rsi      # 0x83f8
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x2110
testl %ebx, %ebx
movl %ebp, 0x8(%rsp)
je 0x63c4
leaq 0x70(%rsp), %rbx
pushq $0x8
popq %rsi
movl %r13d, %r12d
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %edx, %edx
movl %ebp, %ecx
movl %r12d, 0xc(%rsp)
movl %r12d, %r8d
callq 0x5a4c
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b4c
leaq 0xa8(%rsp), %rbx
leaq 0x215f(%rip), %r15      # 0x80e9
leaq 0x2d8(%rsp), %r12
leaq 0x50(%rsp), %rbp
leaq 0x2b8(%rsp), %r14
movl %r13d, 0xd8(%rsp)
movslq %r13d, %rax
movq 0x10(%rsp), %rcx
cmpq %rax, 0x28(%rcx)
jbe 0x6090
movq %rbx, %rdi
callq 0x550c
movl 0xd8(%rsp), %eax
cmpl 0x8(%rsp), %eax
sete %cl
cmpl 0xc(%rsp), %eax
sete %al
orb %cl, %al
jne 0x6078
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x474a
movq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x47d4
movl (%rax), %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x551a
movq %r12, %rdi
callq 0x2100
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5650
movq %r14, %rdi
callq 0x2100
movq 0x5f8e(%rip), %rdi      # 0xbfc8
leaq 0x2210(%rip), %rsi      # 0x8251
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x23ba(%rip), %rsi      # 0x8416
callq 0x2240
movl 0xd8(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x58c2
movl 0xd8(%rsp), %r13d
incl %r13d
jmp 0x5f9f
movl $0x0, 0x18(%rsp)
leaq 0x130(%rsp), %rbx
leaq 0xa8(%rsp), %r12
leaq 0x298(%rsp), %r13
movq %rbx, %rdi
movq 0x108(%rsp), %rsi
callq 0x5778
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movl $0x400, %edx            # imm = 0x400
movq %r12, %rdi
movq %rbx, %rsi
callq 0x566e
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x22e0
movq %r12, %rdi
callq 0x2100
movq %r12, %rbp
movq %r13, %r12
movq %r13, %rdi
movq %r14, %rsi
callq 0x2340
movq %rbp, %r15
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5a6a
movq %r12, %rdi
callq 0x2100
leaq 0x120(%rsp), %rax
movq %rax, 0x110(%rsp)
andq $0x0, 0x118(%rsp)
xorl %r14d, %r14d
leaq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
andq $0x0, 0x140(%rsp)
movb %r14b, 0x120(%rsp)
movb %r14b, 0x148(%rsp)
movl 0xa8(%rsp), %eax
cmpl $0x7, %eax
je 0x62fe
cmpl $0x8, %eax
movq %r15, %r12
jne 0x6366
movq 0x5e3c(%rip), %rdi      # 0xbfc8
leaq 0x20be(%rip), %rsi      # 0x8251
callq 0x2240
movl 0x8(%rsp), %ebp
movq %rax, %rdi
movl %ebp, %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x2281(%rip), %rsi      # 0x8431
callq 0x2240
movl 0xb0(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movl 0xac(%rsp), %edx
movl 0xb4(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
pushq $0x7
popq %rsi
movl %ebp, %ecx
callq 0x5a2e
leaq 0x278(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5b4c
leaq 0x110(%rsp), %rdi
movq %r15, %rsi
callq 0x22e0
movq %r15, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x550c
movq %r15, %r14
leaq 0x218(%rsp), %rdi
leaq 0x1eb1(%rip), %rsi      # 0x80e9
leaq 0x4f(%rsp), %rdx
callq 0x474a
movq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x47d4
leaq 0x218(%rsp), %r15
movl (%rax), %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x551a
movq %r15, %rdi
callq 0x2100
leaq 0x1f8(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x2340
movq %r14, %rdi
leaq 0x1f8(%rsp), %r15
movq %r15, %rsi
callq 0x5650
movq %r15, %rdi
callq 0x2100
movq 0x5d20(%rip), %rdi      # 0xbfc8
leaq 0x1fa2(%rip), %rsi      # 0x8251
callq 0x2240
movq %rax, %rdi
movl %ebp, %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x2003(%rip), %rsi      # 0x82cb
callq 0x2240
movl 0xb0(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x58c2
leaq 0xe8(%rsp), %rdi
callq 0x2100
xorl %r14d, %r14d
jmp 0x6366
movq 0x5cc3(%rip), %rdi      # 0xbfc8
leaq 0x1f45(%rip), %rsi      # 0x8251
callq 0x2240
movl 0x8(%rsp), %esi
movq %r15, %r12
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1ecc(%rip), %rsi      # 0x81f6
callq 0x2240
movl 0xb0(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movl 0x18(%rsp), %eax
incl %eax
movl %eax, 0x18(%rsp)
cltq
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rcx
addq $-0x2, %rcx
cmpq %rax, %rcx
sete %r14b
leaq 0x138(%rsp), %rdi
callq 0x2100
leaq 0x110(%rsp), %rdi
callq 0x2100
leaq 0xb8(%rsp), %rdi
callq 0x2100
leaq 0x50(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x58c2
testb %r14b, %r14b
je 0x60b0
leaq 0x28(%rsp), %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
movl 0xc(%rsp), %r13d
movl 0x48(%rsp), %eax
movb 0xa0(%rsp), %cl
movb %cl, %al
movl %eax, 0x48(%rsp)
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rcx
addq $0x8, %rax
movq %rax, 0xa0(%rsp)
leaq 0x28(%rsp), %rbx
leaq 0xd8(%rsp), %r14
movl %r13d, 0xc(%rsp)
movl 0x8(%rsp), %ebp
cmpq 0xa0(%rsp), %rcx
je 0x6b59
movq 0x5bb3(%rip), %r12      # 0xbfc8
movq %rcx, 0x18(%rsp)
movl 0x20(%rcx), %eax
movl %eax, 0x28(%rsp)
movq 0x330(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4822
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x8(%rax)
je 0x6463
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4822
movl 0x8(%rsp), %ecx
cmpl %ecx, 0x48(%rsp)
jne 0x6a17
movl 0xc(%rsp), %ecx
cmpl %ecx, 0x8(%rax)
jne 0x6a17
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4822
movl 0x4(%rax), %eax
cmpl $0x3, %eax
jae 0x660e
movq %r12, %rdi
leaq 0x1c97(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1c7e(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1f96(%rip), %rsi      # 0x8452
callq 0x2240
movq %rax, %rdi
callq 0x2110
movl 0x28(%rsp), %edx
leaq 0x70(%rsp), %r12
movq %r12, %rdi
pushq $0x6
popq %rsi
movl %ebx, %ecx
callq 0x5a2e
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x5b4c
xorl %eax, %eax
movl 0xc(%rsp), %ebx
movl %eax, 0x50(%rsp)
cltq
movq 0x10(%rsp), %rcx
cmpq %rax, 0x28(%rcx)
jbe 0x67d2
movq %r14, %rdi
callq 0x550c
movl 0x50(%rsp), %eax
cmpl 0x8(%rsp), %eax
je 0x65fb
cmpl %ebx, %eax
je 0x65fb
leaq 0x1d8(%rsp), %rdi
leaq 0x1baf(%rip), %rsi      # 0x80e9
leaq 0x110(%rsp), %rdx
callq 0x474a
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x47d4
leaq 0x1d8(%rsp), %r12
movl (%rax), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x551a
movq %r12, %rdi
callq 0x2100
leaq 0x1b8(%rsp), %rdi
movq %r13, %rsi
callq 0x2340
movq %r14, %rdi
leaq 0x1b8(%rsp), %r12
movq %r12, %rsi
callq 0x5650
movq %r12, %rdi
callq 0x2100
movq 0x5a23(%rip), %rdi      # 0xbfc8
leaq 0x1b6f(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1b56(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1bf2(%rip), %rsi      # 0x81d4
callq 0x2240
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x58c2
movl 0x50(%rsp), %eax
incl %eax
jmp 0x64f8
leaq 0xa8(%rsp), %r15
leaq 0x258(%rsp), %rbx
movq 0x59a3(%rip), %rdi      # 0xbfc8
je 0x6857
cmpl $0x5, %eax
jne 0x69e0
leaq 0x1ae0(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1ac7(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1ddf(%rip), %rsi      # 0x8452
callq 0x2240
movq %rax, %rdi
callq 0x2110
movl 0x28(%rsp), %edx
leaq 0x70(%rsp), %r13
movq %r13, %rdi
pushq $0x6
popq %rsi
movl %ebx, %ecx
callq 0x5a2e
movq %r15, %rdi
movq %r13, %rsi
callq 0x5b4c
xorl %eax, %eax
leaq 0xa8(%rsp), %r13
movl %eax, 0x50(%rsp)
cltq
movq 0x10(%rsp), %rcx
cmpq %rax, 0x28(%rcx)
jbe 0x6ab4
movq %r14, %rdi
callq 0x550c
movl 0x50(%rsp), %eax
cmpl 0x8(%rsp), %eax
je 0x67bf
cmpl 0xc(%rsp), %eax
je 0x67bf
leaq 0x178(%rsp), %rdi
leaq 0x19fa(%rip), %rsi      # 0x80e9
leaq 0x110(%rsp), %rdx
callq 0x474a
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x47d4
leaq 0x178(%rsp), %rbx
movl (%rax), %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x551a
movq %rbx, %rdi
callq 0x2100
leaq 0x158(%rsp), %rdi
movq %r13, %rsi
callq 0x2340
movq %r14, %rdi
leaq 0x158(%rsp), %rbx
movq %rbx, %rsi
callq 0x5650
movq %rbx, %rdi
callq 0x2100
movq 0x586e(%rip), %rdi      # 0xbfc8
leaq 0x19ba(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x19a1(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1a3d(%rip), %rsi      # 0x81d4
callq 0x2240
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1cd0(%rip), %rsi      # 0x8482
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x58c2
movl 0x50(%rsp), %eax
incl %eax
jmp 0x66ab
movq 0x330(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4822
movl $0x5, 0x4(%rax)
movq 0x57d6(%rip), %rdi      # 0xbfc8
leaq 0x1922(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1909(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1c4b(%rip), %rsi      # 0x847a
callq 0x2240
movq %rax, %rdi
leaq 0x19b4(%rip), %rsi      # 0x81f2
callq 0x2240
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x709e
jmp 0x6b34
leaq 0x18bd(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x18a4(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl %ebp, %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1c00(%rip), %rsi      # 0x8492
callq 0x2240
movq %rax, %rdi
callq 0x2110
movl 0x28(%rsp), %edx
leaq 0x70(%rsp), %r12
movq %r12, %rdi
pushq $0x5
popq %rsi
movl %ebp, %ecx
callq 0x5a2e
movq %r15, %rdi
movq %r12, %rsi
callq 0x5b4c
movl 0xc(%rsp), %r13d
xorl %eax, %eax
movl %eax, 0x50(%rsp)
cltq
movq 0x10(%rsp), %rcx
cmpq %rax, 0x28(%rcx)
jbe 0x6a29
movq %r14, %rdi
callq 0x550c
movl 0x50(%rsp), %eax
cmpl 0x8(%rsp), %eax
je 0x69cd
cmpl %r13d, %eax
je 0x69cd
movq %rbx, %rdi
leaq 0x17e4(%rip), %rsi      # 0x80e9
leaq 0x110(%rsp), %rdx
callq 0x474a
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x47d4
movl (%rax), %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x551a
movq %rbx, %rdi
callq 0x2100
leaq 0x198(%rsp), %rdi
movq %r15, %rsi
callq 0x2340
movq %r14, %rdi
leaq 0x198(%rsp), %r12
movq %r12, %rsi
callq 0x5650
movq %r12, %rdi
callq 0x2100
movq 0x5660(%rip), %rdi      # 0xbfc8
leaq 0x17ac(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1793(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1876(%rip), %rsi      # 0x821b
callq 0x2240
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1ac2(%rip), %rsi      # 0x8482
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
callq 0x58c2
movl 0x50(%rsp), %eax
incl %eax
jmp 0x68c7
leaq 0x1af4(%rip), %rsi      # 0x84db
callq 0x2240
movq %rax, %r15
movq 0x330(%rsp), %rdi
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x4822
movl 0x4(%rax), %esi
movq %r15, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0x2110
movq 0x18(%rsp), %rdi
callq 0x22b0
movq %rax, %rcx
jmp 0x6400
movq 0x330(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4822
movl $0x4, 0x4(%rax)
movq 0x557f(%rip), %rdi      # 0xbfc8
leaq 0x16cb(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x16b2(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1a3b(%rip), %rsi      # 0x84c1
callq 0x2240
movq %rax, %rdi
leaq 0x175d(%rip), %rsi      # 0x81f2
callq 0x2240
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x709e
movq %rax, %r12
movq %r15, %rdi
jmp 0x6b3a
movq 0x330(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4822
movl $0x5, 0x4(%rax)
movq 0x54f4(%rip), %rdi      # 0xbfc8
leaq 0x1640(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x28(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1627(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1969(%rip), %rsi      # 0x847a
callq 0x2240
movq %rax, %rdi
leaq 0x16d2(%rip), %rsi      # 0x81f2
callq 0x2240
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x709e
movq %rax, %r12
movq %r13, %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
movq %r12, %rcx
leaq 0x28(%rsp), %rbx
jmp 0x6400
movq 0x20(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x6e77
leaq 0x50(%rsp), %r15
leaq 0x70(%rsp), %r12
leaq 0xa8(%rsp), %r13
leaq 0x238(%rsp), %rbx
movq %r15, %rdi
movq 0x108(%rsp), %rsi
callq 0x5778
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
movb $0x0, 0xb8(%rsp)
movl $0x400, %edx            # imm = 0x400
movq %r12, %rdi
movq %r15, %rsi
callq 0x566e
movq %r13, %rdi
movq %r12, %rsi
callq 0x22e0
movq %r12, %rdi
callq 0x2100
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2340
movq 0x330(%rsp), %r14
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5a6a
movq %rbx, %rdi
callq 0x2100
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
xorl %eax, %eax
movb %al, 0xe8(%rsp)
movb %al, 0x38(%rsp)
movl 0x70(%rsp), %eax
cmpl $0x5, %eax
je 0x6d0f
cmpl $0x6, %eax
jne 0x6e3e
movq 0x5378(%rip), %rdi      # 0xbfc8
leaq 0x14c4(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x14ab(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1876(%rip), %rsi      # 0x8503
callq 0x2240
movl 0x78(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x17da(%rip), %rsi      # 0x8482
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
leaq 0x74(%rsp), %rsi
callq 0x4822
movl $0x5, 0x4(%rax)
movq 0x52f8(%rip), %rdi      # 0xbfc8
leaq 0x1444(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x142b(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
leaq 0x1770(%rip), %rsi      # 0x847a
jmp 0x6dd0
movq 0x52b2(%rip), %rdi      # 0xbfc8
leaq 0x13fe(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x13e5(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
movq %rax, %rdi
leaq 0x1794(%rip), %rsi      # 0x84e7
callq 0x2240
movl 0x78(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1714(%rip), %rsi      # 0x8482
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r14, %rdi
leaq 0x74(%rsp), %rsi
callq 0x4822
movl $0x4, 0x4(%rax)
movq 0x5232(%rip), %rdi      # 0xbfc8
leaq 0x137e(%rip), %rsi      # 0x811b
callq 0x2240
movl 0x74(%rsp), %esi
movq %rax, %rdi
callq 0x23a0
movq %rax, %rdi
leaq 0x1365(%rip), %rsi      # 0x811d
callq 0x2240
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x23a0
leaq 0x16f1(%rip), %rsi      # 0x84c1
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
leaq 0x1410(%rip), %rsi      # 0x81f2
callq 0x2240
movq 0x20(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x5386
movq 0x20(%rsp), %rax
movq 0x28(%rax), %r14
leaq 0x28(%rsp), %rdi
callq 0x2100
leaq 0xd8(%rsp), %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
movq %r13, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x58c2
testq %r14, %r14
jne 0x6b83
jmp 0x6e77
leaq 0x28(%rsp), %rdi
callq 0x2100
leaq 0xd8(%rsp), %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
movq %r13, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x58c2
jmp 0x6b83
xorl %eax, %eax
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ee5
jmp 0x7051
jmp 0x7051
jmp 0x6ee5
jmp 0x6ee5
movq %rax, %r15
leaq 0x1f8(%rsp), %rdi
jmp 0x6ed9
jmp 0x6eb4
jmp 0x6f70
jmp 0x6f44
movq %rax, %r15
jmp 0x6f54
movq %rax, %r15
leaq 0x2b8(%rsp), %rdi
jmp 0x6ef8
jmp 0x6f63
movq %rax, %r15
leaq 0x218(%rsp), %rdi
callq 0x2100
jmp 0x6f47
jmp 0x7051
movq %rax, %r15
jmp 0x7089
movq %rax, %r15
leaq 0x2d8(%rsp), %rdi
callq 0x2100
jmp 0x6f66
jmp 0x6f01
movq %rax, %r15
jmp 0x6fb1
jmp 0x6f0b
movq %rax, %r15
jmp 0x6f9a
movq %rax, %r15
leaq 0x298(%rsp), %rdi
jmp 0x6f95
jmp 0x7051
jmp 0x7051
jmp 0x6f3c
movq %rax, %r15
leaq 0x238(%rsp), %rdi
jmp 0x7033
movq %rax, %r15
jmp 0x7038
movq %rax, %r15
leaq 0x278(%rsp), %rdi
callq 0x58c2
leaq 0xe8(%rsp), %rdi
callq 0x2100
jmp 0x6f73
movq %rax, %r15
leaq 0xa8(%rsp), %rdi
jmp 0x6fac
movq %rax, %r15
leaq 0x138(%rsp), %rdi
callq 0x2100
leaq 0x110(%rsp), %rdi
callq 0x2100
leaq 0xb8(%rsp), %rdi
callq 0x2100
leaq 0x50(%rsp), %rdi
callq 0x2100
leaq 0x130(%rsp), %rdi
callq 0x58c2
leaq 0x28(%rsp), %rdi
jmp 0x7084
jmp 0x706c
movq %rax, %r15
leaq 0x158(%rsp), %rdi
jmp 0x7061
jmp 0x706c
movq %rax, %r15
leaq 0x198(%rsp), %rdi
jmp 0x7061
jmp 0x7051
movq %rax, %r15
leaq 0x178(%rsp), %rdi
jmp 0x7061
jmp 0x7051
movq %rax, %r15
leaq 0x258(%rsp), %rdi
jmp 0x7061
jmp 0x7051
movq %rax, %r15
leaq 0x1b8(%rsp), %rdi
jmp 0x7061
jmp 0x706c
movq %rax, %r15
leaq 0x28(%rsp), %rdi
callq 0x2100
leaq 0xd8(%rsp), %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
leaq 0xa8(%rsp), %rdi
callq 0x2100
leaq 0x50(%rsp), %rdi
callq 0x58c2
jmp 0x7096
movq %rax, %r15
jmp 0x707c
movq %rax, %r15
leaq 0x1d8(%rsp), %rdi
callq 0x2100
jmp 0x706f
jmp 0x706c
jmp 0x706c
movq %rax, %r15
leaq 0xd8(%rsp), %rdi
callq 0x58c2
leaq 0xa8(%rsp), %rdi
callq 0x2100
leaq 0x80(%rsp), %rdi
callq 0x2100
movq %r15, %rdi
callq 0x23b0