// File: dtsaras[P]GCW/GCW.cpp
// Function: calculateInfluence_DSSA(HyperGraph&, Graph&, std::vector<int, std::allocator<int>>&, int, double&, float, float, int, long long, int, sampler<int>&, int)
bool calculateInfluence_DSSA(HyperGraph & hg, Graph & g, vector<int> & seeds, int t, double & deg, float epsilon, float delta, int m, long long int maxSamples, int iter, sampler<int> &samp, int p){
	long long  counter = 0;
	int n = g.getSize();
	// cout << "!!!!!!!!!!!!!!!! 1" << endl;
	unsigned k = seeds.size();
	vector<unsigned int> link(n + 1, seeds.size());
	double f = (log(6/delta)+lgamma(n+1)-lgamma(k+1)-lgamma(n-k+1))*n/(k*log(6*log2(n)/delta));
	double lambda1 = 1+(1+epsilon)*(2+2*epsilon/3)*log(3*log2(f)/delta)/(epsilon*epsilon);
	double degree=0;
	// cout << "!!!!!!!!!!!!!!!! 2" << endl;
	for (unsigned int i = 0; i < k;++i){
		link[seeds[i]] = i;
	}
	vector<bool> maxSeed(t, false);
	omp_set_num_threads(t);
	// cout << "!!!!!!!!!!!!!!!! 3" << endl;
	#pragma omp parallel
	{
		vector<bool> visit(n+1,false);
		vector<int> visit_mark(n,0);
		int id = omp_get_thread_num();

		if (m == 0){
			while(counter < maxSamples){
				// cout << "iteration: " << counter << endl; // del
				// cout << "!!!!!!!!!!!!!!!! 4" << endl;
				maxSeed[id]=hg.pollingLT2(g,link,k,visit,visit_mark, samp, p);
				// cout << "!!!!!!!!!!!!!!!! 5" << endl;
				#pragma omp critical
				{
					counter += 1;
					if (maxSeed[id]){
						degree++;
					}
				}
				// cout << "!!!!!!!!!!!!!!!! 6" << endl;
				// cin.ignore(numeric_limits <streamsize>::max(), '\n');
			}
		}
		else {
			while(counter < maxSamples){
				maxSeed[id]=hg.pollingIC2(g,link,k,visit,visit_mark, samp, p);
	            #pragma omp critical
	            {
					counter += 1;
	                if (maxSeed[id]){
	                    degree++;
	                }
	            }
        	}
		}	
	}
	// cout << "!!!!!!!!!!!!!!!! 7" << endl;

    if (degree >= lambda1){
		double epsilon_1 = (deg*n/maxSamples)/(degree*n/counter) - 1;
        double epsilon_2 = epsilon*sqrt(n*(1+epsilon)/(degree*n*pow(2,iter-1)/counter));
		double epsilon_3 = epsilon*sqrt(n*(1+epsilon)*(1-1/exp(1)-epsilon)/((1+epsilon/3)*degree*n*pow(2,iter-1)/counter));
	    if ((epsilon_1 + epsilon_2 + epsilon_1*epsilon_2)*(1-1/exp(1)-epsilon) + epsilon_3*(1-1/exp(1)) <= epsilon){
			return true;
        }
    }

	hg.updateDeg();
	// cout << "!!!!!!!!!!!!!!!! 8" << endl;
	return false;
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movl 0x328(%rsp), %eax
movq 0x320(%rsp), %rax
movl 0x318(%rsp), %eax
movq 0x310(%rsp), %rax
movq %rdi, 0x2f8(%rsp)
movq %rsi, 0x2f0(%rsp)
movq %rdx, 0x2e8(%rsp)
movl %ecx, 0x2e4(%rsp)
movq %r8, 0x2d8(%rsp)
movss %xmm0, 0x2d4(%rsp)
movss %xmm1, 0x2d0(%rsp)
movl %r9d, 0x2cc(%rsp)
movq $0x0, 0x2c0(%rsp)
movq 0x2f0(%rsp), %rdi
callq 0x1db70
movl %eax, 0x2bc(%rsp)
movq 0x2e8(%rsp), %rdi
callq 0xe3d0
movl %eax, 0x2b8(%rsp)
movl 0x2bc(%rsp), %eax
incl %eax
cltq
movq %rax, 0x170(%rsp)
movq 0x2e8(%rsp), %rdi
callq 0xe3d0
movl %eax, 0x29c(%rsp)
leaq 0x29b(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0xece0
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rcx
leaq 0x2a0(%rsp), %rdi
leaq 0x29c(%rsp), %rdx
callq 0xecf0
jmp 0x595d
leaq 0x29b(%rsp), %rdi
callq 0xed70
movss 0x2d0(%rsp), %xmm1
movss 0x2c6c5(%rip), %xmm0    # 0x32040
divss %xmm1, %xmm0
callq 0xed80
movss %xmm0, 0x16c(%rsp)
jmp 0x598f
movss 0x16c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x158(%rsp)
movl 0x2bc(%rsp), %edi
incl %edi
callq 0xeda0
movsd %xmm0, 0x160(%rsp)
jmp 0x59be
movsd 0x160(%rsp), %xmm1
movsd 0x158(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x148(%rsp)
movl 0x2b8(%rsp), %edi
incl %edi
callq 0xedc0
movsd %xmm0, 0x150(%rsp)
jmp 0x59f6
movsd 0x150(%rsp), %xmm1
movsd 0x148(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x138(%rsp)
movl 0x2bc(%rsp), %edi
movl 0x2b8(%rsp), %eax
subl %eax, %edi
incl %edi
callq 0xedc0
movsd %xmm0, 0x140(%rsp)
jmp 0x5a37
movsd 0x140(%rsp), %xmm1
movsd 0x138(%rsp), %xmm0
subsd %xmm1, %xmm0
movl 0x2bc(%rsp), %edi
cvtsi2sd %edi, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x120(%rsp)
movl 0x2b8(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x128(%rsp)
callq 0xede0
movsd %xmm0, 0x130(%rsp)
jmp 0x5a8a
movsd 0x130(%rsp), %xmm1
movsd 0x2c57d(%rip), %xmm0    # 0x32018
mulsd %xmm1, %xmm0
movss 0x2d0(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x4340
movsd 0x128(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x120(%rsp), %xmm0
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x280(%rsp)
movss 0x2c569(%rip), %xmm0    # 0x3204c
addss 0x2d4(%rsp), %xmm0
movss 0x2c550(%rip), %xmm2    # 0x32044
mulss 0x2d4(%rsp), %xmm2
movss 0x2c543(%rip), %xmm1    # 0x32048
divss %xmm1, %xmm2
movss 0x2c533(%rip), %xmm1    # 0x32044
addss %xmm2, %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x280(%rsp), %xmm0
callq 0x46c0
movaps %xmm0, %xmm1
movsd 0x2c4d1(%rip), %xmm0    # 0x32010
mulsd %xmm1, %xmm0
movss 0x2d0(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x4340
movsd 0x118(%rsp), %xmm1
mulsd %xmm0, %xmm1
movss 0x2d4(%rsp), %xmm0
mulss 0x2d4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
divsd %xmm0, %xmm1
movsd 0x2c480(%rip), %xmm0    # 0x32008
addsd %xmm1, %xmm0
movsd %xmm0, 0x278(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x270(%rsp)
movl $0x0, 0x26c(%rsp)
movl 0x26c(%rsp), %eax
cmpl 0x2b8(%rsp), %eax
jae 0x5c4f
movl 0x26c(%rsp), %eax
movl %eax, 0x114(%rsp)
movq 0x2e8(%rsp), %rdi
movl 0x26c(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movslq (%rax), %rsi
leaq 0x2a0(%rsp), %rdi
callq 0xee00
movl 0x114(%rsp), %ecx
movl %ecx, (%rax)
movl 0x26c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x26c(%rsp)
jmp 0x5bac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x29b(%rsp), %rdi
callq 0xed70
jmp 0x64f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x64e3
movslq 0x2e4(%rsp), %rax
movq %rax, 0x100(%rsp)
movb $0x0, 0x23f(%rsp)
leaq 0x23e(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0xe220
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rcx
leaq 0x240(%rsp), %rdi
leaq 0x23f(%rsp), %rdx
callq 0xe230
jmp 0x5ca3
leaq 0x23e(%rsp), %rdi
callq 0xe2b0
movl 0x2e4(%rsp), %edi
callq 0xe170
jmp 0x5cbe
movl 0x2bc(%rsp), %eax
incl %eax
cltq
movq %rax, 0xf0(%rsp)
movb $0x0, 0x20f(%rsp)
leaq 0x20e(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0xe220
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rcx
leaq 0x210(%rsp), %rdi
leaq 0x20f(%rsp), %rdx
callq 0xe230
jmp 0x5d15
leaq 0x20e(%rsp), %rdi
callq 0xe2b0
movslq 0x2bc(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl $0x0, 0x1ec(%rsp)
leaq 0x1eb(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0xe180
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rcx
leaq 0x1f0(%rsp), %rdi
leaq 0x1ec(%rsp), %rdx
callq 0xe190
jmp 0x5d79
leaq 0x1eb(%rsp), %rdi
callq 0xe210
callq 0xee20
movl %eax, 0xdc(%rsp)
jmp 0x5d94
movl 0xdc(%rsp), %eax
movl %eax, 0x1e4(%rsp)
cmpl $0x0, 0x2cc(%rsp)
jne 0x5fca
jmp 0x5db2
movq 0x2c0(%rsp), %rax
cmpq 0x310(%rsp), %rax
jge 0x5fc5
movq 0x2f8(%rsp), %rdi
movq 0x2f0(%rsp), %rsi
movl 0x2b8(%rsp), %ecx
movq 0x320(%rsp), %rdx
movl 0x328(%rsp), %r8d
movq %rsp, %rax
movl %r8d, 0x8(%rax)
movq %rdx, (%rax)
leaq 0x2a0(%rsp), %rdx
leaq 0x210(%rsp), %r8
leaq 0x1f0(%rsp), %r9
callq 0x200a0
movb %al, 0xdb(%rsp)
jmp 0x5e1f
movslq 0x1e4(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xe790
movq %rdx, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
jmp 0x5e46
movb 0xdb(%rsp), %al
movq 0xc8(%rsp), %rcx
movq 0xd0(%rsp), %rdx
movq %rdx, 0x1d0(%rsp)
movq %rcx, 0x1d8(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x1d0(%rsp), %rdi
callq 0xe7f0
movq 0x2c0(%rsp), %rax
incq %rax
movq %rax, 0x2c0(%rsp)
movslq 0x1e4(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xe790
movq %rdx, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
jmp 0x5eba
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq %rcx, 0x1c0(%rsp)
movq %rax, 0x1c8(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x5ef0
jmp 0x5fc0
movsd 0x2c110(%rip), %xmm0    # 0x32008
addsd 0x270(%rsp), %xmm0
movsd %xmm0, 0x270(%rsp)
jmp 0x5fc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x23e(%rsp), %rdi
callq 0xe2b0
jmp 0x64e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x64d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x20e(%rsp), %rdi
callq 0xe2b0
jmp 0x64d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x1eb(%rsp), %rdi
callq 0xe210
jmp 0x6478
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0xe2e0
jmp 0x6478
jmp 0x5db2
jmp 0x6128
jmp 0x5fcc
movq 0x2c0(%rsp), %rax
cmpq 0x310(%rsp), %rax
jge 0x6126
movq 0x2f8(%rsp), %rdi
movq 0x2f0(%rsp), %rsi
movl 0x2b8(%rsp), %ecx
movq 0x320(%rsp), %rdx
movl 0x328(%rsp), %r8d
movq %rsp, %rax
movl %r8d, 0x8(%rax)
movq %rdx, (%rax)
leaq 0x2a0(%rsp), %rdx
leaq 0x210(%rsp), %r8
leaq 0x1f0(%rsp), %r9
callq 0x208a0
movb %al, 0xb7(%rsp)
jmp 0x6039
movslq 0x1e4(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xe790
movq %rdx, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0x6060
movb 0xb7(%rsp), %al
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rdx
movq %rdx, 0x1b0(%rsp)
movq %rcx, 0x1b8(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x1b0(%rsp), %rdi
callq 0xe7f0
movq 0x2c0(%rsp), %rax
incq %rax
movq %rax, 0x2c0(%rsp)
movslq 0x1e4(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xe790
movq %rdx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
jmp 0x60d4
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rcx, 0x1a0(%rsp)
movq %rax, 0x1a8(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x6107
jmp 0x6121
movsd 0x2bef9(%rip), %xmm0    # 0x32008
addsd 0x270(%rsp), %xmm0
movsd %xmm0, 0x270(%rsp)
jmp 0x5fcc
jmp 0x6128
leaq 0x1f0(%rsp), %rdi
callq 0xe2e0
leaq 0x210(%rsp), %rdi
callq 0xe3a0
movsd 0x270(%rsp), %xmm0
ucomisd 0x278(%rsp), %xmm0
jb 0x6489
movq 0x2d8(%rsp), %rax
movsd (%rax), %xmm0
cvtsi2sdl 0x2bc(%rsp), %xmm2
mulsd %xmm2, %xmm0
cvtsi2sdq 0x310(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x270(%rsp), %xmm1
mulsd %xmm2, %xmm1
cvtsi2sdq 0x2c0(%rsp), %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0x2be78(%rip), %xmm1    # 0x32020
addsd %xmm1, %xmm0
movsd %xmm0, 0x198(%rsp)
movss 0x2d4(%rsp), %xmm1
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movl 0x2bc(%rsp), %eax
cvtsi2ss %eax, %xmm0
movss 0x2be71(%rip), %xmm2    # 0x3204c
addss %xmm2, %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x270(%rsp), %xmm0
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movl 0x318(%rsp), %esi
decl %esi
movl $0x2, %edi
callq 0xee30
movsd %xmm0, 0x88(%rsp)
jmp 0x6225
movsd 0x78(%rsp), %xmm0
movsd 0x88(%rsp), %xmm2
movsd 0x80(%rsp), %xmm1
mulsd %xmm2, %xmm1
cvtsi2sdq 0x2c0(%rsp), %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x4330
movaps %xmm0, %xmm1
movsd 0x70(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x190(%rsp)
movss 0x2d4(%rsp), %xmm1
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
cvtsi2ssl 0x2bc(%rsp), %xmm0
movss 0x2bdba(%rip), %xmm2    # 0x3204c
addss %xmm2, %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0x68(%rsp)
jmp 0x62b6
movsd 0x60(%rsp), %xmm1
movsd 0x68(%rsp), %xmm3
movsd 0x2bd3e(%rip), %xmm2    # 0x32008
movaps %xmm2, %xmm0
divsd %xmm3, %xmm0
subsd %xmm0, %xmm2
movss 0x2d4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm3
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
movsd %xmm1, 0x40(%rsp)
movss 0x2bd50(%rip), %xmm1    # 0x32048
divss %xmm1, %xmm0
movss 0x2bd48(%rip), %xmm1    # 0x3204c
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x270(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x2bc(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x318(%rsp), %esi
decl %esi
movl $0x2, %edi
callq 0xee30
movsd %xmm0, 0x50(%rsp)
jmp 0x6347
movsd 0x40(%rsp), %xmm0
movsd 0x50(%rsp), %xmm2
movsd 0x48(%rsp), %xmm1
mulsd %xmm2, %xmm1
cvtsi2sdq 0x2c0(%rsp), %xmm2
divsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x4330
movaps %xmm0, %xmm1
movsd 0x58(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x188(%rsp)
movsd 0x198(%rsp), %xmm0
movsd 0x190(%rsp), %xmm2
movaps %xmm0, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0x38(%rsp)
jmp 0x63c3
movsd 0x38(%rsp), %xmm2
movsd 0x2bc37(%rip), %xmm0    # 0x32008
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movss 0x2d4(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x188(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0x28(%rsp)
jmp 0x6414
movsd 0x18(%rsp), %xmm2
movsd 0x30(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm3
movsd 0x2bbd4(%rip), %xmm4    # 0x32008
divsd %xmm3, %xmm4
movsd 0x2bbc8(%rip), %xmm3    # 0x32008
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movss 0x2d4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jb 0x6487
movb $0x1, 0x307(%rsp)
movl $0x1, 0x184(%rsp)
jmp 0x64ab
leaq 0x210(%rsp), %rdi
callq 0xe3a0
jmp 0x64d6
jmp 0x6489
movq 0x2f8(%rsp), %rdi
callq 0x1f660
jmp 0x6498
movb $0x0, 0x307(%rsp)
movl $0x1, 0x184(%rsp)
leaq 0x240(%rsp), %rdi
callq 0xe3a0
leaq 0x2a0(%rsp), %rdi
callq 0xe340
movb 0x307(%rsp), %al
andb $0x1, %al
addq $0x308, %rsp            # imm = 0x308
retq
leaq 0x240(%rsp), %rdi
callq 0xe3a0
leaq 0x2a0(%rsp), %rdi
callq 0xe340
movq 0x290(%rsp), %rdi
callq 0x4690
nopl (%rax)