withCFState :: CtrlFlow -> LabelTable -> InstrM () -> InstrM (CtrlFlow, LabelTable, Maybe LastBranch)
withCFState cf lt instr = do
  InstrState { isCtrlFlow = cf', isLabelTable = lt' } <- get
  modify' $ \s -> s { isCtrlFlow = cf, isLabelTable = lt }
  instr
  s' <- get
  modify' $ \s -> s { isCtrlFlow = cf', isLabelTable = lt' }
  let mLastBranch
        | ifLastBranch (isOffset s') lb = Just lb
        | otherwise = Nothing
        where lb = isLastBranch s'
  return (isCtrlFlow s', isLabelTable s', mLastBranch)
withCFState :: CtrlFlow -> LabelTable -> InstrM () -> InstrM (CtrlFlow, LabelTable, Maybe LastBranch)
withCFState cf lt instr = do
  InstrState { isCtrlFlow = cf', isLabelTable = lt' } <- get
  modify' $ \s -> s { isCtrlFlow = cf, isLabelTable = lt }
  instr
  s' <- get
  modify' $ \s -> s { isCtrlFlow = cf', isLabelTable = lt' }
  let mLastBranch
        | ifLastBranch (isOffset s') lb = Just lb
        | otherwise = Nothing
        where lb = isLastBranch s'
  return (isCtrlFlow s', isLabelTable s', mLastBranch)
withCFState cf lt instr = do
  InstrState { isCtrlFlow = cf', isLabelTable = lt' } <- get
  modify' $ \s -> s { isCtrlFlow = cf, isLabelTable = lt }
  instr
  s' <- get
  modify' $ \s -> s { isCtrlFlow = cf', isLabelTable = lt' }
  let mLastBranch
        | ifLastBranch (isOffset s') lb = Just lb
        | otherwise = Nothing
        where lb = isLastBranch s'
  return (isCtrlFlow s', isLabelTable s', mLastBranch)