// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/mi/reaching.c
// Function: reaching
Reaching *
reaching(Cfg *cfg)
{
	Bitset **in, **out;
	Bitset **gen, **kill;
	Bitset *bbin, *bbout;
	Reaching *reaching;
	size_t **defs;        /* mapping from did => [def,list] */
	size_t *ndefs;
	size_t i, j;
	int changed;

	in = zalloc(cfg->nbb * sizeof(Bb*));
	out = zalloc(cfg->nbb * sizeof(Bb*));
	gen = zalloc(cfg->nbb * sizeof(Bb*));
	kill = zalloc(cfg->nbb * sizeof(Bb*));
	defs = zalloc(ndecls * sizeof(size_t*));
	ndefs = zalloc(ndecls * sizeof(size_t));

	collectdefs(cfg, defs, ndefs);
	for (i = 0; i < cfg->nbb; i++) {
		in[i] = mkbs();
		out[i] = mkbs();
		gen[i] = mkbs();
		kill[i] = mkbs();
		if (cfg->bb[i])
			genkill(cfg->bb[i], defs, ndefs, gen[i], kill[i]);
	}

	do {
		changed = 0;
		for (i = 0; i < cfg->nbb; i++) {
			if (!cfg->bb[i])
				continue;
			bbin = mkbs();
			for (j = 0; bsiter(cfg->bb[i]->pred, &j); j++)
				bsunion(bbin, out[j]);
			bbout = bsdup(bbin);
			bsdiff(bbout, kill[i]);
			bsunion(bbout, gen[i]);

			if (!bseq(out[i], bbout) || !bseq(in[i], bbin)) {
				changed = 1;
				bsfree(in[i]);
				bsfree(out[i]);
				in[i] = bbin;
				out[i] = bbout;
			} else {
				bsfree(bbin);
				bsfree(bbout);
			}
		}
	} while (changed);


	for (i = 0; i < cfg->nbb; i++) {
		bsfree(gen[i]);
		bsfree(kill[i]);
	}
	free(gen);
	free(kill);

	reaching = xalloc(sizeof(Reaching));
	reaching->in = in;
	reaching->out = out;
	reaching->defs = defs;
	reaching->ndefs = ndefs;
	reaching->nbb = cfg->nbb;
	return reaching;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
movq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, 0x18(%rsp)
movq 0x20(%r14), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, 0x8(%rsp)
movq 0x20(%r14), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, 0x10(%rsp)
movq 0x20(%r14), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, 0x20(%rsp)
leaq 0x352ea(%rip), %rbx     # 0x5e960
movq (%rbx), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, %r13
movq (%rbx), %rdi
shlq $0x3, %rdi
callq 0x29a78
movq %rax, 0x38(%rsp)
xorl %ebx, %ebx
movq %r14, (%rsp)
movq 0x20(%r14), %rax
cmpq %rax, %rbx
jae 0x29735
movq 0x8(%r14), %rax
movq (%rax,%rbx,8), %r12
testq %r12, %r12
je 0x29729
xorl %ebp, %ebp
cmpq 0x20(%r12), %rbp
jae 0x29729
movq 0x18(%r12), %rax
movq (%rax,%rbp,8), %rdi
callq 0x29554
testq %rax, %rax
je 0x29724
movq %rax, %r15
movq %rax, %rdi
callq 0x1b5e6
cmpl $0x33, %eax
jne 0x29724
movq 0x38(%r15), %r14
movq 0x38(%rsp), %r15
movq (%r15,%r14,8), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r15,%r14,8)
movq (%r13,%r14,8), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x29b04
movq %rax, (%r13,%r14,8)
movq 0x18(%r12), %rcx
movq (%rcx,%rbp,8), %rcx
movslq 0xc(%rcx), %rcx
movq (%r15,%r14,8), %rdx
movq %rcx, -0x8(%rax,%rdx,8)
incq %rbp
jmp 0x296b8
incq %rbx
movq (%rsp), %r14
jmp 0x2969c
xorl %ebx, %ebx
cmpq %rax, %rbx
jae 0x29846
callq 0x29d3c
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
callq 0x29d3c
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
callq 0x29d3c
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
callq 0x29d3c
movq %rax, %r15
movq 0x20(%rsp), %rax
movq %r15, (%rax,%rbx,8)
movq 0x8(%r14), %rax
movq %rbx, 0x40(%rsp)
movq (%rax,%rbx,8), %rbx
testq %rbx, %rbx
je 0x29831
movq 0x10(%rsp), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %rbp
xorl %r12d, %r12d
movq %rbx, 0x28(%rsp)
cmpq 0x20(%rbx), %r12
jae 0x29831
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x29554
testq %rax, %rax
je 0x29829
movq 0x38(%rax), %rbx
xorl %r14d, %r14d
movq 0x38(%rsp), %rax
cmpq (%rax,%rbx,8), %r14
jae 0x297fc
movq (%r13,%rbx,8), %rax
movq (%rax,%r14,8), %rsi
movq %r15, %rdi
callq 0x29ed5
movq (%r13,%rbx,8), %rax
movq (%rax,%r14,8), %rsi
movq %rbp, %rdi
callq 0x29f3e
incq %r14
jmp 0x297ca
movq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rax
movslq 0xc(%rax), %rsi
movq %rbp, %rdi
callq 0x29ed5
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rax
movslq 0xc(%rax), %rsi
movq %r15, %rdi
callq 0x29f3e
incq %r12
jmp 0x297a7
movq 0x40(%rsp), %rbx
incq %rbx
movq (%rsp), %r14
movq 0x20(%r14), %rax
jmp 0x29737
xorl %ebp, %ebp
leaq 0x30(%rsp), %rbx
xorl %r12d, %r12d
cmpq %rax, %rbp
jb 0x29867
xorl %ebp, %ebp
testl %r12d, %r12d
movl $0x0, %r12d
jne 0x29850
jmp 0x29977
movq (%rsp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, (%rax,%rbp,8)
je 0x29967
callq 0x29d3c
movq %rax, %r15
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rax
movq 0x28(%rax), %rdi
movq %rbx, %rsi
callq 0x29e1a
testl %eax, %eax
je 0x298c5
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x29f5f
movq 0x30(%rsp), %rax
incq %rax
jmp 0x29884
movq %r15, %rdi
callq 0x29d7c
movq %rax, %r14
movq 0x20(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x2a079
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x29f5f
movq 0x8(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movq %r14, 0x28(%rsp)
movq %r14, %rsi
callq 0x2a0af
testl %eax, %eax
je 0x29935
movq 0x18(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movq %r15, %rsi
callq 0x2a0af
testl %eax, %eax
je 0x29935
movq %r15, %rdi
callq 0x29d60
movq 0x28(%rsp), %rdi
callq 0x29d60
jmp 0x29967
movq 0x18(%rsp), %rbx
movq (%rbx,%rbp,8), %rdi
callq 0x29d60
movq 0x8(%rsp), %r14
movq (%r14,%rbp,8), %rdi
callq 0x29d60
movq %r15, (%rbx,%rbp,8)
leaq 0x30(%rsp), %rbx
movq 0x28(%rsp), %rax
movq %rax, (%r14,%rbp,8)
pushq $0x1
popq %r12
incq %rbp
movq (%rsp), %rax
movq 0x20(%rax), %rax
jmp 0x29850
xorl %ebx, %ebx
movq (%rsp), %r14
cmpq %rax, %rbx
jae 0x299a7
movq 0x10(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x29d60
movq 0x20(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x29d60
incq %rbx
movq 0x20(%r14), %rax
jmp 0x2997d
movq 0x10(%rsp), %rdi
callq 0x4040
movq 0x20(%rsp), %rdi
callq 0x4040
pushq $0x28
popq %rdi
callq 0x29aa7
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %r13, 0x10(%rax)
movq 0x38(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x20(%r14), %rcx
movq %rcx, 0x20(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq