// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: liveness_set_succ
static void
liveness_set_succ(ir_function_t *f, ir_instr_t *ii)
{
  switch(ii->ii_class) {
  case IR_IC_RET:
  case IR_IC_UNREACHABLE:
  case IR_IC_RESUME:
    ii->ii_num_succ = 0;
    break;

  case IR_IC_CAST:
  case IR_IC_VAARG:
  case IR_IC_LOAD:
  case IR_IC_BINOP:
  case IR_IC_CMP2:
  case IR_IC_STORE:
  case IR_IC_ALLOCA:
  case IR_IC_SELECT:
  case IR_IC_CMP_SELECT:
  case IR_IC_LEA:
  case IR_IC_MOVE:
  case IR_IC_VMOP:
  case IR_IC_CALL:
  case IR_IC_STACKCOPY:
  case IR_IC_STACKSHRINK:
  case IR_IC_MLA:
  case IR_IC_LANDINGPAD:
  case IR_IC_EXTRACTVAL:
    /* -1 just means that we have one successor and it's the next instruction
     * Note that this is different from ii_num_suc == 1 where we have one
     * successor and it's NOT the next instruction (unconditional branch)
     */
    ii->ii_num_succ = -1;
    break;

  case IR_IC_SWITCH:
    {
      ir_instr_switch_t *s = (ir_instr_switch_t *)ii;

      ii->ii_num_succ = 1 + s->num_paths;
      ii->ii_succ = malloc(sizeof(ir_bb_t *) * ii->ii_num_succ);
      ii->ii_succ[0] = bb_find(f, s->defblock);

      for(int i = 0; i < s->num_paths; i++)
        ii->ii_succ[i + 1] = bb_find(f, s->paths[i].block);
    }
    break;

  case IR_IC_BR:
    {
      ir_instr_br_t *b = (ir_instr_br_t *)ii;

      ii->ii_num_succ = 1;
      if(b->condition.value != -1)
        ii->ii_num_succ = 2;

      ii->ii_succ = malloc(sizeof(ir_bb_t *) * ii->ii_num_succ);
      ii->ii_succ[0] = bb_find(f, b->true_branch);
      if(b->condition.value != -1)
        ii->ii_succ[1] = bb_find(f, b->false_branch);
    }
    break;

  case IR_IC_CMP_BRANCH:
    {
      ir_instr_cmp_branch_t *icb = (ir_instr_cmp_branch_t *)ii;

      ii->ii_num_succ = 2;
      ii->ii_succ = malloc(sizeof(ir_bb_t *) * ii->ii_num_succ);
      ii->ii_succ[0] = bb_find(f, icb->true_branch);
      ii->ii_succ[1] = bb_find(f, icb->false_branch);
    }
    break;

  case IR_IC_INVOKE:
    {
      ir_instr_invoke_t *icb = (ir_instr_invoke_t *)ii;

      ii->ii_num_succ = 2;
      ii->ii_succ = malloc(sizeof(ir_bb_t *) * ii->ii_num_succ);
      ii->ii_succ[0] = bb_find(f, icb->normal_dest);
      ii->ii_succ[1] = bb_find(f, icb->unwind_dest);
    }
    break;

  default:
    printf("Cant set successor for op %d\n", ii->ii_class);
    abort();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x1b, %rax
ja 0x270f7
movq -0x40(%rbp), %rax
leaq 0x168ac(%rip), %rcx     # 0x3d75c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movw $0x0, 0x50(%rax)
jmp 0x27111
movq -0x10(%rbp), %rax
movw $0xffff, 0x50(%rax)     # imm = 0xFFFF
jmp 0x27111
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x64(%rax), %eax
addl $0x1, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x50(%rax)
movq -0x10(%rbp), %rax
movswq 0x50(%rax), %rdi
shlq $0x3, %rdi
callq 0x3360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x60(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, (%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x64(%rcx), %eax
jge 0x26f84
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
addq $0x68, %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x268e0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x26f36
jmp 0x27111
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movw $0x1, 0x50(%rax)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x58(%rax)
je 0x26faf
movq -0x10(%rbp), %rax
movw $0x2, 0x50(%rax)
movq -0x10(%rbp), %rax
movswq 0x50(%rax), %rdi
shlq $0x3, %rdi
callq 0x3360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x60(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpl $-0x1, 0x58(%rax)
je 0x27013
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x64(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x27111
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movw $0x2, 0x50(%rax)
movq -0x10(%rbp), %rax
movswq 0x50(%rax), %rdi
shlq $0x3, %rdi
callq 0x3360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x6c(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x70(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x27111
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movw $0x2, 0x50(%rax)
movq -0x10(%rbp), %rax
movswq 0x50(%rax), %rdi
shlq $0x3, %rdi
callq 0x3360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x64(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x68(%rax), %esi
callq 0x268e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x27111
movq -0x10(%rbp), %rax
movl 0x28(%rax), %esi
leaq 0x1859d(%rip), %rdi     # 0x3f6a2
movb $0x0, %al
callq 0x3170
callq 0x3050
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)