// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: break_critical_edge
static void
break_critical_edge(ir_function_t *f, ir_bb_edge_t *ibe)
{
  ir_bb_t *from = ibe->ibe_from;
  ir_bb_t *to   = ibe->ibe_to;
  ir_bb_t *nb   = bb_add_before(f, to);

  // Add a single branch instruction to new basic block
  ir_instr_br_t *br = instr_add(nb, sizeof(ir_instr_br_t), IR_IC_BR);
  br->condition.value = -1;
  br->true_branch = to->ib_id;

  // Hook up existing edge to new bb
  LIST_REMOVE(ibe, ibe_to_link);
  ibe->ibe_to   = nb;
  LIST_INSERT_HEAD(&nb->ib_incoming_edges,   ibe, ibe_to_link);

  // Create new edge from new bb to target bb
  cfg_add_edge(f, nb, to->ib_id, 0);

  // Adjust final instruction of previous bb to point to new bb
  bb_change_branch(from, to, nb, f);

  ir_instr_t *ii;
  // Adjust phi of target bb to point to new bb
  TAILQ_FOREACH(ii, &to->ib_instrs, ii_link) {
    if(ii->ii_class != IR_IC_PHI)
      break;
    ir_instr_phi_t *p = (ir_instr_phi_t *)ii;

    for(int i = 0; i < p->num_nodes; i++) {
      if(p->nodes[i].predecessor == from->ib_id)
        p->nodes[i].predecessor = nb->ib_id;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x26c10
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x68, %esi
movl $0x8, %edx
callq 0x20c10
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0xffffffff, 0x58(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x26ad8
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0x26b21
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rcx
addq $0x30, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x28(%rax), %edx
xorl %ecx, %ecx
callq 0x26810
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rcx
callq 0x26c70
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x26bff
movq -0x38(%rbp), %rax
cmpl $0x9, 0x28(%rax)
je 0x26b8b
jmp 0x26bff
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x58(%rcx), %eax
jge 0x26bed
movq -0x40(%rbp), %rax
addq $0x5c, %rax
movslq -0x44(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x26be0
movq -0x28(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x40(%rbp), %rax
addq $0x5c, %rax
movslq -0x44(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
jmp 0x26be2
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x26b9a
jmp 0x26bef
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x26b74
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)