// File: /workspace/github_c_makefile_star2_O2/cogbee[P]vmir-latest/src/vmir_transform.c
// Function: combine_binop_add_mul
static void
combine_binop_add_mul(ir_unit_t *iu, ir_instr_binary_t *add,
                      ir_instr_binary_t *mul, int side)
{

  const ir_value_t *a1 = value_get(iu, mul->lhs_value.value);
  const ir_type_t *ty = type_get(iu, mul->lhs_value.type);
  if(ty->it_code != IR_TYPE_INT32)
    return;

  ir_value_t *a2 = value_get(iu, mul->rhs_value.value);
  const int arg3 = side ? add->lhs_value.value : add->rhs_value.value;
  ir_value_t *a3 = value_get(iu, arg3);

  assert(a1->iv_type == a2->iv_type);
  assert(a1->iv_type == a3->iv_type);

  if(a1->iv_class != IR_VC_TEMPORARY && a1->iv_class != IR_VC_REGFRAME)
    return;
  if(a2->iv_class != IR_VC_TEMPORARY && a2->iv_class != IR_VC_REGFRAME)
    return;
  if(a3->iv_class != IR_VC_TEMPORARY && a3->iv_class != IR_VC_REGFRAME)
    return;

  ir_instr_ternary_t *mla =
    instr_add_after(sizeof(ir_instr_ternary_t), IR_IC_MLA,
                    &add->super);

  mla->super.ii_ret = add->super.ii_ret;
  mla->arg1 = mul->lhs_value;
  mla->arg2 = mul->rhs_value;
  mla->arg3.value = arg3;
  mla->arg3.type = mla->arg2.type;

  instr_bind_input(iu, mla->arg1, &mla->super);
  instr_bind_input(iu, mla->arg2, &mla->super);
  instr_bind_input(iu, mla->arg3, &mla->super);
  value_bind_return_value(iu, &mla->super);

  value_get(iu, mul->super.ii_ret.value)->iv_class = IR_VC_DEAD;

  instr_destroy(&add->super);
  instr_destroy(&mul->super);

  iu->iu_stats.mla_combine++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl 0x5c(%rdx), %esi
callq 0x102f1
movq %rax, %r12
movl 0x60(%r14), %esi
movq %rbx, %rdi
callq 0xe719
cmpl $0x5, (%rax)
jne 0x146ce
movl 0x64(%r14), %esi
movq %rbx, %rdi
callq 0x102f1
movq %rax, %r13
xorl %eax, %eax
testl %ebp, %ebp
sete %al
movl 0x5c(%r15,%rax,8), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x102f1
movl 0x24(%r12), %ecx
cmpl 0x24(%r13), %ecx
jne 0x146dd
cmpl 0x24(%rax), %ecx
jne 0x146fc
movl (%r12), %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x146ce
movl (%r13), %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x146ce
movl (%rax), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x146ce
pushq $0x70
popq %rdi
pushq $0x1b
popq %rsi
movq %r15, %rdx
callq 0x141bb
movq %rax, %r12
movq 0x2c(%r15), %rax
movq %rax, 0x2c(%r12)
movq 0x5c(%r14), %rsi
movq %rsi, 0x58(%r12)
movq 0x64(%r14), %rax
movq %rax, 0x60(%r12)
movl %ebp, 0x68(%r12)
shrq $0x20, %rax
movl %eax, 0x6c(%r12)
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1420b
movq 0x60(%r12), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1420b
movq 0x68(%r12), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x1420b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10225
movl 0x2c(%r14), %esi
movq %rbx, %rdi
callq 0x102f1
movl $0xc, (%rax)
movq %r15, %rdi
callq 0xe058
movq %r14, %rdi
callq 0xe058
incl 0x614(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcf20(%rip), %rdi      # 0x21604
leaq 0xcbde(%rip), %rsi      # 0x212c9
leaq 0xcf2d(%rip), %rcx      # 0x2161f
movl $0x98c, %edx            # imm = 0x98C
callq 0x31e0
leaq 0xcf73(%rip), %rdi      # 0x21676
leaq 0xcbbf(%rip), %rsi      # 0x212c9
leaq 0xcf0e(%rip), %rcx      # 0x2161f
movl $0x98d, %edx            # imm = 0x98D
callq 0x31e0