// File: wenleix[P]EdgePPR/src/CreateObjGraph.cpp
// Function: main
int main(int argv, char** argc) {
    paper_newid.reserve(10000000);

    if (argv != 3) {
        fprintf(stderr, "Usage: %s [BigRedFormatFile] [GraphName]\n", argc[0]);
        return 1;
    }

    FILE *wenleiFile = fopen(argc[1], "r");
    FILE *graphFile = fopen(argc[2], "w");

    while (true) {
        Publication *paper = readNewPaper(wenleiFile);
        if (paper == NULL) 
            break;
        papers.push_back(paper);
        if (paper->id >= paper_newid.size()) {
            paper_newid.resize(paper->id + 1, -1);
        }
        paper_newid[paper->id] = papers.size() - 1;
    }

    vector< pair<int, int> > paper_author;
    vector< pair<int, int> > paper_conf;        //  Note, paper_id to conf_id, need offset to generate global id.
    vector< pair<int, int> > conf_forum;

    //  Set up (paper, author) and (paper, venueyear) pairs.
    for (int i = 0; i < papers.size(); i++) {
        Publication* p = papers[i];
        int confId = GetOrCreateID(p->conf, conf_id, conf_name);
        int forumId = GetOrCreateID(p->forum, forum_id, forum_name);
        paper_conf.push_back(make_pair(i, confId));
        conf_forum.push_back(make_pair(confId, forumId));

        vector<string> authors;
        split(p->authors, ',', authors);
        for (string& a : authors) {
        	int aid = GetOrCreateID(a, author_id, author_name);
            paper_author.push_back(make_pair(i, aid));
        }
    }

    //	Unique Conf - Forum edges
    sort(conf_forum.begin(), conf_forum.end());
    conf_forum.resize(unique(conf_forum.begin(), conf_forum.end()) - conf_forum.begin());

    fprintf(stdout, "INFO: # Papers = %lu.\n", papers.size());
    fprintf(stdout, "INFO: # Authors = %lu.\n", author_name.size());
    fprintf(stdout, "INFO: # Conf = %lu.\n", conf_name.size());
    fprintf(stdout, "INFO: # Forum = %lu.\n", forum_name.size());

    fprintf(stdout, "INFO: #Paper-Author = %lu.\n", paper_author.size());
    fprintf(stdout, "INFO: #Paper-Conf = %lu.\n", paper_conf.size());
    fprintf(stdout, "INFO: #Conf-Forum = %lu.\n", conf_forum.size());

    //  Citation edges
    int missingCite = 0;
    int existCite = 0;
    int selfCite = 0;
    for (int i = 0; i < papers.size(); i++) {
        Publication *p = papers[i];
        for (auto rid : p->refs) {
            int newID = paper_newid[rid];
            if (i == newID) {
//            	fprintf(stderr, "Ignore self-loop: %d. \n", i);
            	selfCite++;
            	continue;
            }
            if (newID == -1) {
//                fprintf(stderr, "Debug: Paper ID %d is not occurred.\n", rid);
                missingCite++;
                continue;
            }
            outEdge[i].push_back(Edge(newID, 0 /* Cite */));
            existCite++;
        }
    }
    fprintf(stdout, "INFO: missingCite = %d, existCite = %d, selfCite = %d.\n", missingCite, existCite, selfCite);

    //  Make up the edges!
    int author_offset = papers.size();
    int conf_offset = author_offset + author_name.size();
    int forum_offset = conf_offset + conf_name.size();

    //  written_by and author_write
    for (pair<int, int> pa : paper_author) {
        int paperID = pa.first;
        int g_authorID = author_offset + pa.second;			//	GlobalID for this author
        outEdge[paperID].push_back(Edge(g_authorID, 1 /* written_by */));
        outEdge[g_authorID].push_back(Edge(paperID, 2 /* author_write */));
    }

    //  published_in and conf_publish_paper
    for (pair<int, int> pc : paper_conf) {
        int paperID = pc.first;
        int g_confID = conf_offset + pc.second;				//	GlobalID for this conf
        outEdge[paperID].push_back(Edge(g_confID, 3 /* published_in */ ));
        outEdge[g_confID].push_back(Edge(paperID, 4 /* conf_publish_paper */ ));
    }

    //	conf_calledby_forum and forum_call_conf
    for (pair<int, int> cf : conf_forum) {
    	int g_confID = conf_offset + cf.first;
    	int g_forumID = forum_offset + cf.second;
    	outEdge[g_confID].push_back(Edge(g_forumID, 5 /* conf_calledby_forum */ ));
    	outEdge[g_forumID].push_back(Edge(g_confID, 6 /* forum_call_conf */ ));
    }

    int numVertex = papers.size() + author_name.size() + conf_name.size() + forum_name.size();
    int numEdge = 0;
    for (int i = 0; i < numVertex; i++)
        numEdge += outEdge[i].size();

    fprintf(stderr, "# Vertices = %d, # Edges = %d.\n", numVertex, numEdge);
    fprintf(graphFile, "%d %d\n", numVertex, numEdge);
    //  Paper vertex
    for (int i = 0; i < papers.size(); i++) {
        fprintf(graphFile, "%d 0 %lu %s\n", i, outEdge[i].size(), papers[i]->title.c_str());
        WriteOutEdges(graphFile, outEdge[i]);
    }
    //  Author vertex
    for (int i = 0; i < author_name.size(); i++) {
        int g_authorID = author_offset + i;
        fprintf(graphFile, "%d 1 %lu %s\n", g_authorID, outEdge[g_authorID].size(), 
                                            author_name[i].c_str());
        WriteOutEdges(graphFile, outEdge[g_authorID]);
    }
    //  Conf vertex
    for (int i = 0; i < conf_name.size(); i++) {
        int g_confID = conf_offset + i;
        fprintf(graphFile, "%d 2 %lu %s\n", g_confID, outEdge[g_confID].size(),
                                            conf_name[i].c_str());
        WriteOutEdges(graphFile, outEdge[g_confID]);
    }
    //  Forum vertex
    for (int i = 0; i < forum_name.size(); i++) {
        int g_forumID = forum_offset + i;
        fprintf(graphFile, "%d 3 %lu %s\n", g_forumID, outEdge[g_forumID].size(),
                                            forum_name[i].c_str());
        WriteOutEdges(graphFile, outEdge[g_forumID]);
    }

    fclose(wenleiFile);
    fclose(graphFile);

    for (Publication* p : papers) 
        delete p;

    return 0;
}

