// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/6/ra.c
// Function: rewritebb
static void
rewritebb(Isel *s, Asmbb *bb, Loc **aliasmap)
{
	regid use[Nreg], def[Nreg];
	size_t nuse, ndef;
	Insn *insn, *mov;
	size_t i, j;
	Insn **new;
	size_t nnew;
	Htab *map;
	Loc *tmp;

	new = NULL;
	nnew = 0;
	if (!bb)
		return;
	map = mkht(reglochash, regloceq);
	for (j = bb->ni; j > 0; j--) {
		insn = bb->il[j - 1];
		replacealias(s, aliasmap, s->nreg, insn);
		if (nopmov(s, insn))
			continue;
		nuse = uses(insn, use);
		ndef = defs(insn, def);
		/* if there is a remapping, insert the loads and stores as needed */
		if (remap(s, map, insn, use, nuse, def, ndef)) {
			for (i = 0; i < ndef; i++) {
				tmp = htget(map, locmap[def[i]]);
				if (!tmp)
					continue;
				if (isfloatmode(tmp->mode))
					mov = mkinsn(Imovs, tmp, spillslot(s, def[i]), NULL);
				else
					mov = mkinsn(Imov, tmp, spillslot(s, def[i]), NULL);
				lappend(&new, &nnew, mov);
			}
			updatelocs(s, map, insn);
			lappend(&new, &nnew, insn);
			for (i = 0; i < nuse; i++) {
				tmp = htget(map, locmap[use[i]]);
				if (!tmp)
					continue;
				if (isfloatmode(tmp->mode))
					mov = mkinsn(Imovs, spillslot(s, use[i]), tmp, NULL);
				else
					mov = mkinsn(Imov, spillslot(s, use[i]), tmp, NULL);
				lappend(&new, &nnew, mov);
			}
			for (i = 0; i < nuse; i++)
				htdel(map, locmap[use[i]]);
			for (i = 0; i < ndef; i++)
				htdel(map, locmap[def[i]]);
		} else {
			lappend(&new, &nnew, insn);
		}
	}
	for (i = 0; i < nnew/2; i++) {
		insn = new[i];
		new[i] = new[nnew - i - 1];
		new[nnew - i -1] = insn;
	}
	lfree(&bb->il, &bb->ni);
	bb->il = new;
	bb->ni = nnew;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6f0, %rsp            # imm = 0x6F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x6b8(%rbp)
movq $0x0, -0x6c0(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x159f9
jmp 0x15f36
leaq 0x550(%rip), %rdi       # 0x15f50
leaq 0x579(%rip), %rsi       # 0x15f80
callq 0x48fe0
movq %rax, -0x6c8(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x6b0(%rbp)
cmpq $0x0, -0x6b0(%rbp)
jbe 0x15e5b
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x6b0(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x698(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x3d0(%rax), %rdx
movq -0x698(%rbp), %rcx
callq 0x11150
movq -0x8(%rbp), %rdi
movq -0x698(%rbp), %rsi
callq 0x15fc0
cmpl $0x0, %eax
je 0x15a87
jmp 0x15e44
movq -0x698(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x13b20
movq %rax, -0x688(%rbp)
movq -0x698(%rbp), %rdi
leaq -0x680(%rbp), %rsi
callq 0x13d80
movq %rax, -0x690(%rbp)
movq -0x8(%rbp), %rdi
movq -0x6c8(%rbp), %rsi
movq -0x698(%rbp), %rdx
leaq -0x350(%rbp), %rcx
movq -0x688(%rbp), %r8
leaq -0x680(%rbp), %r9
movq -0x690(%rbp), %rax
movq %rax, (%rsp)
callq 0x16060
cmpl $0x0, %eax
je 0x15e28
movq $0x0, -0x6a8(%rbp)
movq -0x6a8(%rbp), %rax
cmpq -0x690(%rbp), %rax
jae 0x15c2e
movq -0x6c8(%rbp), %rdi
leaq 0x66e78(%rip), %rax     # 0x7c9a0
movq (%rax), %rax
movq -0x6a8(%rbp), %rcx
movq -0x680(%rbp,%rcx,8), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x49490
movq %rax, -0x6d0(%rbp)
cmpq $0x0, -0x6d0(%rbp)
jne 0x15b59
jmp 0x15c17
movq -0x6d0(%rbp), %rax
movl 0x4(%rax), %edi
callq 0xfd70
cmpl $0x0, %eax
je 0x15bb6
movq -0x6d0(%rbp), %rax
movq %rax, -0x6d8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movq -0x680(%rbp,%rax,8), %rsi
callq 0x16230
movq -0x6d8(%rbp), %rsi
movq %rax, %rdx
movl $0x27, %edi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0xa980
movq %rax, -0x6a0(%rbp)
jmp 0x15bfd
movq -0x6d0(%rbp), %rax
movq %rax, -0x6e0(%rbp)
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movq -0x680(%rbp,%rax,8), %rsi
callq 0x16230
movq -0x6e0(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0xa980
movq %rax, -0x6a0(%rbp)
movq -0x6a0(%rbp), %rdx
leaq -0x6b8(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x48290
movq -0x6a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x6a8(%rbp)
jmp 0x15b06
movq -0x8(%rbp), %rdi
movq -0x6c8(%rbp), %rsi
movq -0x698(%rbp), %rdx
callq 0x162b0
movq -0x698(%rbp), %rdx
leaq -0x6b8(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x48290
movq $0x0, -0x6a8(%rbp)
movq -0x6a8(%rbp), %rax
cmpq -0x688(%rbp), %rax
jae 0x15d76
movq -0x6c8(%rbp), %rdi
leaq 0x66d14(%rip), %rax     # 0x7c9a0
movq (%rax), %rax
movq -0x6a8(%rbp), %rcx
movq -0x350(%rbp,%rcx,8), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x49490
movq %rax, -0x6d0(%rbp)
cmpq $0x0, -0x6d0(%rbp)
jne 0x15cbd
jmp 0x15d5f
movq -0x6d0(%rbp), %rax
movl 0x4(%rax), %edi
callq 0xfd70
cmpl $0x0, %eax
je 0x15d0c
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movq -0x350(%rbp,%rax,8), %rsi
callq 0x16230
movq %rax, %rsi
movq -0x6d0(%rbp), %rdx
movl $0x27, %edi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0xa980
movq %rax, -0x6a0(%rbp)
jmp 0x15d45
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movq -0x350(%rbp,%rax,8), %rsi
callq 0x16230
movq %rax, %rsi
movq -0x6d0(%rbp), %rdx
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0xa980
movq %rax, -0x6a0(%rbp)
movq -0x6a0(%rbp), %rdx
leaq -0x6b8(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x48290
movq -0x6a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x6a8(%rbp)
jmp 0x15c6a
movq $0x0, -0x6a8(%rbp)
movq -0x6a8(%rbp), %rax
cmpq -0x688(%rbp), %rax
jae 0x15dce
movq -0x6c8(%rbp), %rdi
leaq 0x66c01(%rip), %rax     # 0x7c9a0
movq (%rax), %rax
movq -0x6a8(%rbp), %rcx
movq -0x350(%rbp,%rcx,8), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x49620
movq -0x6a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x6a8(%rbp)
jmp 0x15d81
movq $0x0, -0x6a8(%rbp)
movq -0x6a8(%rbp), %rax
cmpq -0x690(%rbp), %rax
jae 0x15e26
movq -0x6c8(%rbp), %rdi
leaq 0x66ba9(%rip), %rax     # 0x7c9a0
movq (%rax), %rax
movq -0x6a8(%rbp), %rcx
movq -0x680(%rbp,%rcx,8), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x49620
movq -0x6a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x6a8(%rbp)
jmp 0x15dd9
jmp 0x15e42
movq -0x698(%rbp), %rdx
leaq -0x6b8(%rbp), %rdi
leaq -0x6c0(%rbp), %rsi
callq 0x48290
jmp 0x15e44
movq -0x6b0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x6b0(%rbp)
jmp 0x15a22
movq $0x0, -0x6a8(%rbp)
movq -0x6a8(%rbp), %rax
movq -0x6c0(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jae 0x15f03
movq -0x6b8(%rbp), %rax
movq -0x6a8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x698(%rbp)
movq -0x6b8(%rbp), %rax
movq -0x6c0(%rbp), %rcx
subq -0x6a8(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x6b8(%rbp), %rax
movq -0x6a8(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x698(%rbp), %rdx
movq -0x6b8(%rbp), %rax
movq -0x6c0(%rbp), %rcx
subq -0x6a8(%rbp), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x6a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x6a8(%rbp)
jmp 0x15e66
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0x48580
movq -0x6b8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x6c0(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
addq $0x6f0, %rsp            # imm = 0x6F0
popq %rbp
retq
nop