;; Replace sequence:
;; <instruction>
;; pop rr
;;
;; With:
;; pop rr
;; <instruction>
;;
;; This frees the stack ASAP and hopefully clash against a PUSH


OLEVEL: 2
OFLAG: 28

REPLACE {{
  $2
  pop $1
}}

IF {{
  !(INSTR($2) IN (jp, jr, ret, call, djnz, rst)) && !NEEDS($2, (sp, $1)) && !IS_LABEL($2) &&
  OP1($2) <> "sp" && OP2($2) <> "sp"
}}

WITH {{
  pop $1
  $2
}}
