// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_bitcode_instr.c
// Function: parse_phi
static void
parse_phi(ir_unit_t *iu, unsigned int argc, const int64_t *argv)
{
  ir_bb_t *ib = iu->iu_current_bb;

  int type = instr_get_uint(iu, &argc, &argv);

  int num_nodes = argc / 2;

  ir_instr_phi_t *i =
    instr_add(ib, sizeof(ir_instr_phi_t) + num_nodes * sizeof(ir_phi_node_t),
              IR_IC_PHI);

  i->num_nodes = num_nodes;

  for(int j = 0; j < num_nodes; j++) {
    i->nodes[j].value       = instr_get_value_signed(iu, &argc, &argv, type);
    i->nodes[j].predecessor = instr_get_uint(iu, &argc, &argv);
  }
  qsort(i->nodes, num_nodes, sizeof(ir_phi_node_t), phi_sort);

  int w = 1;
  for(int j = 1; j < num_nodes; j++) {
    if(i->nodes[j].predecessor == i->nodes[w - 1].predecessor)
      continue;
    i->nodes[w].predecessor = i->nodes[j].predecessor;
    i->nodes[w].value       = i->nodes[j].value;
    w++;
  }
  i->num_nodes = w;

  value_alloc_instr_ret(iu, type, &i->super);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x1c8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x37cf0
movl %eax, -0x24(%rbp)
movl -0xc(%rbp), %eax
shrl %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0xc, %rax, %rsi
addq $0x60, %rsi
movl $0x9, %edx
callq 0x20c10
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x58(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x369b6
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %ecx
leaq -0xc(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x37d70
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x3c(%rbp)
movq -0x3c(%rbp), %rcx
movq %rcx, 0x4(%rax)
movq -0x8(%rbp), %rdi
leaq -0xc(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x37cf0
movl %eax, %ecx
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x34(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3693d
movq -0x30(%rbp), %rdi
addq $0x5c, %rdi
movslq -0x28(%rbp), %rsi
movl $0xc, %edx
leaq 0x1452(%rip), %rcx      # 0x37e20
callq 0x30d0
movl $0x1, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x36a8f
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x44(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
addq $0x5c, %rcx
movl -0x40(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x36a20
jmp 0x36a81
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x44(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x40(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
addq $0x5c, %rax
movslq -0x40(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x30(%rbp), %rcx
addq $0x5c, %rcx
movslq -0x44(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movq 0x4(%rcx), %rcx
movq %rcx, 0x4(%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x369e1
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x22410
addq $0x50, %rsp
popq %rbp
retq
nop