// File: dtsaras[P]GCW/GCW.cpp
// Function: calculateInfluence_SSA(Graph&, HyperGraph&, std::vector<int, std::allocator<int>>&, int, double, double, float, float, int, long long, long long&, sampler<int>&, int)
bool calculateInfluence_SSA(Graph & g, HyperGraph & hg, vector<int> & seeds, int t, double expected, double epsilon_1, float epsilon_2, float delta, int m, long long int maxSamples, long long int & checkSam, sampler<int> &samp, int p){
	long long  counter = 0;
	int n = g.getSize();
	unsigned int k = seeds.size();
	double f = log2(n*(log(2/delta)+lgamma(n+1)-lgamma(k+1)-lgamma(n-k+1))/(k*log(2/delta)));
	double upperBound = 1+(2+2*epsilon_2/3)*(1 + epsilon_2)*(log(3/delta)+log(f))/(epsilon_2*epsilon_2);
	vector<unsigned int> link(n+1,k);
	int degree=0;
	vector<float> benefits(n,0);
	for (unsigned int i = 0; i < k;++i){
		link[seeds[i]] = i;
	}
	vector<bool> maxSeed(t, false);
	omp_set_num_threads(t);
	#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 && degree < upperBound){
	            maxSeed[id]=hg.pollingLT(g,link,k,visit,visit_mark, samp, p);
				#pragma omp critical
				{
                	counter++;
					if (maxSeed[id]){
						degree++;
					}
				}
        	}
		} 
		else {
			while (counter <= maxSamples && degree < upperBound){
                maxSeed[id]=hg.pollingIC(g,link,k,visit,visit_mark, samp, p);
                #pragma omp critical
                {
                    counter++;
                    if (maxSeed[id]){
                        degree++;
                    }
                }
            }
		}
	}
	checkSam += counter;

	if (expected <= (1 + epsilon_1)*((double)degree*n/(double)counter)){
		return true;
	}
	return false;
}

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movl 0x2b0(%rsp), %eax
movq 0x2a8(%rsp), %rax
movq 0x2a0(%rsp), %rax
movq %rdi, 0x288(%rsp)
movq %rsi, 0x280(%rsp)
movq %rdx, 0x278(%rsp)
movl %ecx, 0x274(%rsp)
movsd %xmm0, 0x268(%rsp)
movsd %xmm1, 0x260(%rsp)
movss %xmm2, 0x25c(%rsp)
movss %xmm3, 0x258(%rsp)
movl %r8d, 0x254(%rsp)
movq %r9, 0x248(%rsp)
movq $0x0, 0x240(%rsp)
movq 0x288(%rsp), %rdi
callq 0x1db70
movl %eax, 0x23c(%rsp)
movq 0x278(%rsp), %rdi
callq 0xe3d0
movl %eax, 0x238(%rsp)
cvtsi2sdl 0x23c(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movss 0x258(%rsp), %xmm1
movss 0x2ba7c(%rip), %xmm0    # 0x32044
movss %xmm0, 0xdc(%rsp)
divss %xmm1, %xmm0
callq 0xed80
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl 0x23c(%rsp), %edi
incl %edi
callq 0xeda0
movaps %xmm0, %xmm1
movsd 0xa8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movl 0x238(%rsp), %edi
incl %edi
callq 0xedc0
movaps %xmm0, %xmm1
movsd 0xb0(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
movl 0x23c(%rsp), %edi
movl 0x238(%rsp), %eax
subl %eax, %edi
incl %edi
callq 0xedc0
movsd 0xb8(%rsp), %xmm2
movsd 0xc0(%rsp), %xmm1
movaps %xmm0, %xmm3
movss 0xdc(%rsp), %xmm0
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
movsd %xmm1, 0xd0(%rsp)
movl 0x238(%rsp), %eax
cvtsi2ss %rax, %xmm1
movss %xmm1, 0xcc(%rsp)
movss 0x258(%rsp), %xmm1
divss %xmm1, %xmm0
callq 0xed80
movss 0xcc(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xd0(%rsp), %xmm0
mulss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x46c0
movss 0xdc(%rsp), %xmm3
movsd %xmm0, 0x230(%rsp)
movss 0x25c(%rsp), %xmm2
movaps %xmm2, %xmm1
addss %xmm1, %xmm1
movss 0x2b956(%rip), %xmm0    # 0x32048
divss %xmm0, %xmm1
addss %xmm3, %xmm1
movss 0x2b94a(%rip), %xmm3    # 0x3204c
addss %xmm3, %xmm2
mulss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0xe8(%rsp)
movss 0x258(%rsp), %xmm1
divss %xmm1, %xmm0
callq 0xed80
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0x230(%rsp), %xmm0
callq 0x4340
movsd 0xe0(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xe8(%rsp), %xmm0
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movss 0x25c(%rsp), %xmm1
mulss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
movsd 0x2b88a(%rip), %xmm1    # 0x32008
addsd %xmm1, %xmm0
movsd %xmm0, 0x228(%rsp)
movl 0x23c(%rsp), %eax
incl %eax
cltq
movq %rax, 0xf0(%rsp)
leaq 0x20f(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0xece0
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rcx
leaq 0x210(%rsp), %rdi
leaq 0x238(%rsp), %rdx
callq 0xecf0
jmp 0x67da
leaq 0x20f(%rsp), %rdi
callq 0xed70
movl $0x0, 0x1f8(%rsp)
movslq 0x23c(%rsp), %rax
movq %rax, 0x98(%rsp)
movl $0x0, 0x1dc(%rsp)
leaq 0x1db(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xee70
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rcx
leaq 0x1e0(%rsp), %rdi
leaq 0x1dc(%rsp), %rdx
callq 0xee80
jmp 0x6849
leaq 0x1db(%rsp), %rdi
callq 0xef00
movl $0x0, 0x1d4(%rsp)
movl 0x1d4(%rsp), %eax
cmpl 0x238(%rsp), %eax
jae 0x6911
movl 0x1d4(%rsp), %eax
movl %eax, 0x94(%rsp)
movq 0x278(%rsp), %rdi
movl 0x1d4(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movslq (%rax), %rsi
leaq 0x210(%rsp), %rdi
callq 0xee00
movl 0x94(%rsp), %ecx
movl %ecx, (%rax)
movl 0x1d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1d4(%rsp)
jmp 0x6861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x20f(%rsp), %rdi
callq 0xed70
jmp 0x6ee4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x1db(%rsp), %rdi
callq 0xef00
jmp 0x6ed7
movslq 0x274(%rsp), %rax
movq %rax, 0x80(%rsp)
movb $0x0, 0x1a7(%rsp)
leaq 0x1a6(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0xe220
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rcx
leaq 0x1a8(%rsp), %rdi
leaq 0x1a7(%rsp), %rdx
callq 0xe230
jmp 0x6965
leaq 0x1a6(%rsp), %rdi
callq 0xe2b0
movl 0x274(%rsp), %edi
callq 0xe170
jmp 0x6980
movl 0x23c(%rsp), %eax
incl %eax
cltq
movq %rax, 0x70(%rsp)
movb $0x0, 0x177(%rsp)
leaq 0x176(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xe220
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
leaq 0x178(%rsp), %rdi
leaq 0x177(%rsp), %rdx
callq 0xe230
jmp 0x69cb
leaq 0x176(%rsp), %rdi
callq 0xe2b0
movslq 0x23c(%rsp), %rax
movq %rax, 0x60(%rsp)
movl $0x0, 0x154(%rsp)
leaq 0x153(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xe180
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rcx
leaq 0x158(%rsp), %rdi
leaq 0x154(%rsp), %rdx
callq 0xe190
jmp 0x6a23
leaq 0x153(%rsp), %rdi
callq 0xe210
callq 0xee20
movl %eax, 0x5c(%rsp)
jmp 0x6a3b
movl 0x5c(%rsp), %eax
movl %eax, 0x14c(%rsp)
cmpl $0x0, 0x254(%rsp)
jne 0x6c73
jmp 0x6a56
movq 0x240(%rsp), %rcx
xorl %eax, %eax
cmpq 0x248(%rsp), %rcx
movb %al, 0x5b(%rsp)
jg 0x6a8b
cvtsi2sdl 0x1f8(%rsp), %xmm1
movsd 0x228(%rsp), %xmm0
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0x5b(%rsp)
movb 0x5b(%rsp), %al
testb $0x1, %al
jne 0x6a98
jmp 0x6c6e
movq 0x280(%rsp), %rdi
movq 0x288(%rsp), %rsi
movl 0x238(%rsp), %ecx
movq 0x2a8(%rsp), %rdx
movl 0x2b0(%rsp), %r8d
movq %rsp, %rax
movl %r8d, 0x8(%rax)
movq %rdx, (%rax)
leaq 0x210(%rsp), %rdx
leaq 0x178(%rsp), %r8
leaq 0x158(%rsp), %r9
callq 0x1fa90
movb %al, 0x5a(%rsp)
jmp 0x6aec
movslq 0x14c(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0xe790
movq %rdx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x6b0d
movb 0x5a(%rsp), %al
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x138(%rsp)
movq %rcx, 0x140(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x138(%rsp), %rdi
callq 0xe7f0
movq 0x240(%rsp), %rax
incq %rax
movq %rax, 0x240(%rsp)
movslq 0x14c(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0xe790
movq %rdx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x6b72
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x128(%rsp)
movq %rax, 0x130(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x6ba2
jmp 0x6c69
movl 0x1f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f8(%rsp)
jmp 0x6c69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x1a6(%rsp), %rdi
callq 0xe2b0
jmp 0x6eca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x6ebd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x176(%rsp), %rdi
callq 0xe2b0
jmp 0x6ebd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x153(%rsp), %rdi
callq 0xe210
jmp 0x6e63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x158(%rsp), %rdi
callq 0xe2e0
jmp 0x6e63
jmp 0x6a56
jmp 0x6dd6
jmp 0x6c75
movq 0x240(%rsp), %rcx
xorl %eax, %eax
cmpq 0x248(%rsp), %rcx
movb %al, 0x37(%rsp)
jg 0x6caa
cvtsi2sdl 0x1f8(%rsp), %xmm1
movsd 0x228(%rsp), %xmm0
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x6cb7
jmp 0x6dd4
movq 0x280(%rsp), %rdi
movq 0x288(%rsp), %rsi
movl 0x238(%rsp), %ecx
movq 0x2a8(%rsp), %rdx
movl 0x2b0(%rsp), %r8d
movq %rsp, %rax
movl %r8d, 0x8(%rax)
movq %rdx, (%rax)
leaq 0x210(%rsp), %rdx
leaq 0x178(%rsp), %r8
leaq 0x158(%rsp), %r9
callq 0x20cf0
movb %al, 0x36(%rsp)
jmp 0x6d0b
movslq 0x14c(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0xe790
movq %rdx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x6d2c
movb 0x36(%rsp), %al
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq %rdx, 0x118(%rsp)
movq %rcx, 0x120(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x118(%rsp), %rdi
callq 0xe7f0
movq 0x240(%rsp), %rax
incq %rax
movq %rax, 0x240(%rsp)
movslq 0x14c(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0xe790
movq %rdx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
jmp 0x6d91
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x108(%rsp)
movq %rax, 0x110(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x6dbe
jmp 0x6dcf
movl 0x1f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f8(%rsp)
jmp 0x6c75
jmp 0x6dd6
leaq 0x158(%rsp), %rdi
callq 0xe2e0
leaq 0x178(%rsp), %rdi
callq 0xe3a0
movq 0x240(%rsp), %rcx
movq 0x2a0(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movsd 0x268(%rsp), %xmm1
movsd 0x2b1f1(%rip), %xmm0    # 0x32008
addsd 0x260(%rsp), %xmm0
cvtsi2sdl 0x1f8(%rsp), %xmm2
cvtsi2sdl 0x23c(%rsp), %xmm3
mulsd %xmm3, %xmm2
cvtsi2sdq 0x240(%rsp), %xmm3
divsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x6e72
movb $0x1, 0x297(%rsp)
movl $0x1, 0x104(%rsp)
jmp 0x6e85
leaq 0x178(%rsp), %rdi
callq 0xe3a0
jmp 0x6ebd
movb $0x0, 0x297(%rsp)
movl $0x1, 0x104(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0xe3a0
leaq 0x1e0(%rsp), %rdi
callq 0xef10
leaq 0x210(%rsp), %rdi
callq 0xe340
movb 0x297(%rsp), %al
andb $0x1, %al
addq $0x298, %rsp            # imm = 0x298
retq
leaq 0x1a8(%rsp), %rdi
callq 0xe3a0
leaq 0x1e0(%rsp), %rdi
callq 0xef10
leaq 0x210(%rsp), %rdi
callq 0xe340
movq 0x200(%rsp), %rdi
callq 0x4690
nopw %cs:(%rax,%rax)