subroutine extract_bit_rep(ilut, nI, real_sgn, flags, j, store)
! Extract useful terms out of the bit-representation of a walker
integer(n_int), intent(in) :: ilut(0:nIfTot)
integer, intent(out) :: nI(nel), flags
integer, intent(in), optional :: j
type(excit_gen_store_type), intent(inout), optional :: store
real(dp), intent(out) :: real_sgn(lenof_sign)
integer(n_int) :: sgn(lenof_sign)
if (tStoredDets .and. present(j)) then
nI = get_determinant(j)
else if (tBuildOccVirtList .and. present(store)) then
if (tBuildSpinSepLists) then
call decode_bit_det_spinsep(nI, ilut, store)
else
call decode_bit_det_lists(nI, ilut, store)
end if
else
call decode_bit_det(nI, ilut)
end if
sgn = iLut(IlutBits%ind_pop:IlutBits%ind_pop + lenof_sign - 1)
real_sgn = transfer(sgn, real_sgn)
flags = int(iLut(IlutBits%ind_flag))
end subroutine extract_bit_rep