// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %esi
callq 0x20ee0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x60(%rax), %esi
callq 0x1ee20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x5, (%rax)
je 0x2779d
jmp 0x27970
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x64(%rax), %esi
callq 0x20ee0
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x277c3
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x277cd
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x20ee0
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x277f5
jmp 0x27814
leaq 0x17f2c(%rip), %rdi     # 0x3f728
leaq 0x17bea(%rip), %rsi     # 0x3f3ed
movl $0x98c, %edx            # imm = 0x98C
leaq 0x17f34(%rip), %rcx     # 0x3f743
callq 0x31c0
movq -0x28(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x48(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x27826
jmp 0x27845
leaq 0x17f6d(%rip), %rdi     # 0x3f79a
leaq 0x17bb9(%rip), %rsi     # 0x3f3ed
movl $0x98d, %edx            # imm = 0x98D
leaq 0x17f03(%rip), %rcx     # 0x3f743
callq 0x31c0
movq -0x28(%rbp), %rax
cmpl $0x4, (%rax)
je 0x2785c
movq -0x28(%rbp), %rax
cmpl $0x5, (%rax)
je 0x2785c
jmp 0x27970
movq -0x38(%rbp), %rax
cmpl $0x4, (%rax)
je 0x27873
movq -0x38(%rbp), %rax
cmpl $0x5, (%rax)
je 0x27873
jmp 0x27970
movq -0x48(%rbp), %rax
cmpl $0x4, (%rax)
je 0x2788a
movq -0x48(%rbp), %rax
cmpl $0x5, (%rax)
je 0x2788a
jmp 0x27970
movq -0x10(%rbp), %rdx
movl $0x70, %edi
movl $0x1b, %esi
callq 0x265e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x2c(%rcx), %rcx
movq %rcx, 0x2c(%rax)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x5c(%rcx), %rcx
movq %rcx, 0x58(%rax)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x64(%rcx), %rcx
movq %rcx, 0x60(%rax)
movl -0x3c(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x50(%rbp), %rax
movl 0x64(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x6c(%rax)
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
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), %rsi
callq 0x20cf0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %esi
callq 0x20ee0
movl $0xc, (%rax)
movq -0x10(%rbp), %rdi
callq 0x1cad0
movq -0x18(%rbp), %rdi
callq 0x1cad0
movq -0x8(%rbp), %rax
movl 0x614(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x614(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)