// File: todo314[P]pruned-monte-carlo/src/pmc.cpp
// Function: PrunedEstimater::sigma(int)
int PrunedEstimater::sigma(const int v0) {
	if (memo[v0]) {
		return sigmas[v0];
	}
	memo[v0] = true;
	if (removed[v0]) {
		return sigmas[v0] = 0;
	} else {
		int child = unique_child(v0);
		if (child == -1) {
			return sigmas[v0] = weight[v0];
		} else if (child >= 0) {
			return sigmas[v0] = sigma(child) + weight[v0];
		} else {
			int delta = 0;
			vector<int> vec;
			visited[v0] = true;
			vec.push_back(v0);
			queue<int> Q;
			Q.push(v0);
			bool prune = ancestor[v0];

			if (prune) {
				delta += sigma(hub);
			}

			for (; !Q.empty();) {
				const int v = Q.front();
				Q.pop();
				if (removed[v]) {
					continue;
				}
				if (prune && descendant[v]) {
					continue;
				}
				delta += weight[v];
				for (int i = at_e[v]; i < at_e[v + 1]; i++) {
					const int u = es[i];
					if (removed[u]) {
						continue;
					}
					if (!visited[u]) {
						visited[u] = true;
						vec.push_back(u);
						Q.push(u);
					}
				}
			}
			for (int i = 0; i < vec.size(); i++) {
				visited[vec[i]] = false;
			}
			return sigmas[v0] = delta;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x170(%rbp)
addq $0x98, %rdi
movslq -0x14(%rbp), %rsi
callq 0x7930
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x7990
testb $0x1, %al
jne 0x4d54
jmp 0x4d72
movq -0x170(%rbp), %rdi
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5421
movq -0x170(%rbp), %rdi
addq $0x98, %rdi
movslq -0x14(%rbp), %rsi
callq 0x7930
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x79c0
movq -0x170(%rbp), %rdi
addq $0xc0, %rdi
movslq -0x14(%rbp), %rsi
callq 0x7930
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7990
testb $0x1, %al
jne 0x4dcd
jmp 0x4df3
movq -0x170(%rbp), %rdi
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x5421
movq -0x170(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x7a10
movl %eax, -0x4c(%rbp)
cmpl $-0x1, -0x4c(%rbp)
jne 0x4e4e
movq -0x170(%rbp), %rdi
addq $0x8, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movq -0x170(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x174(%rbp)
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movq %rax, %rcx
movl -0x174(%rbp), %eax
movl %eax, (%rcx)
movl %eax, -0x4(%rbp)
jmp 0x5421
cmpl $0x0, -0x4c(%rbp)
jl 0x4eb5
movq -0x170(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x4d10
movq -0x170(%rbp), %rdi
movl %eax, -0x17c(%rbp)
addq $0x8, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl -0x17c(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x178(%rbp)
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movq %rax, %rcx
movl -0x178(%rbp), %eax
movl %eax, (%rcx)
movl %eax, -0x4(%rbp)
jmp 0x5421
movl $0x0, -0x50(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x2c00
movq -0x170(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
movslq -0x14(%rbp), %rsi
callq 0x7930
movq %rdx, -0x190(%rbp)
movq %rax, -0x188(%rbp)
jmp 0x4eec
movq -0x190(%rbp), %rax
movq -0x188(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movq %rax, -0x70(%rbp)
leaq -0x78(%rbp), %rdi
movl $0x1, %esi
callq 0x79c0
leaq -0x68(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x7860
jmp 0x4f1f
leaq -0xd8(%rbp), %rdi
callq 0x7b10
jmp 0x4f2d
leaq -0xd8(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x7b40
jmp 0x4f3f
movq -0x170(%rbp), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x14(%rbp), %rsi
callq 0x7930
movq %rdx, -0x1a0(%rbp)
movq %rax, -0x198(%rbp)
jmp 0x4f66
movq -0x1a0(%rbp), %rax
movq -0x198(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x7990
andb $0x1, %al
movb %al, -0xd9(%rbp)
testb $0x1, -0xd9(%rbp)
je 0x4ffb
movq -0x170(%rbp), %rdi
movl 0x170(%rdi), %esi
callq 0x4d10
movl %eax, -0x1a4(%rbp)
jmp 0x4fb9
movl -0x1a4(%rbp), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x4ffb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x5416
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7bd0
jmp 0x5416
jmp 0x4ffd
leaq -0xd8(%rbp), %rdi
callq 0x7b70
movb %al, -0x1a5(%rbp)
jmp 0x5011
movb -0x1a5(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5022
jmp 0x531f
leaq -0xd8(%rbp), %rdi
callq 0x7b90
movq %rax, -0x1b0(%rbp)
jmp 0x5037
movq -0x1b0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7bb0
jmp 0x5054
movq -0x170(%rbp), %rdi
addq $0xc0, %rdi
movslq -0xf4(%rbp), %rsi
callq 0x7930
movq %rdx, -0x1c0(%rbp)
movq %rax, -0x1b8(%rbp)
jmp 0x507e
movq -0x1c0(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x7990
testb $0x1, %al
jne 0x50ac
jmp 0x50b1
jmp 0x4ffd
xorl %eax, %eax
testb $0x1, -0xd9(%rbp)
movb %al, -0x1c1(%rbp)
je 0x511a
movq -0x170(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
movslq -0xf4(%rbp), %rsi
callq 0x7930
movq %rdx, -0x1d8(%rbp)
movq %rax, -0x1d0(%rbp)
jmp 0x50ec
movq -0x1d8(%rbp), %rax
movq -0x1d0(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x7990
movb %al, -0x1c1(%rbp)
movb -0x1c1(%rbp), %al
testb $0x1, %al
jne 0x5126
jmp 0x512b
jmp 0x4ffd
movq -0x170(%rbp), %rdi
addq $0x8, %rdi
movslq -0xf4(%rbp), %rsi
callq 0x29c0
movq -0x170(%rbp), %rdi
movl (%rax), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x50(%rbp)
addq $0x118, %rdi            # imm = 0x118
movslq -0xf4(%rbp), %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x11c(%rbp)
movq -0x170(%rbp), %rdi
movl -0x11c(%rbp), %eax
movl %eax, -0x1dc(%rbp)
addq $0x118, %rdi            # imm = 0x118
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movq %rax, %rcx
movl -0x1dc(%rbp), %eax
cmpl (%rcx), %eax
jge 0x531a
movq -0x170(%rbp), %rdi
addq $0xe8, %rdi
movslq -0x11c(%rbp), %rsi
callq 0x29c0
movq -0x170(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x120(%rbp)
addq $0xc0, %rdi
movslq -0x120(%rbp), %rsi
callq 0x7930
movq %rdx, -0x1f0(%rbp)
movq %rax, -0x1e8(%rbp)
jmp 0x51f4
movq -0x1f0(%rbp), %rax
movq -0x1e8(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movq %rax, -0x128(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x7990
testb $0x1, %al
jne 0x5222
jmp 0x5227
jmp 0x5306
movq -0x170(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
movslq -0x120(%rbp), %rsi
callq 0x7930
movq %rdx, -0x200(%rbp)
movq %rax, -0x1f8(%rbp)
jmp 0x5251
movq -0x200(%rbp), %rax
movq -0x1f8(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movq %rax, -0x138(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x7990
xorb $-0x1, %al
testb $0x1, %al
jne 0x5284
jmp 0x5304
movq -0x170(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
movslq -0x120(%rbp), %rsi
callq 0x7930
movq %rdx, -0x210(%rbp)
movq %rax, -0x208(%rbp)
jmp 0x52ae
movq -0x210(%rbp), %rax
movq -0x208(%rbp), %rcx
movq %rcx, -0x150(%rbp)
movq %rax, -0x148(%rbp)
leaq -0x150(%rbp), %rdi
movl $0x1, %esi
callq 0x79c0
leaq -0x68(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x7860
jmp 0x52ed
leaq -0xd8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x7b40
jmp 0x5302
jmp 0x5304
jmp 0x5306
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x516c
jmp 0x4ffd
movl $0x0, -0x154(%rbp)
movslq -0x154(%rbp), %rax
movq %rax, -0x218(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x71f0
movq %rax, %rcx
movq -0x218(%rbp), %rax
cmpq %rcx, %rax
jae 0x53d4
movq -0x170(%rbp), %rax
addq $0x148, %rax            # imm = 0x148
movq %rax, -0x230(%rbp)
movslq -0x154(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x29c0
movq -0x230(%rbp), %rdi
movslq (%rax), %rsi
callq 0x7930
movq %rdx, -0x228(%rbp)
movq %rax, -0x220(%rbp)
jmp 0x5396
movq -0x228(%rbp), %rax
movq -0x220(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movq %rax, -0x160(%rbp)
leaq -0x168(%rbp), %rdi
xorl %esi, %esi
callq 0x79c0
movl -0x154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x154(%rbp)
jmp 0x5329
movq -0x170(%rbp), %rdi
movl -0x50(%rbp), %eax
movl %eax, -0x234(%rbp)
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0x29c0
movq %rax, %rcx
movl -0x234(%rbp), %eax
movl %eax, (%rcx)
movl %eax, -0x4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7bd0
leaq -0x68(%rbp), %rdi
callq 0x29e0
jmp 0x5421
leaq -0x68(%rbp), %rdi
callq 0x29e0
jmp 0x542d
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x2280
nopw %cs:(%rax,%rax)