

def _translate_rcr(self, tb, instruction):
    oprnd0 = tb.read(instruction.operands[0])
    oprnd1 = tb.read(instruction.operands[1])
    size = tb.immediate(oprnd0.size, oprnd0.size)
    msize = tb.immediate((- oprnd0.size), oprnd0.size)
    tmp0 = tb.temporal(oprnd0.size)
    tmp0_1 = tb.temporal(oprnd0.size)
    count = tb.temporal(oprnd0.size)
    temp_count = tb.temporal(oprnd0.size)
    zero = tb.immediate(0, oprnd0.size)
    tmp_cf_ext = tb.temporal((oprnd0.size * 4))
    tmp_cf_ext_1 = tb.temporal((oprnd0.size * 4))
    oprnd_ext = tb.temporal((oprnd0.size * 4))
    oprnd_ext_1 = tb.temporal((oprnd0.size * 4))
    oprnd_ext_2 = tb.temporal((oprnd0.size * 4))
    oprnd_ext_shifted = tb.temporal((oprnd0.size * 4))
    oprnd_ext_shifted_l = tb.temporal(oprnd0.size)
    oprnd_ext_shifted_h = tb.temporal(oprnd0.size)
    oprnd_ext_shifted_h_1 = tb.temporal(oprnd0.size)
    result = tb.temporal(oprnd0.size)
    result_msb = tb.temporal(1)
    result_msb_prev = tb.temporal(1)
    tmp1 = tb.temporal(1)
    tmp1_zero = tb.temporal(1)
    imm1 = tb.immediate(1, oprnd0.size)
    imm7 = tb.immediate((- (oprnd0.size - 1)), oprnd0.size)
    one = tb.immediate(1, (oprnd0.size * 2))
    mone = tb.immediate((- 1), (oprnd0.size * 2))
    cf_old = tb.temporal(1)
    if (oprnd0.size == 8):
        count_mask = tb.immediate(31, oprnd0.size)
        tmp0 = tb.temporal(oprnd0.size)
        count = tb.temporal(oprnd0.size)
        temp_count = tb.temporal(oprnd_ext.size)
        mod_amount = tb.immediate(9, oprnd0.size)
        tb.add(self._builder.gen_str(oprnd1, count))
        tb.add(self._builder.gen_and(count, count_mask, tmp0_1))
        tb.add(self._builder.gen_mod(tmp0_1, mod_amount, tmp0))
    elif (oprnd0.size == 16):
        count_mask = tb.immediate(31, oprnd0.size)
        tmp0 = tb.temporal(oprnd0.size)
        count = tb.temporal(oprnd0.size)
        temp_count = tb.temporal(oprnd_ext.size)
        mod_amount = tb.immediate(17, oprnd0.size)
        tb.add(self._builder.gen_str(oprnd1, count))
        tb.add(self._builder.gen_and(count, count_mask, tmp0_1))
        tb.add(self._builder.gen_mod(tmp0_1, mod_amount, tmp0))
    elif (oprnd0.size == 32):
        count_mask = tb.immediate(31, oprnd0.size)
        tmp0 = tb.temporal(oprnd0.size)
        count = tb.temporal(oprnd0.size)
        temp_count = tb.temporal(oprnd_ext.size)
        tb.add(self._builder.gen_str(oprnd1, count))
        tb.add(self._builder.gen_and(count, count_mask, tmp0))
    elif (oprnd0.size == 64):
        count_mask = tb.immediate(63, oprnd0.size)
        tmp0 = tb.temporal(oprnd0.size)
        count = tb.temporal(oprnd0.size)
        temp_count = tb.temporal(oprnd_ext.size)
        tb.add(self._builder.gen_str(oprnd1, count))
        tb.add(self._builder.gen_and(count, count_mask, tmp0))
    else:
        raise Exception('Invalid operand size: %d', oprnd0.size)
    tb.add(self._builder.gen_sub(zero, tmp0, temp_count))
    tb.add(self._builder.gen_str(self._flags['cf'], cf_old))
    one_1 = tb.immediate(1, oprnd0.size)
    tb.add(self._builder.gen_bsh(oprnd0, one_1, oprnd_ext_1))
    tb.add(self._builder.gen_str(self._flags['cf'], tmp_cf_ext))
    tb.add(self._builder.gen_or(tmp_cf_ext, oprnd_ext_1, oprnd_ext_2))
    size_1 = tb.immediate(oprnd0.size, oprnd_ext_2.size)
    msize_1 = tb.immediate((- oprnd0.size), oprnd_ext_shifted.size)
    mone_1 = tb.immediate((- 1), oprnd_ext_shifted_h_1.size)
    tb.add(self._builder.gen_bsh(oprnd_ext_2, size_1, oprnd_ext))
    tb.add(self._builder.gen_bsh(oprnd_ext, temp_count, oprnd_ext_shifted))
    tb.add(self._builder.gen_bsh(oprnd_ext_shifted, msize_1, oprnd_ext_shifted_h_1))
    tb.add(self._builder.gen_bsh(oprnd_ext_shifted_h_1, mone_1, oprnd_ext_shifted_h))
    tb.add(self._builder.gen_str(oprnd_ext_shifted, oprnd_ext_shifted_l))
    tb.add(self._builder.gen_or(oprnd_ext_shifted_l, oprnd_ext_shifted_h, result))
    tb.add(self._builder.gen_str(oprnd_ext_shifted_h_1, self._flags['cf']))
    undef_of_lbl = tb.label('undef_of_lbl')
    tb.add(self._builder.gen_sub(count, imm1, tmp1))
    tb.add(self._builder.gen_bisz(tmp1, tmp1_zero))
    tb.add(self._builder.gen_jcc(tmp1_zero, undef_of_lbl))
    tb.add(self._builder.gen_bsh(oprnd0, imm7, result_msb))
    tb.add(self._builder.gen_xor(result_msb, cf_old, self._flags['of']))
    tb.add(undef_of_lbl)
    self._undefine_flag(tb, self._flags['of'])
    tb.write(instruction.operands[0], result)

dataset/ETHPy150Open programa-stic/barf-project/barf/barf/arch/x86/x86translator.py X86Translator._translate_rcr/original