// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_vm.c
// Function: branch_fixup
static void
branch_fixup(ir_unit_t *iu)
{
  ir_function_t *f = iu->iu_current_function;
  int x = VECTOR_LEN(&iu->iu_branch_fixups);
  int p;
  for(int i = 0; i < x; i++) {
    int off = VECTOR_ITEM(&iu->iu_branch_fixups, i);

    uint16_t *I = f->if_vm_text + off;
    switch(I[0]) {
    case VM_B:
      I[1] = bb_to_offset_delta(iu, f, I[1], off);
      break;
    case VM_BCOND:
      I[2] = bb_to_offset_delta(iu, f, I[2], off);
      I[3] = bb_to_offset_delta(iu, f, I[3], off);
      break;
    case VM_INVOKE:
    case VM_INVOKE_VM:
    case VM_INVOKE_EXT:
    case VM_INVOKE_R:
      I[4] = bb_to_offset_delta(iu, f, I[4], off);
      I[5] = bb_to_offset_delta(iu, f, I[5], off);
      break;
    case VM_EQ8_BR ... VM_SLE32_C_BR:
      I[1] = bb_to_offset_delta(iu, f, I[1], off);
      I[2] = bb_to_offset_delta(iu, f, I[2], off);
      break;
    case VM_JUMPTABLE:
      for(int j = 0; j < I[2]; j++) // one extra for default path (first)
        I[3 + j] = bb_to_offset_delta(iu, f, I[3 + j], off);
      break;

    case VM_SWITCH8_BS:
      p = I[2];
      for(int j = 0; j < p + 1; j++)
        I[3 + p + j] = bb_to_offset_delta(iu, f, I[3 + p + j], off);
      break;
    case VM_SWITCH32_BS:
      p = I[2];
      for(int j = 0; j < p + 1; j++)
        I[3 + p * 2 + j] = bb_to_offset_delta(iu, f, I[3 + p * 2 + j], off);
      break;
    case VM_SWITCH64_BS:
      p = I[2];
      for(int j = 0; j < p + 1; j++)
        I[3 + p * 4 + j] = bb_to_offset_delta(iu, f, I[3 + p * 4 + j], off);
      break;
    default:
      parser_error(iu, "Bad branch temporary opcode %d", I[0]);
    }
    I[0] = vm_resolve(I[0]);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x1c0(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x310(%rax), %rax
movl %eax, -0x14(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2bad6
movq -0x8(%rbp), %rax
movq 0x308(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzwl (%rax), %eax
addl $0xfffffed9, %eax       # imm = 0xFFFFFED9
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x53, %eax
ja 0x2ba8c
movq -0x40(%rbp), %rax
leaq 0x12142(%rip), %rcx     # 0x3d91c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x2(%rax)
jmp 0x2bab2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x4(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x6(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x6(%rax)
jmp 0x2bab2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x8(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0xa(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x2bab2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movzwl 0x4(%rax), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x4(%rax)
jmp 0x2bab2
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jge 0x2b942
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %dx
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2b8f3
jmp 0x2bab2
movq -0x28(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2b9ac
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x3, %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %dx
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x3, %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2b959
jmp 0x2bab2
movq -0x28(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2ba1a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
shll %ecx
addl $0x3, %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %dx
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
shll %ecx
addl $0x3, %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2b9c3
jmp 0x2bab2
movq -0x28(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2ba8a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
addl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %edx
movl -0x20(%rbp), %ecx
callq 0x330d0
movw %ax, %dx
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
addl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2ba31
jmp 0x2bab2
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movzwl (%rax), %r8d
leaq 0x14480(%rip), %rsi     # 0x3ff1f
movl $0x1296, %edx           # imm = 0x1296
leaq 0x14cfe(%rip), %rcx     # 0x407a9
movb $0x0, %al
callq 0x18220
movq -0x28(%rbp), %rax
movzwl (%rax), %edi
callq 0x19040
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2b780
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)