// File: dtsaras[P]GCW/GCW.cpp
// Function: SSA(Graph&, int, int, int, std::vector<int, std::allocator<int>>&, float, float, sampler<int>&, int, int)
void SSA(Graph & g, int n, int k, int t, vector<int> &seeds, float epsilon, float delta, sampler<int> &samp, int p, int m){
	HyperGraph hg(n);
	vector<double> degree(k+1,0);

	double epsilon_1= epsilon/(2*(1-1/exp(1)-epsilon));
	double epsilon_2= epsilon/(3*(1-1/exp(1)-epsilon));
	double epsilon_3= (epsilon - (epsilon_1 - epsilon_2 - epsilon_1*epsilon_2)*(1-1/exp(1)-epsilon))/(1-1/exp(1));

	double f = log2(n*(log(2/delta)+lgammal(n+1)-lgammal(k+1)-lgammal(n-k+1))/(k*log(2/delta)));

	double degreeRequired = (2+2*epsilon_3/3)*(1+epsilon_1)*(1+epsilon_2)*log(3*f/delta)/(epsilon_3*epsilon_3);

	long long int curSamples = (long long) degreeRequired;
	long long int totalSamples = 0;
	long long int checkSam = 0;

	while (true){
		seeds.clear();
		addHyperedge(g,hg,t,curSamples,m, samp, p);
		curSamples *= 2;
		totalSamples = hg.getNumEdge();
		buildSeedSet(hg,seeds,n,k,degree);
		if (degree[k] < degreeRequired){
			continue;
		}
		
		if (calculateInfluence_SSA(g, hg, seeds, t, (double)degree[k]*n/(double)hg.getNumEdge(), epsilon_1, epsilon_2, delta, m, totalSamples*2*(1+epsilon_2)/(1-epsilon_2)*(epsilon_3*epsilon_3)/(epsilon_2*epsilon_2), checkSam, samp, p)){
			break;
		}
	}
}

