

def _translate_rol(self, tb, instruction):
    oprnd0 = tb.read(instruction.operands[0])
    oprnd1 = tb.read(instruction.operands[1])
    size = tb.immediate(oprnd0.size, oprnd0.size)
    if (self._arch_mode == ARCH_X86_MODE_32):
        count_mask = tb.immediate(31, oprnd0.size)
    elif (self._arch_mode == ARCH_X86_MODE_64):
        count_mask = tb.immediate(63, oprnd0.size)
    count_masked = tb.temporal(oprnd0.size)
    count = tb.temporal(oprnd0.size)
    oprnd_ext = tb.temporal((oprnd0.size * 2))
    oprnd_ext_shifted = tb.temporal((oprnd0.size * 2))
    oprnd_ext_shifted_l = tb.temporal(oprnd0.size)
    oprnd_ext_shifted_h = tb.temporal(oprnd0.size)
    temp_count = tb.temporal(oprnd_ext.size)
    result = tb.temporal(oprnd0.size)
    result_msb = tb.temporal(1)
    tmp0 = tb.temporal(1)
    tmp0_zero = tb.temporal(1)
    imm0 = tb.immediate(1, oprnd0.size)
    imm1 = tb.immediate((- oprnd0.size), (oprnd0.size * 2))
    imm2 = tb.immediate((- (oprnd0.size + 1)), oprnd0.size)
    tb.add(self._builder.gen_str(oprnd1, count))
    tb.add(self._builder.gen_and(count, count_mask, count_masked))
    tb.add(self._builder.gen_mod(count_masked, size, temp_count))
    tb.add(self._builder.gen_str(oprnd0, oprnd_ext))
    tb.add(self._builder.gen_bsh(oprnd_ext, temp_count, oprnd_ext_shifted))
    tb.add(self._builder.gen_bsh(oprnd_ext_shifted, imm1, 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(result, self._flags['cf']))
    undef_of_lbl = tb.label('undef_of_lbl')
    tb.add(self._builder.gen_sub(count_masked, imm0, tmp0))
    tb.add(self._builder.gen_bisz(tmp0, tmp0_zero))
    tb.add(self._builder.gen_jcc(tmp0_zero, undef_of_lbl))
    tb.add(self._builder.gen_bsh(result, imm2, result_msb))
    tb.add(self._builder.gen_xor(result_msb, self._flags['cf'], 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_rol/original