// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: legalize_aggregate_select
static void
legalize_aggregate_select(ir_unit_t *iu, ir_instr_select_t *ii)
{
  const ir_value_t *tval = value_get(iu, ii->true_value.value);
  const ir_value_t *fval = value_get(iu, ii->false_value.value);
  const ir_value_t *dst = value_get(iu, ii->super.ii_ret.value);

  assert(tval->iv_num_values == dst->iv_num_values);
  assert(fval->iv_num_values == dst->iv_num_values);

  const ir_valuetype_t *tv = tval->iv_data;
  const ir_valuetype_t *fv = fval->iv_data;
  const ir_valuetype_t *dv = dst->iv_data;

  for(int i = 0; i < dst->iv_num_values; i++) {
    // TODO: Individual values can be constant-same for true and false path
    //       Such switches should use a MOVE -operand instead
    ir_instr_select_t *s =
      instr_add_before(sizeof(ir_instr_select_t), IR_IC_SELECT, &ii->super);
    s->super.ii_ret = dv[i];
    s->pred = ii->pred;
    s->true_value = tv[i];
    s->false_value = fv[i];
    value_bind_return_value(iu, &s->super);
    instr_bind_input(iu, s->pred, &s->super);
    instr_bind_input(iu, s->true_value, &s->super);
    instr_bind_input(iu, s->false_value, &s->super);
  }
  instr_destroy(&ii->super);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x58(%rax), %esi
callq 0x20ee0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x60(%rax), %esi
callq 0x20ee0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %esi
callq 0x20ee0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jne 0x28ede
jmp 0x28efd
leaq 0x16bc5(%rip), %rdi     # 0x3faaa
leaq 0x16501(%rip), %rsi     # 0x3f3ed
movl $0xa3b, %edx            # imm = 0xA3B
leaq 0x16bdc(%rip), %rcx     # 0x3fad4
callq 0x31c0
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jne 0x28f0f
jmp 0x28f2e
leaq 0x16bff(%rip), %rdi     # 0x3fb15
leaq 0x164d0(%rip), %rsi     # 0x3f3ed
movl $0xa3c, %edx            # imm = 0xA3C
leaq 0x16bab(%rip), %rcx     # 0x3fad4
callq 0x31c0
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x29026
movq -0x10(%rbp), %rdx
movl $0x70, %edi
movl $0xe, %esi
callq 0x26380
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq -0x44(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x2c(%rax)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x68(%rcx), %rcx
movq %rcx, 0x68(%rax)
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x44(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x58(%rax)
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq -0x44(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x20cf0
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movq -0x50(%rbp), %rdx
movq 0x68(%rax), %rsi
callq 0x267c0
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movq -0x50(%rbp), %rdx
movq 0x58(%rax), %rsi
callq 0x267c0
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rax
movq -0x50(%rbp), %rdx
movq 0x60(%rax), %rsi
callq 0x267c0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x28f59
movq -0x10(%rbp), %rdi
callq 0x1cad0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)