// File: /workspace/github_c_makefile_star2_O3/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 0x2ce48
movq %rax, 0x8(%rsp)
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2ce48
movq %rax, %r13
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2ce48
movq %rax, %r15
movq 0x20(%rbx), %rdi
shlq $0x3, %rdi
callq 0x2ce48
movq %rax, %r12
leaq 0x34f79(%rip), %r14     # 0x61960
movq (%r14), %rdi
shlq $0x3, %rdi
callq 0x2ce48
movq %rax, %rbp
movq (%r14), %rdi
shlq $0x3, %rdi
callq 0x2ce48
movq %rax, 0x28(%rsp)
movq 0x20(%rbx), %rax
testq %rax, %rax
movq %r13, (%rsp)
movq %rbp, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %r12, 0x30(%rsp)
je 0x2cc11
xorl %r12d, %r12d
movq %rbx, 0x48(%rsp)
movq 0x20(%rsp), %r15
movq 0x8(%rbx), %rcx
movq (%rcx,%r12,8), %r13
testq %r13, %r13
je 0x2cac6
cmpq $0x0, 0x20(%r13)
je 0x2cac6
xorl %ebp, %ebp
movq 0x18(%r13), %rax
movq (%rax,%rbp,8), %rdi
callq 0x2c8c0
testq %rax, %rax
je 0x2cab4
movq %rax, %r14
movq %rax, %rdi
callq 0x1d422
cmpl $0x33, %eax
jne 0x2cab4
movq 0x38(%r14), %r14
movq 0x28(%rsp), %rbx
movq (%rbx,%r14,8), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx,%r14,8)
movq (%r15,%r14,8), %rdi
leaq 0x8(,%rax,8), %rsi
callq 0x2ced6
movq %rax, (%r15,%r14,8)
movq 0x18(%r13), %rcx
movq (%rcx,%rbp,8), %rcx
movslq 0xc(%rcx), %rcx
movq (%rbx,%r14,8), %rdx
movq 0x48(%rsp), %rbx
movq %rcx, -0x8(%rax,%rdx,8)
incq %rbp
cmpq 0x20(%r13), %rbp
jb 0x2ca4e
movq 0x20(%rbx), %rax
movq 0x20(%rsp), %rbp
incq %r12
cmpq %rax, %r12
jb 0x2ca34
testq %rax, %rax
je 0x2cc15
xorl %r15d, %r15d
movq (%rsp), %r13
callq 0x2d13c
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
callq 0x2d13c
movq %rax, (%r13,%r15,8)
callq 0x2d13c
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
callq 0x2d13c
movq %rax, %r14
movq 0x30(%rsp), %rax
movq %r14, (%rax,%r15,8)
movq 0x8(%rbx), %rax
movq %r15, 0x40(%rsp)
movq (%rax,%r15,8), %r15
testq %r15, %r15
je 0x2cbf6
cmpq $0x0, 0x20(%r15)
je 0x2cbf6
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx,8), %r12
xorl %r13d, %r13d
movq %r15, 0x50(%rsp)
movq 0x18(%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x2c8c0
testq %rax, %rax
je 0x2cbe9
movq %r13, 0x10(%rsp)
movq %rbp, %r13
movq 0x38(%rax), %rbp
movq 0x28(%rsp), %rbx
cmpq $0x0, (%rbx,%rbp,8)
je 0x2cbac
xorl %r15d, %r15d
movq (%r13,%rbp,8), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x2d369
movq (%r13,%rbp,8), %rax
movq (%rax,%r15,8), %rsi
movq %r12, %rdi
callq 0x2d3d4
incq %r15
cmpq (%rbx,%rbp,8), %r15
jb 0x2cb81
movq 0x50(%rsp), %r15
movq 0x18(%r15), %rax
movq 0x10(%rsp), %rbx
movq (%rax,%rbx,8), %rax
movslq 0xc(%rax), %rsi
movq %r12, %rdi
callq 0x2d369
movq 0x18(%r15), %rax
movq (%rax,%rbx,8), %rax
movslq 0xc(%rax), %rsi
movq %r14, %rdi
callq 0x2d3d4
movq %r13, %rbp
movq %rbx, %r13
movq 0x48(%rsp), %rbx
incq %r13
cmpq 0x20(%r15), %r13
jb 0x2cb50
movq 0x40(%rsp), %r15
incq %r15
movq 0x20(%rbx), %rax
cmpq %rax, %r15
movq (%rsp), %r13
jb 0x2cae2
jmp 0x2cc1b
xorl %eax, %eax
jmp 0x2cc1b
xorl %eax, %eax
movq (%rsp), %r13
leaq 0x38(%rsp), %r12
testq %rax, %rax
je 0x2cd40
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq 0x8(%rbx), %rax
cmpq $0x0, (%rax,%rbp,8)
je 0x2cd25
callq 0x2d13c
movq %rax, %r14
movq $0x0, 0x38(%rsp)
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x28(%rax), %rdi
movq %r12, %rsi
callq 0x2d2a6
testl %eax, %eax
je 0x2cc85
movq 0x38(%rsp), %rax
movq (%r13,%rax,8), %rsi
movq %r14, %rdi
callq 0x2d3f9
incq 0x38(%rsp)
jmp 0x2cc54
movq %r14, %rdi
callq 0x2d180
movq %r13, %r15
movq %rax, %r13
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r13, %rdi
callq 0x2d523
movq 0x18(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movq %r13, %rdi
callq 0x2d3f9
movq (%r15,%rbp,8), %rdi
movq %r13, %rsi
callq 0x2d55d
testl %eax, %eax
je 0x2ccf0
movq 0x8(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movq %r14, %rsi
callq 0x2d55d
testl %eax, %eax
je 0x2ccf0
movq %r14, %rdi
callq 0x2d164
movq %r13, %rdi
callq 0x2d164
movq (%rsp), %r13
jmp 0x2cd25
movq 0x8(%rsp), %rax
movq (%rax,%rbp,8), %rdi
callq 0x2d164
movq (%rsp), %r15
movq (%r15,%rbp,8), %rdi
callq 0x2d164
movq 0x8(%rsp), %rax
movq %r14, (%rax,%rbp,8)
movq %r13, (%r15,%rbp,8)
movq %r15, %r13
movl $0x1, %eax
movq %rax, 0x10(%rsp)
incq %rbp
movq 0x20(%rbx), %rax
cmpq %rax, %rbp
jb 0x2cc34
cmpl $0x0, 0x10(%rsp)
jne 0x2cc20
testq %rax, %rax
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %r12
je 0x2cd6d
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x2d164
movq (%r12,%r14,8), %rdi
callq 0x2d164
incq %r14
cmpq 0x20(%rbx), %r14
jb 0x2cd52
movq %r15, %rdi
callq 0x4040
movq %r12, %rdi
callq 0x4040
movl $0x28, %edi
callq 0x2ce79
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
movq %r13, 0x8(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x28(%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