// Assembly:
subq $0xbd8, %rsp            # imm = 0xBD8
movl 0xbe8(%rsp), %eax
movl 0xbe0(%rsp), %eax
movq %rdi, 0xbd0(%rsp)
movl %esi, 0xbcc(%rsp)
movl %edx, 0xbc8(%rsp)
movl %ecx, 0xbc4(%rsp)
movq %r8, 0xbb8(%rsp)
movss %xmm0, 0xbb4(%rsp)
movss %xmm1, 0xbb0(%rsp)
movq %r9, 0xba8(%rsp)
movl 0xbcc(%rsp), %esi
leaq 0x1a0(%rsp), %rdi
callq 0x1f550
movl 0xbc8(%rsp), %eax
incl %eax
cltq
movq %rax, 0xf8(%rsp)
movq $0x0, 0x180(%rsp)
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0xef70
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rcx
leaq 0x188(%rsp), %rdi
leaq 0x180(%rsp), %rdx
callq 0xef80
jmp 0x75e3
leaq 0x17f(%rsp), %rdi
callq 0xf000
movss 0xbb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xe8(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0xf0(%rsp)
jmp 0x761b
movsd 0xe8(%rsp), %xmm0
movsd 0xf0(%rsp), %xmm3
movsd 0x2a9d3(%rip), %xmm1    # 0x32008
movaps %xmm1, %xmm2
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
movss 0xbb4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
subsd %xmm2, %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x160(%rsp)
movss 0xbb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xd8(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0xe0(%rsp)
jmp 0x768d
movsd 0xd8(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm3
movsd 0x2a961(%rip), %xmm1    # 0x32008
movaps %xmm1, %xmm2
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
movss 0xbb4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
subsd %xmm2, %xmm1
movsd 0x2a945(%rip), %xmm2    # 0x32010
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x158(%rsp)
movss 0xbb4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0x160(%rsp), %xmm1
movsd 0x158(%rsp), %xmm2
movaps %xmm1, %xmm0
subsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0xd0(%rsp)
jmp 0x7731
movsd 0xc0(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
movsd 0xd0(%rsp), %xmm4
movsd 0x2a8b4(%rip), %xmm2    # 0x32008
movaps %xmm2, %xmm3
divsd %xmm4, %xmm3
subsd %xmm3, %xmm2
movss 0xbb4(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movl $0x1, %edi
callq 0xee50
movsd %xmm0, 0xb8(%rsp)
jmp 0x7796
movsd 0xb0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm3
movsd 0x2a858(%rip), %xmm1    # 0x32008
movaps %xmm1, %xmm2
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x150(%rsp)
movl 0xbcc(%rsp), %eax
movl %eax, 0x124(%rsp)
fildl 0x124(%rsp)
fstpt 0xa0(%rsp)
movss 0xbb0(%rsp), %xmm1
movss 0x2a84f(%rip), %xmm0    # 0x32044
divss %xmm1, %xmm0
callq 0xed80
movss %xmm0, 0xac(%rsp)
jmp 0x7809
movss 0xac(%rsp), %xmm0
movss %xmm0, 0x114(%rsp)
flds 0x114(%rsp)
fstpt 0x68(%rsp)
movl 0xbcc(%rsp), %eax
incl %eax
movl %eax, 0x118(%rsp)
fildl 0x118(%rsp)
movq %rsp, %rax
fstpt (%rax)
callq 0x41f0
fldt 0x68(%rsp)
faddp %st, %st(1)
fstpt 0x74(%rsp)
movl 0xbc8(%rsp), %eax
incl %eax
movl %eax, 0x11c(%rsp)
fildl 0x11c(%rsp)
movq %rsp, %rax
fstpt (%rax)
callq 0x41f0
fldt 0x74(%rsp)
fsubp %st, %st(1)
fstpt 0x80(%rsp)
movl 0xbcc(%rsp), %eax
movl 0xbc8(%rsp), %ecx
subl %ecx, %eax
incl %eax
movl %eax, 0x120(%rsp)
fildl 0x120(%rsp)
movq %rsp, %rax
fstpt (%rax)
callq 0x41f0
fldt 0x80(%rsp)
fldt 0xa0(%rsp)
fxch %st(1)
fsubp %st, %st(2)
fmulp %st, %st(1)
fstpt 0x8c(%rsp)
cvtsi2ssl 0xbc8(%rsp), %xmm0
movss %xmm0, 0x98(%rsp)
movss 0xbb0(%rsp), %xmm1
movss 0x2a75d(%rip), %xmm0    # 0x32044
divss %xmm1, %xmm0
callq 0xed80
movss %xmm0, 0x9c(%rsp)
jmp 0x78fb
fldt 0x8c(%rsp)
movss 0x9c(%rsp), %xmm1
movss 0x98(%rsp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0x110(%rsp)
flds 0x110(%rsp)
fdivrp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0xf0c0
fstpt 0x5c(%rsp)
jmp 0x793a
fldt 0x5c(%rsp)
fstpl 0x108(%rsp)
movsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x148(%rsp)
movsd 0x2a6c9(%rip), %xmm1    # 0x32028
mulsd 0x150(%rsp), %xmm1
movsd 0x2a6a0(%rip), %xmm0    # 0x32010
divsd %xmm0, %xmm1
movsd 0x2a6ac(%rip), %xmm0    # 0x32028
addsd %xmm1, %xmm0
movsd 0x2a680(%rip), %xmm1    # 0x32008
addsd 0x160(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x2a66b(%rip), %xmm1    # 0x32008
addsd 0x158(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x2a658(%rip), %xmm0    # 0x32010
mulsd 0x148(%rsp), %xmm0
movss 0xbb0(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
callq 0x4340
movaps %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x150(%rsp), %xmm1
mulsd 0x150(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x140(%rsp)
cvttsd2si 0x140(%rsp), %rax
movq %rax, 0x138(%rsp)
movq $0x0, 0x130(%rsp)
movq $0x0, 0x128(%rsp)
jmp 0x7a2f
movq 0xbb8(%rsp), %rdi
callq 0xf010
movq 0xbd0(%rsp), %rdi
movl 0xbc4(%rsp), %edx
movq 0x138(%rsp), %rcx
movl 0xbe8(%rsp), %eax
testl %eax, %eax
setne %al
movq 0xba8(%rsp), %r9
movl 0xbe0(%rsp), %r8d
movq %rsp, %rsi
movl %r8d, (%rsi)
movzbl %al, %r8d
leaq 0x1a0(%rsp), %rsi
callq 0x4a00
jmp 0x7a88
movq 0x138(%rsp), %rax
addq %rax, %rax
movq %rax, 0x138(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x1fa00
movl %eax, 0x4c(%rsp)
jmp 0x7aae
movl 0x4c(%rsp), %eax
cltq
movq %rax, 0x130(%rsp)
movq 0xbb8(%rsp), %rsi
movl 0xbcc(%rsp), %edx
movl 0xbc8(%rsp), %ecx
leaq 0x1a0(%rsp), %rdi
leaq 0x188(%rsp), %r8
callq 0x4db0
jmp 0x7ae9
movslq 0xbc8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xeb00
movsd (%rax), %xmm1
movsd 0x140(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7b62
jmp 0x7a2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
leaq 0x17f(%rsp), %rdi
callq 0xf000
jmp 0x7cc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
leaq 0x188(%rsp), %rdi
callq 0xf030
jmp 0x7cc2
movq 0xbd0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xbb8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0xbc4(%rsp), %eax
movl %eax, 0x3c(%rsp)
movslq 0xbc8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xeb00
movsd (%rax), %xmm0
cvtsi2sdl 0xbcc(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x1fa00
movl %eax, 0x48(%rsp)
jmp 0x7bc6
movl 0x3c(%rsp), %ecx
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
movl 0x48(%rsp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x160(%rsp), %xmm1
movsd 0x158(%rsp), %xmm5
cvtsd2ss %xmm5, %xmm2
movss 0xbb0(%rsp), %xmm3
movl 0xbe8(%rsp), %r8d
movq 0x130(%rsp), %rax
addq %rax, %rax
cvtsi2sd %rax, %xmm4
movsd 0x2a3e3(%rip), %xmm6    # 0x32008
movaps %xmm5, %xmm7
addsd %xmm6, %xmm7
mulsd %xmm7, %xmm4
subsd %xmm5, %xmm6
divsd %xmm6, %xmm4
movsd 0x150(%rsp), %xmm6
mulsd %xmm6, %xmm6
mulsd %xmm6, %xmm4
mulsd %xmm5, %xmm5
divsd %xmm5, %xmm4
cvttsd2si %xmm4, %r9
movq 0xba8(%rsp), %rsi
movl 0xbe0(%rsp), %r10d
movq %rsp, %rax
movl %r10d, 0x10(%rax)
movq %rsi, 0x8(%rax)
leaq 0x128(%rsp), %rsi
movq %rsi, (%rax)
leaq 0x1a0(%rsp), %rsi
callq 0x6500
movb %al, 0x27(%rsp)
jmp 0x7c8f
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x7c99
jmp 0x7c9b
jmp 0x7ca0
jmp 0x7a2d
leaq 0x188(%rsp), %rdi
callq 0xf030
leaq 0x1a0(%rsp), %rdi
callq 0xf090
addq $0xbd8, %rsp            # imm = 0xBD8
retq
leaq 0x1a0(%rsp), %rdi
callq 0xf090
movq 0x170(%rsp), %rdi
callq 0x4690
nopl (%rax)