def _rep_prefix_end(self, tb, instruction, counter, loop_start_lbl):
        # Define immediate registers
        imm_one = tb.immediate(1, 1)
        counter_imm_one = tb.immediate(1, counter.size)
        end_addr = ReilImmediateOperand((instruction.address + instruction.size) << 8, self._arch_info.address_size + 8)

        # Define temporary registers.
        counter_tmp = tb.temporal(counter.size)
        counter_zero = tb.temporal(1)
        zf_zero = tb.temporal(1)

        tb.add(self._builder.gen_sub(counter, counter_imm_one, counter_tmp))
        tb.add(self._builder.gen_str(counter_tmp, counter))
        tb.add(self._builder.gen_bisz(counter, counter_zero))
        tb.add(self._builder.gen_jcc(counter_zero, end_addr))

        prefix = instruction.prefix

        if prefix in ["rep"]:
            pass
        elif prefix in ["repz", "repe"]:
            tb.add(self._builder.gen_xor(self._flags["zf"], imm_one, zf_zero))
        elif prefix in ["repnz", "repne"]:
            tb.add(self._builder.gen_str(self._flags["zf"], zf_zero))
        else:
            raise Exception("Invalid prefix: %s" % prefix)

        tb.add(self._builder.gen_jcc(zf_zero, end_addr))
        tb.add(self._builder.gen_jcc(imm_one, loop_start_lbl))

# "I/O Instructions"
# ============================================================================ #

# "Enter and Leave Instructions"
# ============================================================================ #
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/arch/x86/x86translator.py/X86Translator._rep_prefix_end/original