// Assembly:
subq $0x3f8, %rsp            # imm = 0x3F8
movl $0x0, 0x3f4(%rsp)
movl %edi, 0x3f0(%rsp)
movq %rsi, 0x3e8(%rsp)
leaq 0x104518(%rip), %rdi    # 0x1074e0
movl $0x989680, %esi         # imm = 0x989680
callq 0x4980
cmpl $0x3, 0x3f0(%rsp)
je 0x300f
movq 0xfffd(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
movq 0x3e8(%rsp), %rax
movq (%rax), %rdx
leaq 0xa17d(%rip), %rsi      # 0xd175
movb $0x0, %al
callq 0x2230
movl $0x1, 0x3f4(%rsp)
jmp 0x431a
movq 0x3e8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0xa103(%rip), %rsi      # 0xd125
callq 0x21c0
movq %rax, 0x3e0(%rsp)
movq 0x3e8(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0xa15d(%rip), %rsi      # 0xd19f
callq 0x21c0
movq %rax, 0x3d8(%rsp)
movq 0x3e0(%rsp), %rdi
callq 0x2890
movq %rax, 0x3d0(%rsp)
cmpq $0x0, 0x3d0(%rsp)
jne 0x3074
jmp 0x312e
leaq 0x10447d(%rip), %rdi    # 0x1074f8
leaq 0x3d0(%rsp), %rsi
callq 0x4a90
movq 0x3d0(%rsp), %rax
movslq 0x88(%rax), %rax
movq %rax, 0x188(%rsp)
leaq 0x10443a(%rip), %rdi    # 0x1074e0
callq 0x4700
movq %rax, %rcx
movq 0x188(%rsp), %rax
cmpq %rcx, %rax
jb 0x30ee
movq 0x3d0(%rsp), %rax
movl 0x88(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
movl $0xffffffff, 0x3cc(%rsp) # imm = 0xFFFFFFFF
leaq 0x1043ff(%rip), %rdi    # 0x1074e0
leaq 0x3cc(%rsp), %rdx
callq 0x4b00
leaq 0x104403(%rip), %rdi    # 0x1074f8
callq 0x4bc0
subq $0x1, %rax
movl %eax, 0x184(%rsp)
movq 0x3d0(%rsp), %rax
movslq 0x88(%rax), %rsi
leaq 0x1043c5(%rip), %rdi    # 0x1074e0
callq 0x4720
movl 0x184(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x304f
leaq 0x3b0(%rsp), %rdi
callq 0x4be0
leaq 0x398(%rsp), %rdi
callq 0x4be0
leaq 0x380(%rsp), %rdi
callq 0x4be0
movl $0x0, 0x37c(%rsp)
movslq 0x37c(%rsp), %rax
movq %rax, 0x178(%rsp)
leaq 0x104381(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movq %rax, %rcx
movq 0x178(%rsp), %rax
cmpq %rcx, %rax
jae 0x3437
movslq 0x37c(%rsp), %rsi
leaq 0x104359(%rip), %rdi    # 0x1074f8
callq 0x4bf0
movq (%rax), %rax
movq %rax, 0x370(%rsp)
movq 0x370(%rsp), %rdi
addq $0x68, %rdi
leaq 0x104266(%rip), %rsi    # 0x107428
leaq 0x1042e7(%rip), %rdx    # 0x1074b0
callq 0x2e60
movl %eax, 0x174(%rsp)
jmp 0x31d7
movl 0x174(%rsp), %eax
movl %eax, 0x36c(%rsp)
movq 0x370(%rsp), %rdi
addq $0x48, %rdi
leaq 0x104268(%rip), %rsi    # 0x107460
leaq 0x1042c9(%rip), %rdx    # 0x1074c8
callq 0x2e60
movl %eax, 0x170(%rsp)
jmp 0x320d
movl 0x170(%rsp), %eax
movl %eax, 0x358(%rsp)
leaq 0x37c(%rsp), %rdi
leaq 0x36c(%rsp), %rsi
callq 0x4c40
movq %rax, 0x168(%rsp)
jmp 0x323a
movq 0x168(%rsp), %rax
movq %rax, 0x350(%rsp)
leaq 0x398(%rsp), %rdi
leaq 0x350(%rsp), %rsi
callq 0x4c10
jmp 0x3261
leaq 0x36c(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x4c40
movq %rax, 0x160(%rsp)
jmp 0x3280
movq 0x160(%rsp), %rax
movq %rax, 0x348(%rsp)
leaq 0x380(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x4c10
jmp 0x32a7
leaq 0x330(%rsp), %rdi
movq %rdi, 0x158(%rsp)
callq 0x4360
movq 0x158(%rsp), %rdx
movq 0x370(%rsp), %rdi
addq $0x20, %rdi
movl $0x2c, %esi
callq 0x2660
jmp 0x32dc
leaq 0x330(%rsp), %rax
movq %rax, 0x328(%rsp)
movq 0x328(%rsp), %rdi
callq 0x4c70
movq %rax, 0x320(%rsp)
movq 0x328(%rsp), %rdi
callq 0x4ca0
movq %rax, 0x318(%rsp)
leaq 0x320(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x4cd0
testb $0x1, %al
jne 0x3334
jmp 0x3414
leaq 0x320(%rsp), %rdi
callq 0x4d10
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rdi
leaq 0x104098(%rip), %rsi    # 0x1073f0
leaq 0x104139(%rip), %rdx    # 0x107498
callq 0x2e60
movl %eax, 0x154(%rsp)
jmp 0x336d
movl 0x154(%rsp), %eax
movl %eax, 0x30c(%rsp)
leaq 0x37c(%rsp), %rdi
leaq 0x30c(%rsp), %rsi
callq 0x4c40
movq %rax, 0x148(%rsp)
jmp 0x339a
movq 0x148(%rsp), %rax
movq %rax, 0x304(%rsp)
leaq 0x3b0(%rsp), %rdi
leaq 0x304(%rsp), %rsi
callq 0x4c10
jmp 0x33c1
jmp 0x33c3
leaq 0x320(%rsp), %rdi
callq 0x4d20
jmp 0x3316
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
jmp 0x42f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x360(%rsp)
movl %eax, 0x35c(%rsp)
leaq 0x330(%rsp), %rdi
callq 0x4370
jmp 0x42f1
leaq 0x330(%rsp), %rdi
callq 0x4370
movl 0x37c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x37c(%rsp)
jmp 0x3160
leaq 0x380(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0x4d80
movq 0x140(%rsp), %rdi
movq %rax, 0x2f8(%rsp)
callq 0x4db0
movq %rax, 0x2f0(%rsp)
movq 0x2f8(%rsp), %rdi
movq 0x2f0(%rsp), %rsi
callq 0x4d40
jmp 0x3480
leaq 0x380(%rsp), %rdi
movq %rdi, 0x130(%rsp)
callq 0x4d80
movq 0x130(%rsp), %rdi
movq %rax, 0x2e0(%rsp)
callq 0x4db0
movq %rax, 0x2d8(%rsp)
movq 0x2e0(%rsp), %rdi
movq 0x2d8(%rsp), %rsi
callq 0x4ec0
movq %rax, 0x138(%rsp)
jmp 0x34d1
movq 0x138(%rsp), %rax
movq %rax, 0x2e8(%rsp)
leaq 0x380(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x4d80
movq %rax, 0x2d0(%rsp)
leaq 0x2e8(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x4e80
movq 0x128(%rsp), %rdi
movq %rax, %rsi
callq 0x4de0
jmp 0x3525
movq 0xfa9c(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0x103fba(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movq 0xf0(%rsp), %rdi
movq %rax, %rdx
leaq 0x9c4c(%rip), %rsi      # 0xd1a1
movb $0x0, %al
callq 0x2230
movq 0xfa65(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0xf8(%rsp)
leaq 0x103f23(%rip), %rdi    # 0x107498
callq 0x4f10
movq 0xf8(%rsp), %rdi
movq %rax, %rdx
leaq 0x9c2c(%rip), %rsi      # 0xd1b8
movb $0x0, %al
callq 0x2230
movq 0xfa2e(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0x100(%rsp)
leaq 0x103f04(%rip), %rdi    # 0x1074b0
callq 0x4f10
movq 0x100(%rsp), %rdi
movq %rax, %rdx
leaq 0x9c0d(%rip), %rsi      # 0xd1d0
movb $0x0, %al
callq 0x2230
movq 0xf9f7(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0x108(%rsp)
leaq 0x103ee5(%rip), %rdi    # 0x1074c8
callq 0x4f10
movq 0x108(%rsp), %rdi
movq %rax, %rdx
leaq 0x9beb(%rip), %rsi      # 0xd1e5
movb $0x0, %al
callq 0x2230
movq 0xf9c0(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0x110(%rsp)
leaq 0x3b0(%rsp), %rdi
callq 0x4f30
movq 0x110(%rsp), %rdi
movq %rax, %rdx
leaq 0x9bc9(%rip), %rsi      # 0xd1fb
movb $0x0, %al
callq 0x2230
movq 0xf988(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0x118(%rsp)
leaq 0x398(%rsp), %rdi
callq 0x4f30
movq 0x118(%rsp), %rdi
movq %rax, %rdx
leaq 0x9bad(%rip), %rsi      # 0xd217
movb $0x0, %al
callq 0x2230
movq 0xf950(%rip), %rax      # 0x12fc8
movq (%rax), %rax
movq %rax, 0x120(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x4f30
movq 0x120(%rsp), %rdi
movq %rax, %rdx
leaq 0x9b8f(%rip), %rsi      # 0xd231
movb $0x0, %al
callq 0x2230
movl $0x0, 0x2cc(%rsp)
movl $0x0, 0x2c8(%rsp)
movl $0x0, 0x2c4(%rsp)
movl $0x0, 0x2c0(%rsp)
movslq 0x2c0(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0x103e0c(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movq %rax, %rcx
movq 0xe8(%rsp), %rax
cmpq %rcx, %rax
jae 0x387e
movslq 0x2c0(%rsp), %rsi
leaq 0x103de4(%rip), %rdi    # 0x1074f8
callq 0x4bf0
movq (%rax), %rax
movq %rax, 0x2b8(%rsp)
movq 0x2b8(%rsp), %rax
addq $0x90, %rax
movq %rax, 0x2b0(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x4f50
movq %rax, 0x2a8(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x4f80
movq %rax, 0x2a0(%rsp)
leaq 0x2a8(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x4fb0
testb $0x1, %al
jne 0x3782
jmp 0x3866
leaq 0x2a8(%rsp), %rdi
callq 0x4ff0
movl (%rax), %eax
movl %eax, 0x29c(%rsp)
movslq 0x29c(%rsp), %rsi
leaq 0x103d39(%rip), %rdi    # 0x1074e0
callq 0x4720
movl (%rax), %eax
movl %eax, 0x298(%rsp)
movl 0x2c0(%rsp), %eax
cmpl 0x298(%rsp), %eax
jne 0x37d8
movl 0x2c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c4(%rsp)
jmp 0x3854
cmpl $-0x1, 0x298(%rsp)
jne 0x37f5
movl 0x2cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2cc(%rsp)
jmp 0x3854
movslq 0x2c0(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x103d08(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xe0(%rsp)
movl 0x298(%rsp), %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5030
jmp 0x382c
movq 0xe0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0x5000
jmp 0x3843
movl 0x2c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c8(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x5050
jmp 0x3764
jmp 0x3868
movl 0x2c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c0(%rsp)
jmp 0x36d5
movq 0xf743(%rip), %rax      # 0x12fc8
movq (%rax), %rdi
movl 0x2cc(%rsp), %edx
movl 0x2c8(%rsp), %ecx
movl 0x2c4(%rsp), %r8d
leaq 0x99a6(%rip), %rsi      # 0xd24b
movb $0x0, %al
callq 0x2230
leaq 0x103c45(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movl %eax, 0x28c(%rsp)
movslq 0x28c(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x103bc2(%rip), %rdi    # 0x107498
callq 0x4f10
movq %rax, %rcx
movq 0xd0(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x288(%rsp)
movslq 0x288(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0x103ba9(%rip), %rdi    # 0x1074b0
callq 0x4f10
movq %rax, %rcx
movq 0xd8(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x284(%rsp)
leaq 0x3b0(%rsp), %rax
movq %rax, 0x278(%rsp)
movq 0x278(%rsp), %rdi
callq 0x4d80
movq %rax, 0x270(%rsp)
movq 0x278(%rsp), %rdi
callq 0x4db0
movq %rax, 0x268(%rsp)
leaq 0x270(%rsp), %rdi
leaq 0x268(%rsp), %rsi
callq 0x5070
testb $0x1, %al
jne 0x3979
jmp 0x3a6c
leaq 0x270(%rsp), %rdi
callq 0x50b0
movq (%rax), %rax
movq %rax, 0x260(%rsp)
movl 0x260(%rsp), %eax
movl %eax, 0x25c(%rsp)
movl 0x28c(%rsp), %eax
movl 0x264(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x258(%rsp)
movslq 0x25c(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x103b47(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xc8(%rsp)
movl 0x258(%rsp), %esi
leaq 0x250(%rsp), %rdi
movl $0x1, %edx
callq 0x5030
jmp 0x39f0
movq 0xc8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x5000
jmp 0x3a07
movslq 0x258(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x103af6(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xc0(%rsp)
movl 0x25c(%rsp), %esi
leaq 0x248(%rsp), %rdi
movl $0x2, %edx
callq 0x5030
jmp 0x3a41
movq 0xc0(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x5000
jmp 0x3a58
jmp 0x3a5a
leaq 0x270(%rsp), %rdi
callq 0x50c0
jmp 0x395b
leaq 0x398(%rsp), %rax
movq %rax, 0x240(%rsp)
movq 0x240(%rsp), %rdi
callq 0x4d80
movq %rax, 0x238(%rsp)
movq 0x240(%rsp), %rdi
callq 0x4db0
movq %rax, 0x230(%rsp)
leaq 0x238(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x5070
testb $0x1, %al
jne 0x3ac4
jmp 0x3bb7
leaq 0x238(%rsp), %rdi
callq 0x50b0
movq (%rax), %rax
movq %rax, 0x228(%rsp)
movl 0x228(%rsp), %eax
movl %eax, 0x224(%rsp)
movl 0x288(%rsp), %eax
movl 0x22c(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x220(%rsp)
movslq 0x224(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x1039fc(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xb8(%rsp)
movl 0x220(%rsp), %esi
leaq 0x218(%rsp), %rdi
movl $0x3, %edx
callq 0x5030
jmp 0x3b3b
movq 0xb8(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x5000
jmp 0x3b52
movslq 0x220(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x1039ab(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xb0(%rsp)
movl 0x224(%rsp), %esi
leaq 0x210(%rsp), %rdi
movl $0x4, %edx
callq 0x5030
jmp 0x3b8c
movq 0xb0(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x5000
jmp 0x3ba3
jmp 0x3ba5
leaq 0x238(%rsp), %rdi
callq 0x50c0
jmp 0x3aa6
leaq 0x380(%rsp), %rax
movq %rax, 0x208(%rsp)
movq 0x208(%rsp), %rdi
callq 0x4d80
movq %rax, 0x200(%rsp)
movq 0x208(%rsp), %rdi
callq 0x4db0
movq %rax, 0x1f8(%rsp)
leaq 0x200(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x5070
testb $0x1, %al
jne 0x3c0f
jmp 0x3d0b
leaq 0x200(%rsp), %rdi
callq 0x50b0
movq (%rax), %rax
movq %rax, 0x1f0(%rsp)
movl 0x288(%rsp), %eax
movl 0x1f0(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x1ec(%rsp)
movl 0x284(%rsp), %eax
movl 0x1f4(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x1e8(%rsp)
movslq 0x1ec(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x1038a8(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xa8(%rsp)
movl 0x1e8(%rsp), %esi
leaq 0x1e0(%rsp), %rdi
movl $0x5, %edx
callq 0x5030
jmp 0x3c8f
movq 0xa8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x5000
jmp 0x3ca6
movslq 0x1e8(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x103857(%rip), %rax    # 0x107510
leaq (%rax,%rcx,8), %rax
movq %rax, 0xa0(%rsp)
movl 0x1ec(%rsp), %esi
leaq 0x1d8(%rsp), %rdi
movl $0x6, %edx
callq 0x5030
jmp 0x3ce0
movq 0xa0(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x5000
jmp 0x3cf7
jmp 0x3cf9
leaq 0x200(%rsp), %rdi
callq 0x50c0
jmp 0x3bf1
leaq 0x1037e6(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movq %rax, 0x88(%rsp)
leaq 0x103772(%rip), %rdi    # 0x107498
callq 0x4f10
movq %rax, %rcx
movq 0x88(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x90(%rsp)
leaq 0x103768(%rip), %rdi    # 0x1074b0
callq 0x4f10
movq %rax, %rcx
movq 0x90(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x98(%rsp)
leaq 0x10375e(%rip), %rdi    # 0x1074c8
callq 0x4f10
movq %rax, %rcx
movq 0x98(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x1d4(%rsp)
movl $0x0, 0x1d0(%rsp)
movl $0x0, 0x1cc(%rsp)
movl 0x1cc(%rsp), %eax
cmpl 0x1d4(%rsp), %eax
jge 0x3ded
movslq 0x1cc(%rsp), %rax
leaq 0x103757(%rip), %rdi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x50e0
movq %rax, %rcx
movslq 0x1d0(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x1d0(%rsp)
movl 0x1cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1cc(%rsp)
jmp 0x3d9a
movq 0xf1ec(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
movl 0x1d4(%rsp), %edx
movl 0x1d0(%rsp), %ecx
leaq 0x9477(%rip), %rsi      # 0xd283
movb $0x0, %al
callq 0x2230
movq 0x3d8(%rsp), %rdi
movl 0x1d4(%rsp), %edx
movl 0x1d0(%rsp), %ecx
leaq 0x933e(%rip), %rsi      # 0xd16e
movb $0x0, %al
callq 0x2230
movl $0x0, 0x1c8(%rsp)
movslq 0x1c8(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x10369f(%rip), %rdi    # 0x1074f8
callq 0x4bc0
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0x3f1e
movq 0x3d8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0x1c8(%rsp), %eax
movl %eax, 0x74(%rsp)
movslq 0x1c8(%rsp), %rax
leaq 0x103677(%rip), %rdi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x50e0
movq %rax, 0x78(%rsp)
movslq 0x1c8(%rsp), %rsi
leaq 0x10363f(%rip), %rdi    # 0x1074f8
callq 0x4bf0
movq (%rax), %rdi
callq 0x2080
movq 0x68(%rsp), %rdi
movl 0x74(%rsp), %edx
movq 0x78(%rsp), %rcx
movq %rax, %r8
leaq 0x93c5(%rip), %rsi      # 0xd2a3
movb $0x0, %al
callq 0x2230
movq 0x3d8(%rsp), %rdi
movslq 0x1c8(%rsp), %rax
leaq 0x103614(%rip), %rsi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x2f10
movl 0x1c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c8(%rsp)
jmp 0x3e42
movl $0x0, 0x1c4(%rsp)
movslq 0x1c4(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x10355b(%rip), %rdi    # 0x107498
callq 0x4f10
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jae 0x4014
movl 0x28c(%rsp), %eax
addl 0x1c4(%rsp), %eax
movl %eax, 0x1c0(%rsp)
movq 0x3d8(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0x1c0(%rsp), %eax
movl %eax, 0x54(%rsp)
movslq 0x1c0(%rsp), %rax
leaq 0x103581(%rip), %rdi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x50e0
movq %rax, 0x58(%rsp)
movslq 0x1c4(%rsp), %rsi
leaq 0x1034e9(%rip), %rdi    # 0x107498
callq 0x5100
movq %rax, %rdi
callq 0x2080
movq 0x48(%rsp), %rdi
movl 0x54(%rsp), %edx
movq 0x58(%rsp), %rcx
movq %rax, %r8
leaq 0x92dc(%rip), %rsi      # 0xd2b0
movb $0x0, %al
callq 0x2230
movq 0x3d8(%rsp), %rdi
movslq 0x1c0(%rsp), %rax
leaq 0x10351e(%rip), %rsi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x2f10
movl 0x1c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c4(%rsp)
jmp 0x3f29
movl $0x0, 0x1bc(%rsp)
movslq 0x1bc(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x10347d(%rip), %rdi    # 0x1074b0
callq 0x4f10
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x410a
movl 0x288(%rsp), %eax
addl 0x1bc(%rsp), %eax
movl %eax, 0x1b8(%rsp)
movq 0x3d8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x1b8(%rsp), %eax
movl %eax, 0x34(%rsp)
movslq 0x1b8(%rsp), %rax
leaq 0x10348b(%rip), %rdi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x50e0
movq %rax, 0x38(%rsp)
movslq 0x1bc(%rsp), %rsi
leaq 0x10340b(%rip), %rdi    # 0x1074b0
callq 0x5100
movq %rax, %rdi
callq 0x2080
movq 0x28(%rsp), %rdi
movl 0x34(%rsp), %edx
movq 0x38(%rsp), %rcx
movq %rax, %r8
leaq 0x91f3(%rip), %rsi      # 0xd2bd
movb $0x0, %al
callq 0x2230
movq 0x3d8(%rsp), %rdi
movslq 0x1b8(%rsp), %rax
leaq 0x103428(%rip), %rsi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x2f10
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0x401f
movl $0x0, 0x1b4(%rsp)
movslq 0x1b4(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x10339f(%rip), %rdi    # 0x1074c8
callq 0x4f10
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x4200
movl 0x284(%rsp), %eax
addl 0x1b4(%rsp), %eax
movl %eax, 0x1b0(%rsp)
movq 0x3d8(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x1b0(%rsp), %eax
movl %eax, 0x14(%rsp)
movslq 0x1b0(%rsp), %rax
leaq 0x103395(%rip), %rdi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x50e0
movq %rax, 0x18(%rsp)
movslq 0x1b4(%rsp), %rsi
leaq 0x10332d(%rip), %rdi    # 0x1074c8
callq 0x5100
movq %rax, %rdi
callq 0x2080
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %edx
movq 0x18(%rsp), %rcx
movq %rax, %r8
leaq 0x910a(%rip), %rsi      # 0xd2ca
movb $0x0, %al
callq 0x2230
movq 0x3d8(%rsp), %rdi
movslq 0x1b0(%rsp), %rax
leaq 0x103332(%rip), %rsi    # 0x107510
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x2f10
movl 0x1b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b4(%rsp)
jmp 0x4115
movq 0x3e0(%rsp), %rdi
callq 0x2190
jmp 0x420f
movq 0x3d8(%rsp), %rdi
callq 0x2190
jmp 0x421e
leaq 0x1032d3(%rip), %rax    # 0x1074f8
movq %rax, 0x1a8(%rsp)
leaq 0x1032c4(%rip), %rdi    # 0x1074f8
callq 0x5120
movq %rax, 0x1a0(%rsp)
leaq 0x1032b0(%rip), %rdi    # 0x1074f8
callq 0x5150
movq %rax, 0x198(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x5180
testb $0x1, %al
jne 0x4270
jmp 0x42bd
leaq 0x1a0(%rsp), %rdi
callq 0x51c0
movq (%rax), %rax
movq %rax, 0x190(%rsp)
movq 0x190(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x42ac
movq (%rsp), %rdi
callq 0x51d0
movq (%rsp), %rdi
callq 0x2180
jmp 0x42ae
leaq 0x1a0(%rsp), %rdi
callq 0x5230
jmp 0x4255
movl $0x0, 0x3f4(%rsp)
leaq 0x380(%rsp), %rdi
callq 0x5250
leaq 0x398(%rsp), %rdi
callq 0x5250
leaq 0x3b0(%rsp), %rdi
callq 0x5250
jmp 0x431a
leaq 0x380(%rsp), %rdi
callq 0x5250
leaq 0x398(%rsp), %rdi
callq 0x5250
leaq 0x3b0(%rsp), %rdi
callq 0x5250
jmp 0x4329
movl 0x3f4(%rsp), %eax
addq $0x3f8, %rsp            # imm = 0x3F8
retq
movq 0x360(%rsp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)