// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: remove_empty_bb
static void
remove_empty_bb(ir_unit_t *iu, ir_function_t *f)
{
  ir_bb_t *ib, *nb, *next;

  for(ib = TAILQ_FIRST(&f->if_bbs); ib != NULL; ib = next) {
    next = TAILQ_NEXT(ib, ib_link);

    ir_instr_t *ii = TAILQ_FIRST(&ib->ib_instrs);
    if(ii->ii_class != IR_IC_BR)
      continue;

    ir_instr_br_t *b = (ir_instr_br_t *)ii;
    ir_bb_edge_t *ibe, *n;
    if(b->condition.value != -1)
      continue;

    nb = bb_find(f, b->true_branch);
    assert(nb != NULL);

    if(nb == ib)
      continue; /* Unconditional branch to itself
                 * ie, an infinite loop, still legal though
                 */

    for(ibe = LIST_FIRST(&ib->ib_incoming_edges); ibe != NULL; ibe = n) {
      n = LIST_NEXT(ibe, ibe_to_link);
      bb_change_branch(ibe->ibe_from, ib, nb, f);

      ibe->ibe_to = nb;
      LIST_REMOVE(ibe, ibe_to_link);
      LIST_INSERT_HEAD(&nb->ib_incoming_edges, ibe, ibe_to_link);
    }
    bb_destroy(ib, f);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2acca
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x8, 0x28(%rax)
je 0x2ab7d
jmp 0x2acbd
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $-0x1, 0x58(%rax)
je 0x2ab94
jmp 0x2acbd
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x60(%rax), %esi
callq 0x268e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2abb1
jmp 0x2abd0
leaq 0x152e4(%rip), %rdi     # 0x3fe9c
leaq 0x1482e(%rip), %rsi     # 0x3f3ed
movl $0x422, %edx            # imm = 0x422
leaq 0x152dc(%rip), %rcx     # 0x3fea7
callq 0x31c0
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x2abdf
jmp 0x2acbd
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2acb0
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rcx
callq 0x26c70
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2ac46
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
jmp 0x2ac5b
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x40(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0x2ac85
movq -0x40(%rbp), %rcx
addq $0x10, %rcx
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rcx
addq $0x30, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x2aca3
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x2abeb
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1c9f0
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x2ab4c
addq $0x50, %rsp
popq %rbp
retq