// File: /workspace/github_cpp_makefile_star2_O2/sjain12[P]CliqueCounting/tests/../Escape/CliquesTuranShadow.h
// Function: turan_shadow(Escape::CGraph&, CDAG&, std::basic_ofstream<char, std::char_traits<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, int)
void turan_shadow(CGraph &CG, CDAG &DG, ofstream &of, string gname, string fname, int runs, int num_samples, int clique_size)
{    
    high_resolution_clock::time_point treegen_s = high_resolution_clock::now();

    double num_cliques = 0, num_leaves = 0;
    double non_leaf_cliques = 0;
    double discarded_leaves = 0;
    int k = 0; 
    double succ_ratio = 0, leaf_samples = 0, leaf_size = 0, density = 0, leaf_cliques = 0;
    VertexIdx psize = 0, nsize = 0;
    PartialClique *pc = NULL;
    VertexIdx arr[10000];  // array for storing numbers 0 through leaf_size, which will be used by the random number generator
    VertexIdx rng[10000]; // will be used for the random number generator
    double N = 0;    

    vector<int> leafk;
    vector<int> leafn;
    int leaves_inc = 10000000;
    int max_leaves = leaves_inc;
    leafk.resize(leaves_inc);
    leafn.resize(leaves_inc);
    double internal = 0;


    for (int i=0; i<10000; i++)
        arr[i] = i;

    double internal_nodes = 0;
	double shadow_size = 0;
    srand(time(NULL));
    
    Stack *stack = newStack();
    vector <VertexSet*> leaves;
    vector <int> leafExperiments;
    leafExperiments.resize(leaves_inc);
    leaves.resize(leaves_inc);

    for (VertexIdx i=0; i<CG.nVertices; i++)
    {
    	VertexSet *path = newVertexSet(1);
    	path->vertices[0] = i;
    	VertexSet *nbrs = newVertexSet(DG.outlist.offsets[i+1] - DG.outlist.offsets[i]);
    	std::copy(DG.outlist.nbors+DG.outlist.offsets[i], DG.outlist.nbors+DG.outlist.offsets[i+1], nbrs->vertices);
    	pc = newPartialClique(path, nbrs);
    	stack->push(pc);

        StackItem* si = stack->pop();
        int flag = 0;
    	EdgeIdx num_edges = 0;
        while (si != NULL)  // unraveling the stack
        {
            VertexSet *path = si->pc->path;
            VertexSet *nbrs = si->pc->nbrs;  // get the current path and its nbrs
            psize = path->nVertices;
            nsize = nbrs->nVertices;
            flag = 0;

    	    k = clique_size - psize;
            density = get_density(CG, nbrs,num_edges);
    				
            if (psize + nsize < clique_size) 
            {
                discarded_leaves++;
                flag = 1;
            }
            else if (psize == clique_size)
            {
                num_cliques++;
                non_leaf_cliques++;
                flag = 1;
            }
            else if (psize == clique_size - 1)
            {
                num_cliques += nbrs->nVertices;
                non_leaf_cliques += nbrs->nVertices;
                flag = 1;
            }
            else if (k == 2)
    		{
    				non_leaf_cliques += num_edges;
    				flag = 1;
    		}
    		else
    		{
                double thresh_dens = 1.0 - pow((k-1), -1);
                if (density >= thresh_dens)
                {
                    leaves[num_leaves] = nbrs;
                    leafExperiments[num_leaves] = nCr[nsize][k];
                    leafk[num_leaves] = k;
                    leafn[num_leaves] = nsize;
                    N += nCr[nsize][k];
                  
                    shadow_size += nsize;

                    num_leaves++;
                    if (num_leaves == max_leaves) 
                    {
                        max_leaves += leaves_inc;
                        leaves.resize(max_leaves);
                        leafExperiments.resize(max_leaves);
                        leafk.resize(max_leaves);
                        leafn.resize(max_leaves);
                    }
                }
                else
                {
                    internal++;
                    for (int i=0; i<nbrs->nVertices-1; i++)
                    {
                        VertexSet *new_path = newVertexSet(1);
                        new_path->nVertices = path->nVertices + 1;
                        VertexSet *new_nbrs = newVertexSet(nsize);

                        int c = 0;
                        for (int j=i+1; j<nbrs->nVertices; j++)
                        {
                            if (CG.isEdge(nbrs->vertices[i], nbrs->vertices[j]) != -1)
                            {
                                new_nbrs->vertices[c] = nbrs->vertices[j];
                                c++;
                            }
                        }
                        new_nbrs->nVertices = c;
    			
                        PartialClique *pc1 = newPartialClique(new_path, new_nbrs);
                        stack->push(pc1);
                    }

                    flag = 1;
                }
            }
            if (flag == 1)
            {
                if (nbrs->nVertices >= 0) delete[] nbrs->vertices;
                delete nbrs;
                
            }
            if (path->nVertices > 0) delete[] path->vertices;
            delete path;
            delete si->pc;
            delete si;
            si = stack->pop();
            continue;
        }

    }
	high_resolution_clock::time_point treegen_e = high_resolution_clock::now();
    auto duration_treegen = std::chrono::duration_cast<std::chrono::microseconds>( treegen_e - treegen_s ).count();

    cout << "internal = " << internal << endl;
    cout << "leaves = " << num_leaves << endl;
    cout << "discarded_leaves = " << discarded_leaves << endl;
    cout << "internal + leaves + discarded_leaves = " << internal + num_leaves + discarded_leaves << endl;

    string datfile(gname + "_" + to_string(num_samples) + "_" + to_string(clique_size) + "_" + to_string(runs) + "_data");
    std::string dfname = "../results/cliques/" + datfile;
    std::cout << dfname << std::endl;
    std::ofstream df;
    df.open(dfname);
    if (!df.is_open())
    {
        std::cout << "Could not open output file." << std::endl;
        exit(1);
    }
    printf("Output File: %s\n", dfname.c_str());
    df << "estimate,succ_ratio,time," << endl;
    df.precision(2);
    double est;

	if (num_leaves != 0)
	{
		std::default_random_engine generator;
		std::discrete_distribution<int> distribution (leafExperiments.begin(), leafExperiments.end());
	
    	for (int r=0; r<runs; r++)
    	{
        
        	high_resolution_clock::time_point sampling_s = high_resolution_clock::now();
        	auto duration_sampling = std::chrono::duration_cast<std::chrono::microseconds>(sampling_s - sampling_s).count();
        	leaf_cliques = 0;
        	for (int i=0; i<num_samples; ++i) 
        	{
            	int leaf = distribution(generator);
            	k = leafk[leaf];
            	VertexSet *l = leaves[leaf];
            	std::copy(arr, arr+l->nVertices, rng);
            	std::random_shuffle ( rng, rng+l->nVertices);
            	VertexIdx *sample = (VertexIdx *) calloc(k,sizeof(VertexIdx)); 
            	for (int j = 0; j < k; j++)
                	sample[j] = l->vertices[rng[j]];

            	if (isClique(sample, k, CG)) 
            	{
                	leaf_cliques++; //experiment was a success. Sampled set of vertices do form a clique
            	}

            	free(sample);
        	}

        	high_resolution_clock::time_point sampling_e = high_resolution_clock::now();
        	duration_sampling = std::chrono::duration_cast<std::chrono::microseconds>( sampling_e - sampling_s ).count();
        	modf((leaf_cliques * N / num_samples)+non_leaf_cliques, &est);
        	succ_ratio = leaf_cliques / num_samples;
        	df << est << "," <<  succ_ratio << "," << duration_sampling << "," << endl;
    	}
    }
	else 
     	df << "0,0,0," << endl;
    		
	df.close();

    string outfile(gname + "_" + to_string(num_samples) + "_" + to_string(clique_size) + "_params");
    std::string ofname = "../results/cliques/" + outfile;
    std::cout << ofname << std::endl;
    std::ofstream ofparams;
    ofparams.open(ofname);
    if (!ofparams.is_open())
    {
        std::cout << "Could not open output file." << std::endl;
        exit(1);
    }
    printf("Output File: %s\n", ofname.c_str());

    ofparams << "internal," << "leaves," << "discarded leaves,"  << "shadow size," << "N,";
    ofparams << "tree_t," << "num_samples," << endl;
    ofparams << internal << "," << num_leaves << "," << discarded_leaves << "," << shadow_size << "," << N << ",";
    ofparams << duration_treegen << "," << num_samples << "," << endl;
    ofparams << endl;
    ofparams.close();
   
	for (int i=0; i<num_leaves; i++)
	{
		if (leaves[i]->nVertices >= 0) delete[] leaves[i]->vertices;
            delete leaves[i];
            
	} 
    cout << "clique_size = " << clique_size << endl;;
    cout << "Num of leaves = " << num_leaves << endl;
    cout << "Num of discarded leaves = " << discarded_leaves << endl;
    cout << "Number of non_leaf_cliques = " << non_leaf_cliques << endl;
    cout << "Estimated number of cliques = " << est << endl;
    cout << "N = " << N << endl;
    cout << "time reqd to build tree: " << duration_treegen << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x27768, %rsp          # imm = 0x27768
movl %r9d, 0x34(%rsp)
movq %rcx, 0xe8(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdi, 0x78(%rsp)
callq 0x3050
movq %rax, 0x190(%rsp)
xorpd %xmm0, %xmm0
leaq 0x170(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movapd %xmm0, 0x150(%rsp)
andq $0x0, 0x160(%rsp)
movl $0x989680, %esi         # imm = 0x989680
callq 0x581c
leaq 0x150(%rsp), %rdi
movl $0x989680, %esi         # imm = 0x989680
callq 0x581c
xorl %eax, %eax
cmpq $0x2710, %rax           # imm = 0x2710
je 0x3fe0
movq %rax, 0x13ee0(%rsp,%rax,8)
incq %rax
jmp 0x3fcb
xorl %edi, %edi
callq 0x3230
movl %eax, %edi
callq 0x3260
callq 0x3c87
movq %rax, %r12
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x130(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movl $0x989680, %esi         # imm = 0x989680
callq 0x581c
leaq 0xd0(%rsp), %rdi
movl $0x989680, %esi         # imm = 0x989680
callq 0x584e
movslq 0x277a8(%rsp), %r13
leal -0x1(%r13), %eax
cltq
movq %rax, 0x198(%rsp)
movl $0x989680, 0x6c(%rsp)   # imm = 0x989680
xorpd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movq $0x0, 0x70(%rsp)
pushq $0x10
popq %rbp
movsd %xmm0, 0x90(%rsp)
movsd %xmm0, 0x50(%rsp)
movsd %xmm0, 0x40(%rsp)
movsd %xmm0, 0x38(%rsp)
movapd %xmm0, 0x80(%rsp)
movq %r12, 0x1a8(%rsp)
movq %r13, 0x1a0(%rsp)
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
cmpq (%rax), %rcx
jge 0x44da
pushq $0x1
popq %rdi
callq 0x3aa8
movq %rax, %rbx
movq 0x8(%rax), %rax
movq 0x70(%rsp), %rcx
movq %rcx, (%rax)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax,%rcx,8), %rdi
subq (%rax,%rcx,8), %rdi
callq 0x3aa8
movq %rax, %r14
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x70(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
incq %rcx
shlq $0x3, %rsi
movq %rcx, 0x70(%rsp)
movq (%rax,%rcx,8), %rdx
shlq $0x3, %rdx
subq %rsi, %rdx
je 0x412b
movq 0x98(%rsp), %rax
addq 0x18(%rax), %rsi
movq 0x8(%r14), %rdi
callq 0x3460
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c21
movq %r12, %rdi
movq %rax, %rsi
callq 0x3ca6
movq %r12, %rdi
callq 0x3cd2
andq $0x0, 0x460(%rsp)
testq %rax, %rax
je 0x40a1
movq %rax, 0xa8(%rsp)
movq (%rax), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r14
movq %rcx, 0x28(%rsp)
movq (%rcx), %rbx
movq (%r14), %r15
movq 0x78(%rsp), %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r14, %rdi
leaq 0x460(%rsp), %rsi
callq 0x3d9e
leaq (%r15,%rbx), %rax
cmpq %r13, %rax
jge 0x41c0
movsd 0x40(%rsp), %xmm0
addsd 0x6e50(%rip), %xmm0     # 0xb008
movsd %xmm0, 0x40(%rsp)
jmp 0x41dd
cmpq %r13, %rbx
jne 0x424d
movsd 0x38(%rsp), %xmm0
addsd 0x6e31(%rip), %xmm0     # 0xb008
movsd %xmm0, 0x38(%rsp)
movq (%r14), %rax
testq %rax, %rax
js 0x41f3
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x41f3
callq 0x3330
movq %r14, %rdi
movq %rbp, %rsi
callq 0x32b0
movq 0x28(%rsp), %r14
cmpq $0x0, (%r14)
jle 0x4217
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x4217
callq 0x3330
movq %r14, %rdi
movq %rbp, %rsi
callq 0x32b0
movq 0xa8(%rsp), %rbx
movq (%rbx), %rdi
movq %rbp, %rsi
callq 0x32b0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x32b0
movq %r12, %rdi
callq 0x3cd2
jmp 0x4152
cmpq 0x198(%rsp), %rbx
jne 0x4274
movq (%r14), %rax
cvtsi2sd %rax, %xmm0
movsd 0x38(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
jmp 0x41e0
movl 0x277a8(%rsp), %eax
subl %ebx, %eax
cmpl $0x2, %eax
jne 0x42a1
cvtsi2sdq 0x460(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
jmp 0x41dd
leal -0x1(%rax), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x6d58(%rip), %xmm3     # 0xb008
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
movapd %xmm3, %xmm1
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jae 0x43bd
movq %r15, 0x1b0(%rsp)
movsd 0x48(%rsp), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, 0x48(%rsp)
xorl %r15d, %r15d
pushq $0x1
popq %rax
movq %rax, 0x60(%rsp)
movq (%r14), %rax
leaq -0x1(%rax), %rcx
cmpq %r15, %rcx
jle 0x41e0
pushq $0x1
popq %rdi
callq 0x3aa8
movq %rax, %rbx
movq 0x28(%rsp), %rax
movq (%rax), %rax
incq %rax
movq %rax, (%rbx)
movq 0x1b0(%rsp), %rdi
callq 0x3aa8
movq %rax, %rbp
movq %rbx, 0x58(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0xa0(%rsp)
xorl %ebx, %ebx
movq 0x60(%rsp), %r12
movslq %ebx, %r13
cmpq %r12, (%r14)
jle 0x437c
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rsi
movq (%rax,%r12,8), %rdx
movq 0x78(%rsp), %rdi
callq 0x7112
cmpl $-0x1, %eax
je 0x4377
movq 0x8(%r14), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rbp), %rcx
movq %rax, (%rcx,%r13,8)
incl %r13d
movl %r13d, %ebx
incq %r12
jmp 0x433e
movq %r13, (%rbp)
movq 0x58(%rsp), %rdi
movq %rbp, %rsi
callq 0x3c21
movq 0x1a8(%rsp), %r12
movq 0x1a0(%rsp), %r13
pushq $0x10
popq %rbp
incq 0x60(%rsp)
movq %r12, %rdi
movq %rax, %rsi
callq 0x3ca6
movq 0xa0(%rsp), %r15
jmp 0x42ed
movapd 0x80(%rsp), %xmm2
cvttsd2si %xmm2, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
movapd %xmm2, %xmm0
subsd 0x6c32(%rip), %xmm0     # 0xb010
cvttsd2si %xmm0, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq 0xd0(%rsp), %rcx
movq %r14, (%rcx,%rsi,8)
movslq %eax, %rcx
imulq $0x328, %r15, %rdx      # imm = 0x328
leaq 0xceca(%rip), %rdi      # 0x112d0
addq %rdi, %rdx
movsd (%rdx,%rcx,8), %xmm0
cvttsd2si %xmm0, %ecx
movq 0x130(%rsp), %rdx
movl %ecx, (%rdx,%rsi,4)
movq 0x170(%rsp), %rcx
movl %eax, (%rcx,%rsi,4)
movq 0x150(%rsp), %rax
movl %r15d, (%rax,%rsi,4)
movsd 0x50(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
cvtsi2sd %r15, %xmm0
movsd 0x90(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x90(%rsp)
addsd %xmm3, %xmm2
movl 0x6c(%rsp), %eax
cvtsi2sd %eax, %xmm0
movapd %xmm2, 0x80(%rsp)
ucomisd %xmm0, %xmm2
jne 0x41fe
jp 0x41fe
addl $0x989680, %eax         # imm = 0x989680
movl %eax, 0x6c(%rsp)
movslq %eax, %rbx
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x584e
movq 0x28(%rsp), %r14
leaq 0x130(%rsp), %rdi
movq %rbx, %rsi
callq 0x581c
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x581c
leaq 0x150(%rsp), %rdi
movq %rbx, %rsi
callq 0x581c
jmp 0x4203
callq 0x3050
subq 0x190(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %r15
movq 0xcad5(%rip), %rdi      # 0x10fd0
leaq 0x6bf6(%rip), %rsi      # 0xb0f8
callq 0x3280
movq %rax, %rdi
movsd 0x48(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xcaac(%rip), %rdi      # 0x10fd0
leaq 0x6cc9(%rip), %rsi      # 0xb1f4
callq 0x3280
movq %rax, %rdi
movapd 0x80(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xca80(%rip), %rdi      # 0x10fd0
leaq 0x6bc1(%rip), %rsi      # 0xb118
callq 0x3280
movq %rax, %rdi
movsd 0x40(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xca57(%rip), %rdi      # 0x10fd0
leaq 0x6b84(%rip), %rsi      # 0xb104
callq 0x3280
movsd 0x48(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movq %rax, %rdi
callq 0x3450
movq %rax, %rdi
callq 0x3140
leaq 0x6b7b(%rip), %rdx      # 0xb12c
leaq 0x220(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x5905
leaq 0x200(%rsp), %rdi
movl 0x277a0(%rsp), %esi
callq 0x593d
leaq 0xb0(%rsp), %rdi
leaq 0x220(%rsp), %rsi
leaq 0x200(%rsp), %rdx
callq 0x589e
leaq 0x6b2e(%rip), %rdx      # 0xb12c
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x587f
leaq 0x1e0(%rsp), %rdi
movl 0x277a8(%rsp), %esi
callq 0x593d
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0x1e0(%rsp), %rdx
callq 0x589e
leaq 0x6ae1(%rip), %rdx      # 0xb12c
leaq 0x260(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x587f
leaq 0x1c0(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x593d
leaq 0x460(%rsp), %rdi
leaq 0x260(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
callq 0x589e
leaq 0x6a99(%rip), %rdx      # 0xb12e
leaq 0x240(%rsp), %rdi
leaq 0x460(%rsp), %rsi
callq 0x587f
leaq 0x460(%rsp), %rdi
callq 0x3120
leaq 0x1c0(%rsp), %rdi
callq 0x3120
leaq 0x260(%rsp), %rdi
callq 0x3120
leaq 0x110(%rsp), %rdi
callq 0x3120
leaq 0x1e0(%rsp), %rdi
callq 0x3120
leaq 0xf0(%rsp), %rdi
callq 0x3120
leaq 0xb0(%rsp), %rdi
callq 0x3120
leaq 0x200(%rsp), %rdi
callq 0x3120
leaq 0x220(%rsp), %rdi
callq 0x3120
leaq 0x6a0e(%rip), %rsi      # 0xb134
leaq 0x110(%rsp), %rdi
leaq 0x240(%rsp), %rdx
callq 0x5996
movq 0xc88e(%rip), %rdi      # 0x10fd0
leaq 0x110(%rsp), %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
leaq 0x460(%rsp), %rdi
callq 0x3490
leaq 0x460(%rsp), %rdi
leaq 0x110(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3130
leaq 0x4d0(%rsp), %rdi
callq 0x30b0
testb %al, %al
je 0x4f78
movq 0x110(%rsp), %rsi
leaq 0x69a8(%rip), %rdi      # 0xb148
xorl %eax, %eax
callq 0x3040
leaq 0x69ab(%rip), %rsi      # 0xb159
leaq 0x460(%rsp), %rdi
callq 0x3280
movq %rax, %rdi
callq 0x3140
movq 0x460(%rsp), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x468(%rsp,%rax)
xorpd %xmm0, %xmm0
movapd 0x80(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x47f4
jnp 0x4a43
movq %r15, 0xa0(%rsp)
movq $0x1, 0xf0(%rsp)
movq 0x130(%rsp), %rsi
movq 0x138(%rsp), %rdx
leaq 0x260(%rsp), %rdi
callq 0x665a
movl 0x277a0(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
xorl %ebx, %ebx
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movl %ecx, 0xa8(%rsp)
movl 0x34(%rsp), %eax
testl %eax, %eax
cmovlel %ebx, %eax
movl %eax, 0x34(%rsp)
leaq 0x660(%rsp), %rbp
cmpl 0x34(%rsp), %ebx
je 0x4a2c
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
callq 0x3050
movq %rax, 0x58(%rsp)
movq %rbx, %r14
cmpl 0xa8(%rsp), %r15d
je 0x4979
leaq 0x260(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x5a0c
cltq
movq 0x170(%rsp), %rcx
movslq (%rcx,%rax,4), %r12
movq 0xd0(%rsp), %rcx
movq (%rcx,%rax,8), %rbx
movq (%rbx), %rdx
testq %rdx, %rdx
je 0x48e0
shlq $0x3, %rdx
movq %rbp, %rdi
leaq 0x13ee0(%rsp), %rsi
callq 0x31f0
movq (%rbx), %rax
jmp 0x48e2
xorl %eax, %eax
leaq (%rsp,%rax,8), %rsi
addq $0x660, %rsi            # imm = 0x660
movq %rbp, %r13
movq %rbp, %rdi
callq 0x5a14
movq %r12, %rdi
pushq $0x8
popq %rsi
callq 0x3190
movq %rax, %rbp
testl %r12d, %r12d
movl $0x0, %eax
cmovgl %r12d, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x4933
movq 0x8(%rbx), %rdx
movq 0x660(%rsp,%rcx,8), %rsi
movq (%rdx,%rsi,8), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
jmp 0x4914
movq %rbp, %rdi
movl %r12d, %esi
movq 0x78(%rsp), %rdx
callq 0x3d0b
movsd 0x28(%rsp), %xmm0
movapd %xmm0, %xmm1
addsd 0x66b3(%rip), %xmm1     # 0xb008
testb %al, %al
jne 0x495d
movapd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movq %rbp, %rdi
callq 0x3300
incl %r15d
movq %r14, %rbx
movq %r13, %rbp
jmp 0x4882
callq 0x3050
subq 0x58(%rsp), %rax
cqto
movl $0x3e8, %ecx            # imm = 0x3E8
idivq %rcx
movq %rax, %r12
movsd 0x50(%rsp), %xmm0
mulsd 0x28(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
leaq 0x1b8(%rsp), %rdi
callq 0x34c0
movsd 0x1b8(%rsp), %xmm0
leaq 0x460(%rsp), %rdi
movsd %xmm0, 0x58(%rsp)
callq 0x3450
movq %rax, %rdi
leaq 0x679d(%rip), %rsi      # 0xb178
callq 0x3280
movsd 0x28(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
movq %rax, %rdi
callq 0x3450
movq %rax, %rdi
leaq 0x677a(%rip), %rsi      # 0xb178
callq 0x3280
movq %rax, %rdi
movq %r12, %rsi
callq 0x3250
movq %rax, %rdi
leaq 0x6760(%rip), %rsi      # 0xb178
callq 0x3280
movq %rax, %rdi
callq 0x3140
incl %ebx
jmp 0x485e
leaq 0x260(%rsp), %rdi
callq 0x5b2e
movq 0xa0(%rsp), %r15
jmp 0x4a5f
leaq 0x6729(%rip), %rsi      # 0xb173
leaq 0x460(%rsp), %rdi
callq 0x3280
movq %rax, %rdi
callq 0x3140
leaq 0x460(%rsp), %rdi
callq 0x3390
leaq 0x66b9(%rip), %rdx      # 0xb12c
leaq 0x200(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x5905
leaq 0x1e0(%rsp), %rdi
movl 0x277a0(%rsp), %esi
callq 0x593d
leaq 0x220(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0x1e0(%rsp), %rdx
callq 0x589e
leaq 0x666c(%rip), %rdx      # 0xb12c
leaq 0xb0(%rsp), %rdi
leaq 0x220(%rsp), %rsi
callq 0x587f
leaq 0x1c0(%rsp), %rdi
movl 0x277a8(%rsp), %esi
callq 0x593d
leaq 0x260(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
callq 0x589e
leaq 0x666d(%rip), %rdx      # 0xb17a
leaq 0xf0(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x587f
leaq 0x260(%rsp), %rdi
callq 0x3120
leaq 0x1c0(%rsp), %rdi
callq 0x3120
leaq 0xb0(%rsp), %rdi
callq 0x3120
leaq 0x220(%rsp), %rdi
callq 0x3120
leaq 0x1e0(%rsp), %rdi
callq 0x3120
leaq 0x200(%rsp), %rdi
callq 0x3120
leaq 0x65bd(%rip), %rsi      # 0xb134
leaq 0xb0(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x5996
movq 0xc43d(%rip), %rdi      # 0x10fd0
leaq 0xb0(%rsp), %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
leaq 0x260(%rsp), %rdi
callq 0x3490
leaq 0x260(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3130
leaq 0x2d0(%rsp), %rdi
callq 0x30b0
testb %al, %al
je 0x4f95
movq 0xb0(%rsp), %rsi
leaq 0x6557(%rip), %rdi      # 0xb148
xorl %eax, %eax
callq 0x3040
leaq 0x6583(%rip), %rsi      # 0xb182
leaq 0x260(%rsp), %rdi
callq 0x3280
leaq 0x6583(%rip), %rsi      # 0xb196
movq %rax, %rdi
callq 0x3280
leaq 0x656a(%rip), %rsi      # 0xb18c
movq %rax, %rdi
callq 0x3280
leaq 0x656d(%rip), %rsi      # 0xb19e
movq %rax, %rdi
callq 0x3280
leaq 0x656b(%rip), %rsi      # 0xb1ab
movq %rax, %rdi
callq 0x3280
leaq 0x655f(%rip), %rsi      # 0xb1ae
leaq 0x260(%rsp), %rdi
callq 0x3280
leaq 0x6553(%rip), %rsi      # 0xb1b6
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
callq 0x3140
leaq 0x260(%rsp), %rdi
movsd 0x48(%rsp), %xmm0
callq 0x3450
leaq 0x64eb(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movapd 0x80(%rsp), %xmm0
callq 0x3450
leaq 0x64cb(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movsd 0x40(%rsp), %xmm0
callq 0x3450
leaq 0x64ae(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movsd 0x90(%rsp), %xmm0
callq 0x3450
leaq 0x648e(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movsd 0x50(%rsp), %xmm0
callq 0x3450
leaq 0x6471(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
leaq 0x260(%rsp), %rdi
movq %r15, %rsi
callq 0x3250
leaq 0x6452(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movl 0x277a0(%rsp), %esi
callq 0x34a0
leaq 0x6434(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
callq 0x3140
leaq 0x260(%rsp), %rdi
callq 0x3140
leaq 0x260(%rsp), %rdi
callq 0x3390
xorl %r14d, %r14d
pushq $0x10
popq %rbx
cvtsi2sd %r14d, %xmm0
movapd 0x80(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x4dc4
movq 0xd0(%rsp), %rax
movq (%rax,%r14,8), %rdi
cmpq $0x0, (%rdi)
js 0x4db7
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x4db7
movq %rax, %rdi
callq 0x3330
movq 0xd0(%rsp), %rax
movq (%rax,%r14,8), %rdi
movq %rbx, %rsi
callq 0x32b0
incq %r14
jmp 0x4d74
movq 0xc205(%rip), %rdi      # 0x10fd0
leaq 0x63f1(%rip), %rsi      # 0xb1c3
callq 0x3280
movq %rax, %rdi
movl 0x277a8(%rsp), %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3140
movq 0xc1db(%rip), %rdi      # 0x10fd0
leaq 0x63d6(%rip), %rsi      # 0xb1d2
callq 0x3280
movq %rax, %rdi
movapd 0x80(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xc1af(%rip), %rdi      # 0x10fd0
leaq 0x63bb(%rip), %rsi      # 0xb1e3
callq 0x3280
movq %rax, %rdi
movsd 0x40(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xc186(%rip), %rdi      # 0x10fd0
leaq 0x63ad(%rip), %rsi      # 0xb1fe
callq 0x3280
movq %rax, %rdi
movsd 0x38(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xc15d(%rip), %rdi      # 0x10fd0
leaq 0x63a2(%rip), %rsi      # 0xb21c
callq 0x3280
movq %rax, %rdi
movsd 0x58(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xc134(%rip), %rdi      # 0x10fd0
leaq 0x6398(%rip), %rsi      # 0xb23b
callq 0x3280
movq %rax, %rdi
movsd 0x50(%rsp), %xmm0
callq 0x3450
movq %rax, %rdi
callq 0x3140
movq 0xc10b(%rip), %rdi      # 0x10fd0
leaq 0x6374(%rip), %rsi      # 0xb240
callq 0x3280
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movq %rax, %rdi
callq 0x3140
leaq 0x260(%rsp), %rdi
callq 0x33c0
leaq 0xb0(%rsp), %rdi
callq 0x3120
leaq 0xf0(%rsp), %rdi
callq 0x3120
leaq 0x460(%rsp), %rdi
callq 0x33c0
leaq 0x110(%rsp), %rdi
callq 0x3120
leaq 0x240(%rsp), %rdi
callq 0x3120
leaq 0x130(%rsp), %rdi
callq 0x6280
leaq 0xd0(%rsp), %rdi
callq 0x646c
leaq 0x150(%rsp), %rdi
callq 0x6280
leaq 0x170(%rsp), %rdi
callq 0x6280
addq $0x27768, %rsp          # imm = 0x27768
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc051(%rip), %rdi      # 0x10fd0
leaq 0x6133(%rip), %rsi      # 0xb0b9
callq 0x3280
movq %rax, %rdi
callq 0x3140
jmp 0x4fb0
movq 0xc034(%rip), %rdi      # 0x10fd0
leaq 0x6116(%rip), %rsi      # 0xb0b9
callq 0x3280
movq %rax, %rdi
callq 0x3140
pushq $0x1
popq %rdi
callq 0x3310
jmp 0x5106
jmp 0x50ef
movq %rax, %rbx
jmp 0x512c
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x3120
jmp 0x4fdf
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x3120
jmp 0x4ff1
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x3120
jmp 0x5003
movq %rax, %rbx
leaq 0x220(%rsp), %rdi
callq 0x3120
jmp 0x5015
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x3120
leaq 0x200(%rsp), %rdi
jmp 0x5134
movq %rax, %rbx
jmp 0x5022
jmp 0x5106
jmp 0x50f4
movq %rax, %rbx
jmp 0x516d
movq %rax, %rbx
leaq 0x460(%rsp), %rdi
callq 0x3120
jmp 0x505b
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x3120
jmp 0x506d
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x3120
jmp 0x507f
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x3120
jmp 0x5091
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x3120
leaq 0xf0(%rsp), %rdi
callq 0x3120
leaq 0xb0(%rsp), %rdi
callq 0x3120
leaq 0x200(%rsp), %rdi
callq 0x3120
leaq 0x220(%rsp), %rdi
jmp 0x5175
movq %rax, %rbx
jmp 0x509e
movq %rax, %rbx
jmp 0x50ab
movq %rax, %rbx
jmp 0x50b8
movq %rax, %rbx
jmp 0x50c5
jmp 0x5184
jmp 0x50fe
jmp 0x5106
movq %rax, %rbx
jmp 0x511f
movq %rax, %rbx
jmp 0x5160
jmp 0x5184
movq %rax, %rbx
jmp 0x51a1
movq %rax, %rbx
jmp 0x5153
jmp 0x5184
jmp 0x5184
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x33c0
leaq 0xb0(%rsp), %rdi
callq 0x3120
leaq 0xf0(%rsp), %rdi
callq 0x3120
jmp 0x5153
jmp 0x5184
jmp 0x5184
jmp 0x5143
jmp 0x5143
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x5b2e
leaq 0x460(%rsp), %rdi
callq 0x33c0
leaq 0x110(%rsp), %rdi
callq 0x3120
leaq 0x240(%rsp), %rdi
callq 0x3120
jmp 0x5187
jmp 0x5184
jmp 0x5184
jmp 0x5184
jmp 0x5184
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x6280
leaq 0xd0(%rsp), %rdi
callq 0x646c
leaq 0x150(%rsp), %rdi
callq 0x6280
leaq 0x170(%rsp), %rdi
callq 0x6280
movq %rbx, %rdi
callq 0x34b0