                           | InvalidSwitchLayout
                           | InvalidIndirectBranchOperands
                           | KnotTyingFailure
+                          | TypeKnotTyingFailure
                           | InvalidSelectArgs !Int
                           | InvalidExtractElementInst !Int
                           | InvalidInsertElementInst !Int

  s <- get
  return (ir, s)

translateType :: TypePtr -> KnotMonad Type
translateType tp = do
  s <- get
  case M.lookup (ptrToIntPtr tp) (typeMap s) of
    Just t -> return t
    Nothing -> translateType' tp

{-
cTypeTag :: TypePtr -> IO TypeTag
cTypeSize :: TypePtr -> IO Int
cTypeIsVarArg :: TypePtr -> IO Bool
cTypeIsPacked :: TypePtr -> IO Bool
cTypeList :: TypePtr -> IO [TypePtr]
cTypeInner :: TypePtr -> IO TypePtr
cTypeName :: TypePtr -> IO String
cTypeAddrSpace :: TypePtr -> IO Int
-}
translateType' :: TypePtr -> KnotMonad Type
translateType' tp = do
  s <- get
  tag <- liftIO $ cTypeTag tp
  t <- case tag of

  name <- liftIO $ cValueName vp
  typePtr <- liftIO $ cValueType vp
  dataPtr <- liftIO $ cValueData vp
  tt <- translateType finalState typePtr

  uid <- nextId

