// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, 0x18(%rsp)
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, %r13
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, 0x10(%rsp)
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, 0x8(%rsp)
leaq 0x34a55(%rip), %r14     # 0x61960
movq (%r14), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, 0x28(%rsp)
movq (%r14), %rdi
shlq $0x3, %rdi
callq 0x2d348
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rbx)
movq %rbx, 0x38(%rsp)
je 0x2cfdf
xorl %ecx, %ecx
movq 0x20(%rsp), %r15
movq 0x8(%rbx), %rax
movq %rcx, (%rsp)
movq (%rax,%rcx,8), %rbp
testq %rbp, %rbp
je 0x2cfce
cmpq $0x0, 0x20(%rbp)
je 0x2cfce
xorl %r12d, %r12d
movq 0x18(%rbp), %rax
movq (%rax,%r12,8), %rdi
callq 0x2cde0
testq %rax, %rax
je 0x2cfc5
movq %rax, %r14
movq %rax, %rdi
callq 0x1d672
cmpl $0x33, %eax
jne 0x2cfc5
movq 0x38(%r14), %r14
movq (%r15,%r14,8), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r15,%r14,8)
movq 0x28(%rsp), %rbx
movq (%rbx,%r14,8), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2d3d6
movq %rax, (%rbx,%r14,8)
movq 0x38(%rsp), %rbx
movq 0x18(%rbp), %rcx
movq (%rcx,%r12,8), %rcx
movslq 0xc(%rcx), %rcx
movq (%r15,%r14,8), %rdx
movq %rcx, -0x8(%rax,%rdx,8)
incq %r12
cmpq 0x20(%rbp), %r12
jb 0x2cf5f
movq (%rsp), %rcx
incq %rcx
cmpq 0x20(%rbx), %rcx
jb 0x2cf44
cmpq $0x0, 0x20(%rbx)
movq 0x8(%rsp), %r14
je 0x2d236
xorl %r12d, %r12d
movq %r13, 0x40(%rsp)
callq 0x2d63c
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
callq 0x2d63c
movq %rax, (%r13,%r12,8)
callq 0x2d63c
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
callq 0x2d63c
movq %r12, %rcx
movq %rax, %r12
movq %rax, (%r14,%rcx,8)
movq 0x8(%rbx), %rax
movq %rcx, 0x30(%rsp)
movq (%rax,%rcx,8), %rbp
testq %rbp, %rbp
je 0x2d108
cmpq $0x0, 0x20(%rbp)
je 0x2d108
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %r14
xorl %r15d, %r15d
movq %rbp, 0x48(%rsp)
movq 0x18(%rbp), %rax
movq (%rax,%r15,8), %rdi
callq 0x2cde0
testq %rax, %rax
je 0x2d0fb
movq %r15, (%rsp)
movq 0x38(%rax), %r13
movq 0x20(%rsp), %rbp
cmpq $0x0, (%rbp,%r13,8)
movq 0x28(%rsp), %rbx
je 0x2d0c0
xorl %r15d, %r15d
movq (%rbx,%r13,8), %rax
movq (%rax,%r15,8), %rsi
movq %r12, %rdi
callq 0x2d816
movq (%rbx,%r13,8), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x2d872
incq %r15
cmpq (%rbp,%r13,8), %r15
jb 0x2d096
movq 0x48(%rsp), %rbp
movq 0x18(%rbp), %rax
movq (%rsp), %r15
movq (%rax,%r15,8), %rax
movslq 0xc(%rax), %rsi
movq %r14, %rdi
callq 0x2d816
movq 0x18(%rbp), %rax
movq (%rax,%r15,8), %rax
movslq 0xc(%rax), %rsi
movq %r12, %rdi
callq 0x2d872
movq 0x40(%rsp), %r13
movq 0x38(%rsp), %rbx
incq %r15
cmpq 0x20(%rbp), %r15
jb 0x2d063
movq 0x30(%rsp), %r12
incq %r12
cmpq 0x20(%rbx), %r12
movq 0x8(%rsp), %r14
jb 0x2cff7
jmp 0x2d236
movq $0x0, (%rsp)
xorl %ebp, %ebp
movq 0x8(%rbx), %rax
cmpq $0x0, (%rax,%rbp,8)
je 0x2d223
callq 0x2d63c
movq %rax, %r12
leaq 0x50(%rsp), %rsi
movq $0x0, (%rsi)
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x28(%rax), %rdi
callq 0x2d753
testl %eax, %eax
je 0x2d18f
leaq 0x50(%rsp), %r14
movq (%r14), %rax
movq (%r13,%rax,8), %rsi
movq %r12, %rdi
callq 0x2d897
incq (%r14)
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x28(%rax), %rdi
movq %r14, %rsi
jmp 0x2d15d
movq %r12, %rdi
callq 0x2d680
movq %rax, %r14
movq 0x8(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x2d9c6
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x2d897
movq (%r13,%rbp,8), %rdi
movq %r14, %rsi
callq 0x2da00
testl %eax, %eax
je 0x2d1f4
movq 0x18(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movq %r12, %rsi
callq 0x2da00
testl %eax, %eax
je 0x2d1f4
movq %r12, %rdi
callq 0x2d664
movq %r14, %rdi
callq 0x2d664
jmp 0x2d21e
movq 0x18(%rsp), %r15
movq (%r15,%rbp,8), %rdi
callq 0x2d664
movq (%r13,%rbp,8), %rdi
callq 0x2d664
movq %r12, (%r15,%rbp,8)
movq %r14, (%r13,%rbp,8)
movl $0x1, %eax
movq %rax, (%rsp)
movq 0x8(%rsp), %r14
incq %rbp
cmpq 0x20(%rbx), %rbp
jb 0x2d12e
cmpl $0x0, (%rsp)
je 0x2d241
cmpq $0x0, 0x20(%rbx)
jne 0x2d124
cmpq $0x0, 0x20(%rbx)
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %r15
movq %r14, %rbp
je 0x2d274
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
callq 0x2d664
movq (%rbp,%r14,8), %rdi
callq 0x2d664
incq %r14
cmpq 0x20(%rbx), %r14
jb 0x2d258
movq %r12, %rdi
callq 0x4040
movq %rbp, %rdi
callq 0x4040
movl $0x28, %edi
callq 0x2d379
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq %r15, 0x10(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x20(%rbx), %rcx
movq %rcx, 0x20(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq