def _translate_shr(self, tb, instruction):
        # Flags Affected
        # The CF flag contains the value of the last bit shifted out
        # of the destination operand; it is undefined for SHL and SHR
        # instructions where the count is greater than or equal to the
        # size (in bits) of the destination operand. The OF flag is
        # affected only for 1-bit shifts (see "Description" above);
        # otherwise, it is undefined. The SF, ZF, and PF flags are set
        # according to the result. If the count is 0, the flags are
        # not affected. For a non-zero count, the AF flag is
        # undefined.

        # TODO: Fix flag translation

        oprnd0 = tb.read(instruction.operands[0])
        oprnd1 = tb.read(instruction.operands[1])

        imm0 = tb.immediate(1, oprnd0.size)
        imm1 = tb.immediate((2**oprnd0.size)-1, oprnd0.size)
        imm2 = tb.immediate(-1, oprnd0.size)

        tmp0 = tb.temporal(oprnd0.size)
        tmp1 = tb.temporal(oprnd0.size)
        tmp2 = tb.temporal(oprnd0.size)
        tmp3 = tb.temporal(oprnd0.size)
        tmp4 = tb.temporal(oprnd0.size)
        tmp5 = tb.temporal(oprnd0.size)
        tmp6 = tb.temporal(oprnd0.size)

        # Extend 2nd operand to 1st operand size
        tb.add(self._builder.gen_str(oprnd1, tmp0))

        # Decrement in 1 shift amount
        tb.add(self._builder.gen_sub(tmp0, imm0, tmp1))

        # Negate
        tb.add(self._builder.gen_xor(tmp1, imm1, tmp2))
        tb.add(self._builder.gen_add(tmp2, imm0, tmp3))

        # Shift right
        tb.add(self._builder.gen_bsh(oprnd0, tmp3, tmp4))

        # Save LSB in CF
        tb.add(self._builder.gen_and(tmp4, imm0, tmp5))
        tb.add(self._builder.gen_str(tmp5, self._flags["cf"]))

        # Shift one more time
        tb.add(self._builder.gen_bsh(tmp4, imm2, tmp6))

        if self._translation_mode == FULL_TRANSLATION:
            # Flags : OF
            # TODO: Implement translation for OF flag.

            # Flags : SF, ZF, PF
            self._update_sf(tb, oprnd0, oprnd0, tmp6)
            self._update_zf(tb, oprnd0, oprnd0, tmp6)
            self._update_pf(tb, oprnd0, oprnd0, tmp6)

            # Flags : AF
            self._undefine_flag(tb, self._flags["af"])

        tb.write(instruction.operands[0], tmp6)
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/arch/x86/x86translator.py/X86Translator._translate_shr/original