// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
movl 0x5c(%rdx), %r8d
movq 0x188(%rdi), %rdx
cmpq %r8, %rdx
jbe 0x172ae
movl 0x60(%r14), %eax
cmpq %rax, 0x170(%rbx)
jbe 0x172c6
movq %rsi, %r15
movq 0x168(%rbx), %rsi
leaq (%rax,%rax,4), %rax
cmpl $0x5, (%rsi,%rax,8)
jne 0x172a4
movl 0x64(%r14), %eax
cmpq %rax, %rdx
jbe 0x172de
xorl %esi, %esi
testl %ecx, %ecx
sete %sil
movl 0x5c(%r15,%rsi,8), %r12d
cmpq %r12, %rdx
jbe 0x172f9
movq 0x180(%rbx), %rsi
movq (%rsi,%r8,8), %rdx
movq (%rsi,%rax,8), %rcx
movl 0x24(%rdx), %edi
cmpl 0x24(%rcx), %edi
jne 0x17319
movq (%rsi,%r12,8), %rax
cmpl 0x24(%rax), %edi
jne 0x17338
movl (%rdx), %edx
andl $-0x2, %edx
cmpl $0x4, %edx
jne 0x172a4
movl (%rcx), %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x172a4
movl (%rax), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x172a4
movl $0x70, %edi
movl $0x1b, %esi
movq %r15, %rdx
callq 0x16c48
movq %rax, %r13
movq 0x2c(%r15), %rax
movq %rax, 0x2c(%r13)
movq 0x5c(%r14), %rsi
movq %rsi, 0x58(%r13)
movq 0x64(%r14), %rax
movq %rax, 0x60(%r13)
movl %r12d, 0x68(%r13)
movl 0x64(%r13), %eax
movl %eax, 0x6c(%r13)
movq %rbx, %rdi
movq %r13, %rdx
callq 0x16ce0
movq 0x60(%r13), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x16ce0
movq 0x68(%r13), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x16ce0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x11f77
movl 0x2c(%r14), %r8d
cmpq %r8, 0x188(%rbx)
jbe 0x172ae
movq 0x180(%rbx), %rax
movq (%rax,%r8,8), %rax
movl $0xc, (%rax)
movq %r15, %rdi
callq 0xef89
movq %r14, %rdi
callq 0xef89
incl 0x614(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xe20b(%rip), %rsi      # 0x254c0
leaq 0xe9b8(%rip), %rcx      # 0x25c74
movq %rbx, %rdi
movl $0x143, %edx            # imm = 0x143
jmp 0x17312
leaq 0xe73f(%rip), %rsi      # 0x25a0c
leaq 0xe771(%rip), %rcx      # 0x25a45
movq %rbx, %rdi
movl $0x7c, %edx
jmp 0x172f4
leaq 0xe1db(%rip), %rsi      # 0x254c0
leaq 0xe988(%rip), %rcx      # 0x25c74
movq %rbx, %rdi
movl $0x143, %edx            # imm = 0x143
movl %eax, %r8d
jmp 0x17312
leaq 0xe1c0(%rip), %rsi      # 0x254c0
leaq 0xe96d(%rip), %rcx      # 0x25c74
movq %rbx, %rdi
movl $0x143, %edx            # imm = 0x143
movl %r12d, %r8d
xorl %eax, %eax
callq 0xca73
leaq 0xf12f(%rip), %rdi      # 0x2644f
leaq 0xeded(%rip), %rsi      # 0x26114
leaq 0xf13c(%rip), %rcx      # 0x2646a
movl $0x98c, %edx            # imm = 0x98C
callq 0x31e0
leaq 0xf182(%rip), %rdi      # 0x264c1
leaq 0xedce(%rip), %rsi      # 0x26114
leaq 0xf11d(%rip), %rcx      # 0x2646a
movl $0x98d, %edx            # imm = 0x98D
callq 0x31e0