// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/flow.c
// Function: convert_to_jump
int convert_to_jump(struct instruction *insn, struct basic_block *target)
{
	struct basic_block *bb = insn->bb;
	struct basic_block *child;
	int changed = REPEAT_CSE;

	switch (insn->opcode) {
	case OP_CBR:
		changed |= remove_phisources(insn->bb, insn->bb_true == target ? insn->bb_false : insn->bb_true);
		break;
	case OP_SWITCH:
		changed |= remove_other_phisources(insn->bb, insn->multijmp_list, target);
		break;
	}
	kill_use(&insn->cond);
	insn->bb_true = target;
	insn->bb_false = NULL;
	insn->cond = NULL;
	insn->size = 0;
	insn->opcode = OP_BR;

	FOR_EACH_PTR(bb->children, child) {
		if (child == target) {
			target = NULL;	// leave first occurence
			continue;
		}
		DELETE_CURRENT_PTR(child);
		remove_bb_from_list(&child->parents, bb, 1);
		changed |= REPEAT_CFG_CLEANUP;
	} END_FOR_EACH_PTR(child);
	PACK_PTR_LIST(&bb->children);
	repeat_phase |= changed;
	return changed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x7f, %eax
movl %eax, -0x5c(%rbp)
subl $0x4, %eax
je 0x59fd0
jmp 0x59fc6
movl -0x5c(%rbp), %eax
subl $0x5, %eax
je 0x5a019
jmp 0x5a038
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x59ff8
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x5a004
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x58b20
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x5a038
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x5a240
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x35160
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xff, %ecx
orl $0x0, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $-0x80, %ecx
orl $0x3, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5a0b0
jmp 0x5a20c
jmp 0x5a0b2
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x5a1f4
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x5a104
cmpq $0x0, -0x20(%rbp)
jne 0x5a104
jmp 0x5a1e6
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x5a11b
movq $0x0, -0x10(%rbp)
jmp 0x5a1e6
jmp 0x5a11d
movq -0x38(%rbp), %rax
addq $0x18, %rax
movslq -0x44(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
addq $0x18, %rax
movq -0x38(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $-0x8, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x5a187
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
jmp 0x5a160
movq -0x50(%rbp), %rax
movl $0xf0f0f0f0, %ecx       # imm = 0xF0F0F0F0
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movw (%rax), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
addl $-0x1, %ecx
movw %cx, %dx
movw (%rax), %cx
andw $0xff, %dx
andw $0xff00, %cx            # imm = 0xFF00
orw %dx, %cx
movw %cx, (%rax)
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x59b90
movl -0x24(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x24(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x5a0b9
jmp 0x5a1f6
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq -0x30(%rbp), %rax
jne 0x5a0b2
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
callq 0x31170
movl -0x24(%rbp), %ecx
leaq 0x32f31(%rip), %rax     # 0x8d154
orl (%rax), %ecx
leaq 0x32f28(%rip), %rax     # 0x8d154
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)