// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r12
movq 0x8(%rdi), %rax
movq %rax, (%rsp)
movl (%rdi), %eax
andl $0x7f, %eax
movl $0x1, %r15d
cmpl $0x5, %eax
je 0x3cca6
cmpl $0x4, %eax
jne 0x3cd18
movq 0x38(%r12), %rsi
cmpq %r14, %rsi
jne 0x3cc94
movq 0x40(%r12), %rsi
movq (%rsp), %rdi
callq 0x3bcfc
movl %eax, %r15d
orl $0x1, %r15d
jmp 0x3cd18
movq 0x38(%r12), %rbx
testq %rbx, %rbx
je 0x3cd18
movq %r12, 0x8(%rsp)
xorl %r15d, %r15d
movq %rbx, %r13
movq %r14, %rbp
movzwl (%r13), %eax
testb %al, %al
jle 0x3cd06
xorl %r12d, %r12d
movq 0x18(%r13,%r12,8), %rcx
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x3ccde
testq %rcx, %rcx
je 0x3ccf6
movq (%rcx), %rsi
cmpq %rbp, %rsi
je 0x3ccf4
movq (%rsp), %rdi
callq 0x3bcfc
orl %eax, %r15d
jmp 0x3ccf6
xorl %ebp, %ebp
incq %r12
movl (%r13), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jl 0x3ccca
movq 0x10(%r13), %r13
cmpq %rbx, %r13
jne 0x3ccbe
orl $0x1, %r15d
movq 0x8(%rsp), %r12
leaq 0x30(%r12), %rdi
callq 0x24a58
movq %r14, 0x38(%r12)
xorl %eax, %eax
movq %rax, 0x40(%r12)
movq %rax, 0x30(%r12)
movl $0x80, %eax
andl (%r12), %eax
orl $0x3, %eax
movl %eax, (%r12)
movq (%rsp), %rax
leaq 0x20(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x3ce1b
movq %rax, %r13
movq %rax, 0x8(%rsp)
movzwl (%r13), %ecx
movsbl %cl, %eax
testw %ax, %ax
jle 0x3ce09
leaq 0x18(%r13), %r12
leaq 0x10(%r13), %rbp
xorl %ebx, %ebx
movslq %ebx, %rdx
movq (%r12,%rdx,8), %rdi
movzwl %cx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x3cd97
testq %rdi, %rdi
je 0x3cdf5
cmpq %r14, %rdi
je 0x3cdc9
leaq (%r12,%rdx,8), %rcx
movswq %ax, %rax
leaq (,%rax,8), %rax
addq %rbp, %rax
cmpq %rax, %rcx
jae 0x3cdce
leaq 0x8(%rcx), %rdx
movq 0x8(%rcx), %rsi
movq %rsi, (%rcx)
movq %rdx, %rcx
cmpq %rax, %rdx
jb 0x3cdb4
jmp 0x3cdd1
xorl %r14d, %r14d
jmp 0x3cdf5
movq %rcx, %rdx
movl $0xf0f0f0f0, %eax       # imm = 0xF0F0F0F0
movq %rax, (%rdx)
decb (%r13)
decl %ebx
addq $0x18, %rdi
movq (%rsp), %rsi
movl $0x1, %edx
callq 0x2296b
orl $0x4, %r15d
incl %ebx
movl (%r13), %ecx
movsbl %cl, %eax
movsbl %cl, %edx
cmpl %edx, %ebx
jl 0x3cd80
movq 0x10(%r13), %r13
movq 0x8(%rsp), %rax
cmpq %rax, %r13
jne 0x3cd65
movq 0x10(%rsp), %rdi
callq 0x22731
leaq 0x2af48(%rip), %rax     # 0x67d74
orl %r15d, (%rax)
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq