// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: construct_cfg
static void
construct_cfg(ir_function_t *f)
{
  ir_bb_t *bb, *next;
  for(bb = TAILQ_FIRST(&f->if_bbs); bb != NULL; bb = next) {
    next = TAILQ_NEXT(bb, ib_link);

    ir_instr_t *ii = TAILQ_LAST(&bb->ib_instrs, ir_instr_queue);
    if(ii == NULL) {
      bb_destroy(bb, f);
      continue;
    }

    switch(ii->ii_class) {
    case IR_IC_BR:
      {
        ir_instr_br_t *b = (ir_instr_br_t *)ii;
        cfg_add_edge(f, bb, b->true_branch, 1);
        if(b->condition.value != -1)
          cfg_add_edge(f, bb, b->false_branch, 1);
      }
      break;
    case IR_IC_SWITCH:
      {
        ir_instr_switch_t *s = (ir_instr_switch_t *)ii;
        cfg_add_edge(f, bb, s->defblock, 1);
        for(int i = 0; i < s->num_paths; i++)
          cfg_add_edge(f, bb, s->paths[i].block, 1);
      }
      break;
    case IR_IC_INVOKE:
      {
        ir_instr_invoke_t *s = (ir_instr_invoke_t *)ii;
        cfg_add_edge(f, bb, s->normal_dest, 1);
        cfg_add_edge(f, bb, s->unwind_dest, 1);
      }
      break;

    case IR_IC_RET:
    case IR_IC_UNREACHABLE:
    case IR_IC_RESUME:
      break;
    default:
      abort();
    }

    unmark_outgoing_blocks(bb);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x24c2e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x24afa
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x1c9f0
jmp 0x24c21
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movq %rax, -0x48(%rbp)
subq $0x13, %rax
ja 0x24c13
movq -0x48(%rbp), %rax
leaq 0x18b5e(%rip), %rcx     # 0x3d678
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x60(%rax), %edx
movl $0x1, %ecx
callq 0x26810
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x58(%rax)
je 0x24b67
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl 0x64(%rax), %edx
movl $0x1, %ecx
callq 0x26810
jmp 0x24c18
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
movl 0x60(%rax), %edx
movl $0x1, %ecx
callq 0x26810
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x64(%rcx), %eax
jge 0x24bd3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
addq $0x68, %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movl $0x1, %ecx
callq 0x26810
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x24b94
jmp 0x24c18
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
movl 0x64(%rax), %edx
movl $0x1, %ecx
callq 0x26810
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
movl 0x68(%rax), %edx
movl $0x1, %ecx
callq 0x26810
jmp 0x24c18
jmp 0x24c18
callq 0x3050
movq -0x10(%rbp), %rdi
callq 0x26870
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x24ab8
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)