New prebuilt linux toolchain x86_64-linux-glibc2.11-4.8

This new toolchain replaces the following toolchains and scripts
in prebuilts/tools/gcc-sdk which call them
  prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6
  prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6

sysroot is upgraded to glibc2.11
gcc is upgraded to gcc4.8

Build instructions:
  CC=${AOSP}/prebuilts/tools/gcc-sdk/gcc \
  CXX=${AOSP}/prebuilts/tools/gcc-sdk/g++ \
    ./build-lucid-multilib-toolchain.sh --gcc-version=4.8

Change-Id: Ibe3e66d9c5e772dcedc555d7019c0604c63cc1b4
diff --git a/PACKAGE_SOURCES b/PACKAGE_SOURCES
new file mode 100644
index 0000000..30b1015
--- /dev/null
+++ b/PACKAGE_SOURCES
@@ -0,0 +1,68 @@
+libacl1_2.2.49-2_amd64.deb                                       8c1aab869dfc913d8a1a5414806632ce6f2bef00
+libacl1_2.2.49-2_i386.deb                                        d12cd952a33929b1a34863547e9a8fe641ee91c5
+libacl1-dev_2.2.49-2_amd64.deb                                   89990ea4125cd8aa9d0ebde26466ee2a4c97e1d5
+libacl1-dev_2.2.49-2_i386.deb                                    bb4a111befdd40758c50d9ce6a3045554a5b0e1a
+libasound2_1.0.22-0ubuntu7_amd64.deb                             bc75880dc4dfbd371ccb8c7954ea76f8c40e89dd
+libasound2_1.0.22-0ubuntu7_i386.deb                              c42d7a9986215f37ef7939fa200ef196c0869db6
+libasound2-dev_1.0.22-0ubuntu7_amd64.deb                         f1059186a7fa82740174e72cb35bc72d63eb346b
+libasound2-dev_1.0.22-0ubuntu7_i386.deb                          83679aa6cfc61e29d3123507f946c73b0beec6d8
+libattr1_2.4.44-1_amd64.deb                                      4eddcc4410e0b1a061db6032de5b010535f1c5fd
+libattr1_2.4.44-1_i386.deb                                       1214092b29bbb4ab5557be9b212edfdbae3dd5f5
+libattr1-dev_2.4.44-1_amd64.deb                                  432f85de2a08fe6584263e5381abb24b4b36d86b
+libattr1-dev_2.4.44-1_i386.deb                                   d0c9636b2165c46da9ac6a89d2fe9b1bb4ab777f
+libaudiofile-dev_0.2.6-8ubuntu1_amd64.deb                        f99d275d80a36f51d8d1a1fb7d6ffa4c66de6d98
+libaudiofile-dev_0.2.6-8ubuntu1_i386.deb                         e5edfba3f6be1ecfa2e0b3f808f9c54f1fa3d912
+libc6_2.11.1-0ubuntu7_amd64.deb                                  53846bbc0d58e37bb2316d31cece4f5a91ed6cbd
+libc6_2.11.1-0ubuntu7_i386.deb                                   9b7380fd0db04b9d9dfe2bde3e13703fe515a99f
+libc6-dev_2.11.1-0ubuntu7_amd64.deb                              f2b119fbe8b5bae88fe56f47bb0fdcffbba2ee30
+libc6-dev_2.11.1-0ubuntu7_i386.deb                               71ca8d0d98f012eee1ad26021636e07125fadf26
+libcap2_2.17-2ubuntu1_amd64.deb                                  cdd7daafb96ba7dd860a3fb6ef9948ae53925853
+libcap2_2.17-2ubuntu1_i386.deb                                   8b5ba99a6d54e2441919e6bce5e77883cd610389
+libcap-dev_2.17-2ubuntu1_amd64.deb                               418e91cf119ec81b8033818d234d74bb72c11c9b
+libcap-dev_2.17-2ubuntu1_i386.deb                                75b4e6bd5a10a1469cd63e29be5c9ceba3c74df7
+libdrm2_2.4.18-1ubuntu3_amd64.deb                                e2c925ace5bdd15e7695c48b0d4b60d311eaa270
+libdrm2_2.4.18-1ubuntu3_i386.deb                                 e059549d61e2f7e4bb13e2fbad697dafe69a7212
+libesd0-dev_0.2.41-6ubuntu1_amd64.deb                            7770f51cd7d20b561c29a1bd9df670f3d46cb6a5
+libesd0-dev_0.2.41-6ubuntu1_i386.deb                             b8143a594bf252b62fb9656302b8f69939f19c8e
+libgl1-mesa-dev_7.7.1-1ubuntu2_amd64.deb                         3b4d547b2c60c01e0a40118b73f90ec837477fc0
+libgl1-mesa-dev_7.7.1-1ubuntu2_i386.deb                          f594d140477889e3e9c1b0e3ccb15ac2f997503d
+libgl1-mesa-glx_7.7.1-1ubuntu2_amd64.deb                         34a43505423654cf90ab569884e2528428c566b7
+libgl1-mesa-glx_7.7.1-1ubuntu2_i386.deb                          07a106df066c0481d86366e2d675d4ff6fa5b27d
+libncurses5_5.7+20090803-2ubuntu3_amd64.deb                      cd4c4617d546cc9bd0555e33061a5c0158b201c4
+libncurses5_5.7+20090803-2ubuntu3_i386.deb                       e6c8f93d386c4f4c744fa842406a29168c7c0ca3
+libncurses5-dev_5.7+20090803-2ubuntu3_amd64.deb                  b4d84b17f26189aecc56ae58aa7df85588d060bb
+libncurses5-dev_5.7+20090803-2ubuntu3_i386.deb                   9211e5c95e7c159e091e21f7307314664c624129
+libpulse0_0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu14_amd64.deb 67d3d10daf6894142ca9507ef77137b822cad6b7
+libpulse0_0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu14_i386.deb 88190b713d6d0b7110f1e90100f445be826758c6
+libpulse-dev_0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu14_amd64.deb 2dca9b76a493493c923a6a3b7efc65148e3d6ab0
+libpulse-dev_0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu14_i386.deb 338e9ea50e7e664a6344d07d993b720cf2749fdc
+libx11-6_1.3.2-1ubuntu3_amd64.deb                                1351b4af7ca37e4f9d30f452209eb13593dd05f1
+libx11-6_1.3.2-1ubuntu3_i386.deb                                 eeacac0b8cd740d0d4972e6ee9942284589fe11a
+libx11-dev_1.3.2-1ubuntu3_amd64.deb                              f61a712eb3505f2642f27847ca3f12bf6508f568
+libx11-dev_1.3.2-1ubuntu3_i386.deb                               05f24f272a02ff73ebe045f9bb750a9362397651
+libxau6_1.0.5-1_amd64.deb                                        fbb9f2e2922cd8562ecd6a309c0cf8a104c5c04b
+libxau6_1.0.5-1_i386.deb                                         e44791a744b5192fa899ffc4771d705fd7266801
+libxcb1-dev_1.5-2_amd64.deb                                      531132520ee6fbe40bea6bdf06202b52ee681e63
+libxcb1-dev_1.5-2_i386.deb                                       ad45c5cc20102406ce1b9e9a80ac782db144bd1f
+libxdamage1_1.1.2-1_amd64.deb                                    eb550d8b130a0d32f2159f55be3f760220c2fb1a
+libxdamage1_1.1.2-1_i386.deb                                     e2244ecdcfb70e77a7d438487757315c040ed45d
+libxdmcp6_1.0.3-1_amd64.deb                                      b547c8ccb14c5f89f8a4349f8213d6cbb8e4c416
+libxdmcp6_1.0.3-1_i386.deb                                       9c6daaa2a4a7eee4f9e9a042f67cdbc84229627e
+libxext6_1.1.1-2_amd64.deb                                       b7e58668040bde7499f3bb73e6b703ae7514611b
+libxext6_1.1.1-2_i386.deb                                        1b2a8d3f1cbbd1856cd76345221059095a07db69
+libxfixes3_4.0.4-1_amd64.deb                                     d0223eeb0c16be26dbc15519eefbf43666634927
+libxfixes3_4.0.4-1_i386.deb                                      e3e9129452999ade9f72f6d0cb7b1dca8dc49af1
+libxxf86vm1_1.1.0-2_amd64.deb                                    a135a90a9a66de6c50e485f341523140415cef6e
+libxxf86vm1_1.1.0-2_i386.deb                                     b18cc44cc63077282959e2f42781f33a78522f3b
+linux-libc-dev_2.6.32-21.32_amd64.deb                            ad87b2e941705ccb9c63278ef0615ecc915a4186
+linux-libc-dev_2.6.32-21.32_i386.deb                             b479afdf88f1155446d1d1a4edcb08564039b800
+mesa-common-dev_7.7.1-1ubuntu2_amd64.deb                         d6784bdf2eff640160e134a6ee4ce94fbc3fc5a7
+mesa-common-dev_7.7.1-1ubuntu2_i386.deb                          1c1800ce6919d027b11d35a472b09d0a569a4994
+x11proto-core-dev_7.0.16-1_all.deb                               0ab813fd530930b1246f866d47413c2102e11472
+x11proto-input-dev_2.0-2_all.deb                                 5dd0850b537904b9217a24438a1370298297b3ad
+x11proto-kb-dev_1.0.4-1_all.deb                                  d86d0e9ceb385b6c068c888c53322fae982e2492
+x11proto-xext-dev_7.1.1-2_all.deb                                084edf539eb884efbd28e2f83362861b3f047d43
+zlib1g_1.2.3.3.dfsg-15ubuntu1_amd64.deb                          5800cde216957124272b39e381a13b75e44949fb
+zlib1g_1.2.3.3.dfsg-15ubuntu1_i386.deb                           274d8dbb86bd0a429dadd80159b9c07e82092e56
+zlib1g-dev_1.2.3.3.dfsg-15ubuntu1_amd64.deb                      37a52be5e0796fc16b3f1267c0ea17a7e8109be4
+zlib1g-dev_1.2.3.3.dfsg-15ubuntu1_i386.deb                       f4c696d8c261498e1f6fdd1ebcc46e206ccf2604
diff --git a/TOOLCHAIN_SOURCES b/TOOLCHAIN_SOURCES
new file mode 100644
index 0000000..066e2f5
--- /dev/null
+++ b/TOOLCHAIN_SOURCES
@@ -0,0 +1,10 @@
+toolchain/binutils.git:          5a2caf34e4995860baf405552163df288000b7bf [2.21, 2.22, 2.23] Backport of the patch for keeping lto sections when linking with "-r" options (ld bfd behaviour).
+toolchain/build.git:             7eae5e66da2793a2a26bcd42357dca1ea6c391b9 Switch x86/x86-64 -mtune from "atom" to more generic "intel"
+toolchain/gcc.git:               283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb Fix host 64-bit gcc4.6 build
+toolchain/gdb.git:               37c2cd1af0dd58048d965bac278fc5d83fea65a0 Fix segfault on 64-bits
+toolchain/gold.git:              8d401cf711539af5a2f78d12447341d774892618 Empty initial commit.
+toolchain/gmp.git:               e6b9669dafc6a5f83c80b4b4176359b78bccdc90 Add gmp-5.0.5.tar.bz2
+toolchain/mpfr.git:              bfcf1bfa38469208aaad8873cd4c68781061d90f add mpfr-3.1.1.tar.bz2
+toolchain/mpc.git:               835d16e92eed875638a8b5d552034c3b1aae045b add mpc-1.0.1.tar.gz
+toolchain/isl.git:               b05d4572958c5d497da793f3317084bab90c3033 add isl-0.11.1.tar.bz2 needed by GCC 4.8 with graphite
+toolchain/cloog.git:             98972d5434ffcb4d11d2c81a46600e9a1cda9110 MinGW-w64 build fix (lacks ffs declaration)
diff --git a/bin/cloog b/bin/cloog
new file mode 100755
index 0000000..e1ac456
--- /dev/null
+++ b/bin/cloog
Binary files differ
diff --git a/bin/x86_64-linux-addr2line b/bin/x86_64-linux-addr2line
new file mode 100755
index 0000000..fb66def
--- /dev/null
+++ b/bin/x86_64-linux-addr2line
Binary files differ
diff --git a/bin/x86_64-linux-ar b/bin/x86_64-linux-ar
new file mode 100755
index 0000000..9f856c1
--- /dev/null
+++ b/bin/x86_64-linux-ar
Binary files differ
diff --git a/bin/x86_64-linux-as b/bin/x86_64-linux-as
new file mode 100755
index 0000000..a46d4cf
--- /dev/null
+++ b/bin/x86_64-linux-as
Binary files differ
diff --git a/bin/x86_64-linux-c++ b/bin/x86_64-linux-c++
new file mode 100755
index 0000000..4edd6e1
--- /dev/null
+++ b/bin/x86_64-linux-c++
Binary files differ
diff --git a/bin/x86_64-linux-c++filt b/bin/x86_64-linux-c++filt
new file mode 100755
index 0000000..4292f89
--- /dev/null
+++ b/bin/x86_64-linux-c++filt
Binary files differ
diff --git a/bin/x86_64-linux-cpp b/bin/x86_64-linux-cpp
new file mode 100755
index 0000000..386e24a
--- /dev/null
+++ b/bin/x86_64-linux-cpp
Binary files differ
diff --git a/bin/x86_64-linux-elfedit b/bin/x86_64-linux-elfedit
new file mode 100755
index 0000000..65c9565
--- /dev/null
+++ b/bin/x86_64-linux-elfedit
Binary files differ
diff --git a/bin/x86_64-linux-g++ b/bin/x86_64-linux-g++
new file mode 100755
index 0000000..4edd6e1
--- /dev/null
+++ b/bin/x86_64-linux-g++
Binary files differ
diff --git a/bin/x86_64-linux-gcc b/bin/x86_64-linux-gcc
new file mode 100755
index 0000000..2ea9b04
--- /dev/null
+++ b/bin/x86_64-linux-gcc
Binary files differ
diff --git a/bin/x86_64-linux-gcc-4.8 b/bin/x86_64-linux-gcc-4.8
new file mode 100755
index 0000000..2ea9b04
--- /dev/null
+++ b/bin/x86_64-linux-gcc-4.8
Binary files differ
diff --git a/bin/x86_64-linux-gcc-ar b/bin/x86_64-linux-gcc-ar
new file mode 100755
index 0000000..cdc9661
--- /dev/null
+++ b/bin/x86_64-linux-gcc-ar
Binary files differ
diff --git a/bin/x86_64-linux-gcc-nm b/bin/x86_64-linux-gcc-nm
new file mode 100755
index 0000000..8d85ba3
--- /dev/null
+++ b/bin/x86_64-linux-gcc-nm
Binary files differ
diff --git a/bin/x86_64-linux-gcc-ranlib b/bin/x86_64-linux-gcc-ranlib
new file mode 100755
index 0000000..c6efe24
--- /dev/null
+++ b/bin/x86_64-linux-gcc-ranlib
Binary files differ
diff --git a/bin/x86_64-linux-gcov b/bin/x86_64-linux-gcov
new file mode 100755
index 0000000..a08bcad
--- /dev/null
+++ b/bin/x86_64-linux-gcov
Binary files differ
diff --git a/bin/x86_64-linux-gprof b/bin/x86_64-linux-gprof
new file mode 100755
index 0000000..1125b15
--- /dev/null
+++ b/bin/x86_64-linux-gprof
Binary files differ
diff --git a/bin/x86_64-linux-ld b/bin/x86_64-linux-ld
new file mode 100755
index 0000000..5ac9266
--- /dev/null
+++ b/bin/x86_64-linux-ld
Binary files differ
diff --git a/bin/x86_64-linux-ld.bfd b/bin/x86_64-linux-ld.bfd
new file mode 100755
index 0000000..a40643b
--- /dev/null
+++ b/bin/x86_64-linux-ld.bfd
Binary files differ
diff --git a/bin/x86_64-linux-ld.gold b/bin/x86_64-linux-ld.gold
new file mode 100755
index 0000000..5ac9266
--- /dev/null
+++ b/bin/x86_64-linux-ld.gold
Binary files differ
diff --git a/bin/x86_64-linux-nm b/bin/x86_64-linux-nm
new file mode 100755
index 0000000..49eb77f
--- /dev/null
+++ b/bin/x86_64-linux-nm
Binary files differ
diff --git a/bin/x86_64-linux-objcopy b/bin/x86_64-linux-objcopy
new file mode 100755
index 0000000..4ac22f1
--- /dev/null
+++ b/bin/x86_64-linux-objcopy
Binary files differ
diff --git a/bin/x86_64-linux-objdump b/bin/x86_64-linux-objdump
new file mode 100755
index 0000000..262293d
--- /dev/null
+++ b/bin/x86_64-linux-objdump
Binary files differ
diff --git a/bin/x86_64-linux-ranlib b/bin/x86_64-linux-ranlib
new file mode 100755
index 0000000..4f400ac
--- /dev/null
+++ b/bin/x86_64-linux-ranlib
Binary files differ
diff --git a/bin/x86_64-linux-readelf b/bin/x86_64-linux-readelf
new file mode 100755
index 0000000..c181ed6
--- /dev/null
+++ b/bin/x86_64-linux-readelf
Binary files differ
diff --git a/bin/x86_64-linux-size b/bin/x86_64-linux-size
new file mode 100755
index 0000000..2de52ab
--- /dev/null
+++ b/bin/x86_64-linux-size
Binary files differ
diff --git a/bin/x86_64-linux-strings b/bin/x86_64-linux-strings
new file mode 100755
index 0000000..0e4dd24
--- /dev/null
+++ b/bin/x86_64-linux-strings
Binary files differ
diff --git a/bin/x86_64-linux-strip b/bin/x86_64-linux-strip
new file mode 100755
index 0000000..2fbeb57
--- /dev/null
+++ b/bin/x86_64-linux-strip
Binary files differ
diff --git a/build-lucid-multilib-toolchain.sh b/build-lucid-multilib-toolchain.sh
new file mode 100755
index 0000000..1c133b8
--- /dev/null
+++ b/build-lucid-multilib-toolchain.sh
@@ -0,0 +1,1800 @@
+#!/bin/bash
+#
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This script is used to rebuild the Linux 32-bit cross-toolchain
+# that allows you to generate 32-bit binaries that target Ubuntu 8.04
+# (a.k.a. Hardy Heron) instead of the host system (which usually is 10.04,
+# a.k.a. Lucid Lynx)
+#
+# Use --help for complete usage information.
+#
+# WARNING: At this time, the generated toolchain binaries will *not* run
+#          with GLibc 2.11, only the machine code it generates.
+#
+
+PROGNAME="`basename \"$0\"`"
+PATCHES_DIR="$( cd "$( dirname "$0" )" && pwd )/toolchain-patches"
+
+###########################################################################
+###########################################################################
+#####
+#####  C O N F I G U R A T I O N
+#####
+###########################################################################
+###########################################################################
+
+panic ()
+{
+    echo "ERROR: $@"
+    exit 1
+}
+
+fail_panic ()
+{
+    if [ $? != 0 ] ; then
+        echo "ERROR: $@"
+        exit 1
+    fi
+}
+
+
+# We only support running this script on Linux
+OS=$(uname -s)
+if [ "$OS" != Linux ]; then
+    panic "This script can only run on Linux machines!"
+fi
+
+UBUNTU_ARCHS="i386 amd64"
+
+# Used to set the host bitness of the generted toolchain binaries
+# First call with the build machine's bitness, and later with 32
+# if --32-bits option is used.
+# $1: 32 or 64
+set_host_bits ()
+{
+    HOST_BITS=$1
+    GMP_ABI=$1
+    case $1 in
+        32)
+            HOST_ARCH=i686
+            GCC_TARGET=i686-linux
+            GMP_TARGET=i386-linux
+            ;;
+        64)
+            HOST_ARCH=x86_64
+            GCC_TARGET=x86_64-linux
+            GMP_TARGET=x86_64-linux
+            ;;
+        *)
+            panic "Invalid host bitness (32 or 64 expected): $1"
+    esac
+}
+
+# Determine build machine bitness
+BUILD_ARCH=$(uname -m)
+case "$BUILD_ARCH" in
+    x86_64|amd64)
+        BUILD_BITS=64
+        BUILD_ARCH=x86_64
+        BUILD_GCC_TARGET=x86_64-linux
+        set_host_bits 64
+        ;;
+    i?86)
+        BUILD_BITS=32
+        BUILD_ARCH=i686
+        BUILD_GCC_TARGET=i686-linux
+        set_host_bits 32
+        ;;
+    *)
+        panic "Unknown build CPU architecture: $BUILD_ARCH"
+esac
+
+# Versions of various toolchain components, do not touch unless you know
+# what you're doing!
+
+BINUTILS_VERSION=2.23
+GMP_VERSION=5.0.5
+MPFR_VERSION=3.1.1
+MPC_VERSION=1.0.1
+GCC_VERSION=4.6
+CLOOG_VERSION=0.18.0
+ISL_VERSION=0.11.1
+
+GLIBC_VERSION=2.11
+
+GIT_CMD=git
+GIT_DATE=
+GIT_BRANCH=master
+GIT_REFERENCE=
+GIT_BASE=
+GIT_BASE_DEFAULT=https://android.googlesource.com/toolchain
+
+# Location where we're going to install the toolchain during the build
+# This will depend on the phase of the build.
+install_dir () { echo "$WORK_DIR/$PHASE/$TOOLCHAIN_NAME"; }
+
+# Given an input string that looks like <major>.<minor>.<patch>
+# Return <major>.<minor> only.
+major_minor_only () {
+   local MAJOR=$(echo -n "$1" | cut -f1 -d.)
+   local MINOR=$(echo -n "$1" | cut -f2 -d.)
+   echo "$MAJOR.$MINOR"
+}
+
+# Location where we're going to install the final binaries
+# If empty, TOOLCHAIN_ARCHIVE will be generated
+PREFIX_DIR=
+
+# Location of the final sysroot. This must be a sub-directory of INSTALL_DIR
+# to ensure that the toolchain binaries are properly relocatable (i.e. can
+# be used when moved to another directory).
+sysroot_dir () { echo "$(install_dir)/sysroot"; }
+
+# Try to parallelize the build for faster performance.
+JOBS=$(cat /proc/cpuinfo | grep -c processor)
+
+# The base URL of the Ubuntu mirror we're going to use.
+UBUNTU_MIRROR=http://mirrors.us.kernel.org
+
+# Ubuntu release name we want packages from. Can be a name or a number
+# (i.e. "lucid" or "10.04")
+UBUNTU_RELEASE=lucid
+
+
+# The list of packages we need to download from the Ubuntu servers and
+# extract into the original sysroot
+#
+# Call add_ubuntu_package <package-name> to add a package to the list,
+# which will be processed later.
+#
+UBUNTU_PACKAGES=
+
+add_ubuntu_package ()
+{
+    UBUNTU_PACKAGES="$UBUNTU_PACKAGES $@"
+}
+
+# The package files containing kernel headers for Hardy and the C
+# library headers and binaries
+add_ubuntu_package \
+    linux-libc-dev \
+    libc6 \
+    libc6-dev \
+    libcap2 \
+    libcap-dev \
+    libattr1 \
+    libattr1-dev \
+    libacl1 \
+    libacl1-dev \
+
+# The X11 headers and binaries (for the emulator)
+add_ubuntu_package \
+    libx11-6 \
+    libx11-dev \
+    libxcb1-dev \
+    libxau6 \
+    libxdmcp6 \
+    x11proto-core-dev \
+    x11proto-xext-dev \
+    x11proto-input-dev \
+    x11proto-kb-dev
+
+# The OpenGL-related headers and libraries (for GLES emulation)
+add_ubuntu_package \
+    mesa-common-dev \
+    libgl1-mesa-dev \
+    libgl1-mesa-glx \
+    libxxf86vm1 \
+    libxext6 \
+    libxdamage1 \
+    libxfixes3 \
+    libdrm2
+
+# Audio libraries (required by the emulator)
+add_ubuntu_package \
+    libasound2 \
+    libasound2-dev \
+    libesd0-dev \
+    libaudiofile-dev \
+    libpulse0 \
+    libpulse-dev
+
+# ZLib and others.
+add_ubuntu_package \
+    zlib1g \
+    zlib1g-dev \
+    libncurses5 \
+    libncurses5-dev
+
+
+
+###########################################################################
+###########################################################################
+#####
+#####  E N D   O F   C O N F I G U R A T I O N
+#####
+###########################################################################
+###########################################################################
+
+# Parse all options
+OPTION_HELP=no
+VERBOSE=0
+FORCE=no
+ONLY_SYSROOT=no
+ONLY_TOOLCHAIN_DIR=
+BOOTSTRAP=
+PARAMETERS=
+FORCE_32=
+LIST_TASKS=
+
+for opt do
+  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
+  case $opt in
+  --help|-h|-\?) OPTION_HELP=yes
+  ;;
+  --verbose) VERBOSE=$(( $VERBOSE + 1 ))
+  ;;
+  --force) FORCE="yes"
+  ;;
+  --32-bits) FORCE_32=true
+  ;;
+  --ubuntu-mirror=*) UBUNTU_MIRROR=$optarg
+  ;;
+  --ubuntu-release=*) UBUNTU_RELEASE=$optarg
+  ;;
+  --prefix=*) PREFIX_DIR=$optarg
+  ;;
+  --work-dir=*) WORK_DIR=$optarg
+  ;;
+  --gcc-version=*) GCC_VERSION=$optarg
+  ;;
+  --binutils-version=*) BINUTILS_VERSION=$optarg
+  ;;
+  --gmp-version=*) GMP_VERSION=$optarg
+  ;;
+  --mpfr-version=*) MPFR_VERSION=$optarg
+  ;;
+  --mpc-version=*) MPC_VERSION=$optarg
+  ;;
+  --isl-version=*) ISL_VERSION=$optarg
+  ;;
+  --cloog-version=*) CLOOG_VERSION=$oparg
+  ;;
+  --git=*) GIT_CMD=$optarg
+  ;;
+  --git-date=*) GIT_DATE=$optarg
+  ;;
+  --git-branch=*) GIT_BRANCH=$optarg
+  ;;
+  --git-base=*) GIT_BASE=$optarg
+  ;;
+  --git-reference=*) GIT_REFERENCE=$optarg
+  ;;
+  --out-dir=*) OPTION_OUT_DIR=$optarg
+  ;;
+  --cc=*) OPTION_CC=$optarg
+  ;;
+  --jobs=*) JOBS=$optarg
+  ;;
+  -j*) JOBS=${opt#-j}
+  ;;
+  --only-sysroot) ONLY_SYSROOT=yes
+  ;;
+  --bootstrap) BOOTSTRAP=yes
+  ;;
+  --list-tasks) LIST_TASKS=yes
+  ;;
+  -*)
+    echo "unknown option '$opt', use --help"
+    exit 1
+    ;;
+  *)
+    if [ -z "$PARAMETERS" ]; then
+        PARAMETERS=$opt
+    else
+        PARAMETERS="$PARAMETERS $opt"
+    fi
+  esac
+done
+
+if [ "$OPTION_HELP" = "yes" ]; then
+    cat << EOF
+
+Usage: $PROGNAME [options] [<path-to-toolchain-sources>]
+
+This script is used to rebuild a custom Linux host toolchain that targets
+GLibc $GLIBC_VERSION or higher. The machine code generated by this toolchain
+will run properly on Ubuntu $UBUNTU_RELEASE or higher.
+
+If you're running on a 32-bit system, it will generate a 32-bit toolchain.
+If you're running on a 64-bit system, it will generate a 64-bit toolchain
+unless you use the --32-bits option.
+
+You can provide the path to a local copy of the toolchain sources repository
+as a first parameter. If you don't, the sources will be downloaded and
+extracted automatically into your work directory.
+
+Note that this script will download various binary packages from Ubuntu
+servers in order to prepare a compatible "sysroot".
+
+By default, it generates a package archive ($TOOLCHAIN_ARCHIVE) but you can,
+as an alternative, ask for direct installation with --prefix=<path>
+
+Use the bootstrap option to re-generate the toolchain with itself. This is
+useful if you want to ensure that the generated compiler binaries will work
+properly on Ubuntu 8.04 or higher. By default, they will only run on systems
+that match your build system's C library ABI, or higher.
+
+Options: [defaults in brackets after descriptions]
+EOF
+    echo "Standard options:"
+    echo "  --help                        Print this message"
+    echo "  --force                       Force-rebuild everything"
+    echo "  --prefix=PATH                 Installation path [$PREFIX_DIR]"
+    echo "  --ubuntu-mirror=URL           Ubuntu mirror URL [$UBUNTU_MIRROR]"
+    echo "  --ubuntu-release=NAME         Ubuntu release name [$UBUNTU_RELEASE]"
+    echo "  --work-dir=PATH               Temporary work directory [/tmp/gcc.<random>]"
+    echo "  --only-sysroot                Only download and build sysroot packages"
+    echo "  --verbose                     Verbose output. Can be used twice."
+    echo "  --binutils-version=VERSION    Binutils version number [$BINUTILS_VERSION]"
+    echo "  --gcc-version=VERSION         GCC version number [$GCC_VERSION]"
+    echo "  --gmp-version=VERSION         GMP version number [$GMP_VERSION]"
+    echo "  --mpfr-version=VERSION        MPFR version numner [$MPFR_VERSION]"
+    echo "  --mpc-version=VERSION         MPC version number [$MPC_VERSION]"
+    echo "  --isl-version=VERSION         ISL version number [$ISL_VERSION]"
+    echo "  --cloog-version=VERSION       Cloog version number [$CLOOG_VERSION]"
+    echo "  --jobs=COUNT                  Run COUNT build jobs in parallel [$JOBS]"
+    echo "  -j<COUNT>                     Same as --jobs=COUNT."
+    echo "  --git=<cmd>                   Use this version of the git tool [$GIT_CMD]"
+    echo "  --git-date=<date>             Specify specific git date when download sources [none]"
+    echo "  --git-branch=<name>           Specify which branch to use when downloading the sources [$GIT_BRANCH]"
+    echo "  --git-reference=<path>        Use a git reference repository"
+    echo "  --git-base=<url>              Use this git repository base [$GIT_BASE]"
+    echo "  --bootstrap                   Bootstrap toolchain (i.e. compile it with itself)"
+    echo "  --32-bits                     Generate 32-bit toolchain on 64-bit build system."
+    echo ""
+    exit 1
+fi
+
+if [ "$FORCE_32" ]; then
+    if [ "$BUILD_BITS" = 64 ]; then
+        set_host_bits 32
+    else
+       echo "Warning: --32-bits option ignored on 32-bit build machine."
+    fi
+fi
+
+# Determine root working directory for our script
+if [ -z "$WORK_DIR" ]; then
+    WORK_DIR=$(mktemp -d /tmp/$USER-gcc-$HOST_BITS-XXXXXX)
+    WORK_DIR_CLEANUP=true
+else
+    mkdir -p "$WORK_DIR"
+    fail_panic "Could not create directory: $WORK_DIR"
+    WORK_DIR_CLEANUP=false
+fi
+
+if [ -z "$PARAMETERS" ] ; then
+    if [ -n "$GIT_REFERENCE" ] ; then
+        if [ ! -d "$GIT_REFERENCE" -o ! -d "$GIT_REFERENCE/build" ]; then
+            echo "ERROR: Invalid reference repository directory path: $GIT_REFERENCE"
+            exit 1
+        fi
+        if [ -n "$GIT_BASE" ]; then
+            echo "Using git clone reference: $GIT_REFERENCE"
+        else
+            # If we have a reference without a base, use it as a download base instead.
+            GIT_BASE=$GIT_REFERENCE
+            GIT_REFERENCE=
+            echo "Using git clone base: $GIT_BASE"
+        fi
+    elif [ -z "$GIT_BASE" ]; then
+        GIT_BASE=$GIT_BASE_DEFAULT
+        echo "Auto-config: --git-base=$GIT_BASE"
+    fi
+
+    # Location where we will download the toolchain sources
+    TOOLCHAIN_SRC_DIR=$WORK_DIR/toolchain-src
+else
+    set_parameters () {
+        TOOLCHAIN_SRC_DIR="$1"
+        if [ ! -d "$TOOLCHAIN_SRC_DIR" ]; then
+            echo "ERROR: Not a directory: $1"
+            exit 1
+        fi
+        if [ ! -d "$TOOLCHAIN_SRC_DIR/build" ]; then
+            echo "ERROR: Missing directory: $1/build"
+            exit 1
+        fi
+    }
+
+    set_parameters $PARAMETERS
+fi
+
+# Location of original sysroot. This is where we're going to extract all
+# binary Ubuntu packages.
+ORG_SYSROOT_DIR=$WORK_DIR/sysroot
+
+# Name of the final generated toolchain
+TOOLCHAIN_NAME=$GCC_TARGET-glibc$GLIBC_VERSION-$(major_minor_only $GCC_VERSION)
+
+# Name of the final toolchain binary tarball that this script will create
+TOOLCHAIN_ARCHIVE=/tmp/$TOOLCHAIN_NAME.tar.bz2
+
+# A file that will contain details about all the sources used to generate
+# the final toolchain. This includes both SHA-1 for toolchain git repositories
+# and SHA-1 hashes for downloaded Ubuntu packages.
+SOURCES_LIST=$WORK_DIR/SOURCES
+
+# Determine Make flags
+MAKE_FLAGS="-j$JOBS"
+
+# Create the work directory
+mkdir -p "$WORK_DIR"
+mkdir -p "$TOOLCHAIN_SRC_DIR"
+
+# Location where we download packages from the Ubuntu servers
+DOWNLOAD_DIR=$WORK_DIR/download
+
+# Empty the SOURCES file
+rm -f "$SOURCES_LIST" && touch "$SOURCES_LIST"
+
+
+if [ "$VERBOSE" -ge 1 ] ; then
+    run () {
+        echo "## COMMAND: $@"
+        $@
+    }
+    log () {
+        echo "$@"
+    }
+    if [ "$VERBOSE" -ge 2 ] ; then
+        log2 () {
+            echo "$@"
+        }
+    else
+        log2 () {
+            return
+        }
+    fi
+else
+    run () {
+        "$@" >>$TMPLOG 2>&1
+    }
+    log () {
+        return
+    }
+    log2 () {
+        return
+    }
+fi
+
+# Sanitize a path list, we want to remove empty sub-dirs and
+# leading/trailing columns.
+sanitize_path_list ()
+{
+  local RESULT
+  RESULT=$(printf "%s\n" "$*" | tr ':' '\n' | awk '$1 != "" && $1 != "." { print $0; }' | tr '\n' ':')
+  printf "%s" ${RESULT%:}
+}
+
+BUILD_DIR=$WORK_DIR/build
+mkdir -p $BUILD_DIR
+
+TMPLOG=$BUILD_DIR/build.log
+rm -rf $TMPLOG && touch $TMPLOG
+
+build_dir_for () { echo "$BUILD_DIR/$PHASE/$1"; }
+
+TIMESTAMPS_DIR=$BUILD_DIR/timestamps
+mkdir -p $TIMESTAMPS_DIR
+
+stamp_check () {
+    [ -f "$TIMESTAMPS_DIR/$1" ]
+}
+
+stamp_clear () {
+    rm -f "$TIMESTAMPS_DIR/$1"
+}
+
+stamp_set () {
+    touch "$TIMESTAMPS_DIR/$1"
+}
+
+if [ "$FORCE" = "yes" ] ; then
+    echo "Cleaning up timestamps (forcing the build)."
+    rm -f $TIMESTAMPS_DIR/*
+fi
+
+if [ "$VERBOSE" = 0 ] ; then
+    echo "To follow build, run: tail -F $TMPLOG"
+fi
+
+# returns 0 iff the string in $2 matches the pattern in $1
+# $1: pattern
+# $2: string
+pattern_match ()
+{
+    echo "$2" | grep -q -E -e "$1"
+}
+
+# Find if a given shell program is available.
+# We need to take care of the fact that the 'which <foo>' command
+# may return either an empty string (Linux) or something like
+# "no <foo> in ..." (Darwin). Also, we need to redirect stderr
+# to /dev/null for Cygwin
+#
+# $1: variable name
+# $2: program name
+#
+# Result: set $1 to the full path of the corresponding command
+#         or to the empty/undefined string if not available
+#
+find_program ()
+{
+    local PROG
+    PROG=`which $2 2>/dev/null`
+    if [ -n "$PROG" ] ; then
+        if pattern_match '^no ' "$PROG"; then
+            PROG=
+        fi
+    fi
+    eval $1="$PROG"
+}
+
+# Copy a directory, create target location if needed
+#
+# $1: source directory
+# $2: target directory location
+#
+copy_directory ()
+{
+    local SRCDIR="$1"
+    local DSTDIR="$2"
+    if [ ! -d "$SRCDIR" ] ; then
+        panic "Can't copy from non-directory: $SRCDIR"
+    fi
+    log2 "Directory copy: $SRCDIR -> $DSTDIR"
+    mkdir -p "$DSTDIR" && (cd "$SRCDIR" && tar cf - *) | (tar xf - -C "$DSTDIR")
+    fail_panic "Cannot copy to directory: $DSTDIR"
+}
+
+find_program CMD_WGET wget
+find_program CMD_CURL curl
+find_program CMD_SCP  scp
+
+# Download a file with either 'curl', 'wget' or 'scp'
+#
+# $1: source URL (e.g. http://foo.com, ssh://blah, /some/path)
+# $2: target file
+download_file ()
+{
+    # Is this HTTP, HTTPS or FTP ?
+    if pattern_match "^(http|https|ftp):.*" "$1"; then
+        if [ -n "$CMD_WGET" ] ; then
+            run $CMD_WGET -O $2 $1
+        elif [ -n "$CMD_CURL" ] ; then
+            run $CMD_CURL -o $2 $1
+        else
+            echo "Please install wget or curl on this machine"
+            exit 1
+        fi
+        return
+    fi
+
+    # Is this SSH ?
+    # Accept both ssh://<path> or <machine>:<path>
+    #
+    if pattern_match "^(ssh|[^:]+):.*" "$1"; then
+        if [ -n "$CMD_SCP" ] ; then
+            scp_src=`echo $1 | sed -e s%ssh://%%g`
+            run $CMD_SCP $scp_src $2
+        else
+            echo "Please install scp on this machine"
+            exit 1
+        fi
+        return
+    fi
+
+    # Is this a file copy ?
+    # Accept both file://<path> or /<path>
+    #
+    if pattern_match "^(file://|/).*" "$1"; then
+        cp_src=`echo $1 | sed -e s%^file://%%g`
+        run cp -f $cp_src $2
+        return
+    fi
+
+    # Unknown schema
+    echo "ERROR: Unsupported source URI: $1"
+    exit 1
+}
+
+# A variant of 'download_file' used to specify the target directory
+# $1: source URL
+# $2: target directory
+download_file_to ()
+{
+    local URL="$1"
+    local DIR="$2"
+    local DST="$DIR/`basename $URL`"
+    mkdir -p $DIR
+    download_file "$URL" "$DST"
+}
+
+# Pack a given archive
+#
+# $1: archive file path (including extension)
+# $2: source directory for archive content
+# $3+: list of files (including patterns), all if empty
+pack_archive ()
+{
+    local ARCHIVE="$1"
+    local SRCDIR="$2"
+    local SRCFILES
+    local TARFLAGS ZIPFLAGS
+    shift; shift;
+    if [ -z "$1" ] ; then
+        SRCFILES="*"
+    else
+        SRCFILES="$@"
+    fi
+    if [ "`basename $ARCHIVE`" = "$ARCHIVE" ] ; then
+        ARCHIVE="`pwd`/$ARCHIVE"
+    fi
+    mkdir -p `dirname $ARCHIVE`
+    if [ "$VERBOSE" -ge 2 ] ; then
+        TARFLAGS="vcf"
+        ZIPFLAGS="-9r"
+    else
+        TARFLAGS="cf"
+        ZIPFLAGS="-9qr"
+    fi
+    case "$ARCHIVE" in
+        *.zip)
+            (cd $SRCDIR && run zip $ZIPFLAGS "$ARCHIVE" $SRCFILES)
+            ;;
+        *.tar)
+            (cd $SRCDIR && run tar $TARFLAGS "$ARCHIVE" $SRCFILES)
+            ;;
+        *.tar.gz)
+            (cd $SRCDIR && run tar z$TARFLAGS "$ARCHIVE" $SRCFILES)
+            ;;
+        *.tar.bz2)
+            (cd $SRCDIR && run tar j$TARFLAGS "$ARCHIVE" $SRCFILES)
+            ;;
+        *)
+            panic "Unsupported archive format: $ARCHIVE"
+            ;;
+    esac
+}
+
+no_trailing_slash ()
+{
+    echo ${1##/}
+}
+
+# Load the Ubuntu packages file. This is a long text file that will list
+# each package for a given release.
+#
+# $1: Ubuntu mirror base URL (e.g. http://mirrors.us.kernel.org/)
+# $2: Release name
+#
+get_ubuntu_packages_list ()
+{
+    local RELEASE=$2
+    local BASE="`no_trailing_slash \"$1\"`"
+    local SRCFILE DSTFILE
+    for UA in $UBUNTU_ARCHS; do
+        SRCFILE="$BASE/ubuntu/dists/$RELEASE/main/binary-$UA/Packages.bz2"
+        DSTFILE="$DOWNLOAD_DIR/Packages-$UA.bz2"
+        log "Trying to load $SRCFILE"
+        download_file "$SRCFILE" "$DSTFILE"
+        fail_panic "Could not download $SRCFILE"
+        (cd $DOWNLOAD_DIR && bunzip2 -cf Packages-$UA.bz2 > Packages-$UA)
+        fail_panic "Could not uncompress $DSTFILE to Packages-$UA"
+    done
+
+    # Write a small awk script used to extract filenames for a given package
+    cat > $DOWNLOAD_DIR/extract-filename.awk <<EOF
+BEGIN {
+    # escape special characters in package name
+    gsub("\\\\.","\\\\.",PKG)
+    gsub("\\\\+","\\\\+",PKG)
+    FILE = ""
+    PACKAGE = ""
+}
+
+\$1 == "Package:" {
+    if (\$2 == PKG) {
+        PACKAGE = \$2
+    } else {
+        PACKAGE = ""
+    }
+}
+
+\$1 == "Filename:" && PACKAGE == PKG {
+    FILE = \$2
+}
+
+END {
+    print FILE
+}
+EOF
+}
+
+# Convert an unversioned package name into a .deb package URL
+#
+# $1: Package name without version information (e.g. libc6-dev)
+# $2: Ubuntu mirror base URL
+# $3: Ubuntu arch ("i386" or "amd64")
+#
+get_ubuntu_package_deb_url ()
+{
+    # The following is an awk command to parse the Packages file and extract
+    # the filename of a given package.
+    local BASE="`no_trailing_slash \"$1\"`"
+    local FILE=`awk -f "$DOWNLOAD_DIR/extract-filename.awk" -v PKG=$1 $DOWNLOAD_DIR/Packages-$3`
+    if [ -z "$FILE" ]; then
+        log "Could not find filename for package $1"
+        exit 1
+    fi
+    echo "$2/ubuntu/$FILE"
+}
+
+# Does the host compiler generate 32-bit machine code?
+# If not, add the -m32 flag to the compiler name to ensure this.
+#
+compute_host_flags ()
+{
+    HOST_CC=${CC:-gcc}
+    HOST_CXX=${CXX-g++}
+    if [ -n "$USE_CCACHE" ]; then
+        echo -n "Checking for ccache..."
+        find_program CMD_CCACHE ccache
+        if [ -n "$CMD_CCACHE" ] ; then
+            echo "$HOST_CC" | tr ' ' '\n' | grep -q -e "ccache"
+            if [ $? = 0 ] ; then
+                echo "yes (ignored)"
+            else
+                echo "yes"
+                HOST_CC="ccache $HOST_CC"
+                HOST_CXX="ccache $HOST_CXX"
+            fi
+        else
+            echo "no"
+        fi
+    fi
+    echo -n "Checking compiler bitness... "
+    cat > "$BUILD_DIR"/conftest.c << EOF
+#include <stdio.h>
+int main(void) {
+    printf("%d\n",sizeof(void*)*8);
+    return 0;
+}
+EOF
+    $HOST_CC -o "$BUILD_DIR"/conftest "$BUILD_DIR"/conftest.c > "$BUILD_DIR"/conftest.log 2>&1
+    if [ $? != 0 ] ; then
+        echo "Could not compile test program!!"
+        echo "Error log is:"
+        cat "$BUILD_DIR"/conftest.log
+        rm "$BUID_DIR"/conftest.log
+        panic "Need a working build toolchain!"
+    fi
+    HOST_CC_BITS=$("$BUILD_DIR"/conftest)
+    echo -n "$HOST_CC_BITS"
+    case $HOST_CC_BITS in
+        32) # Nothing to do
+            ;;
+        64) # Do we need to force 32-bits
+            if [ "$FORCE_32" ]; then
+                echo " (forcing generation of 32-bit binaries)"
+                HOST_CC=$HOST_CC" -m32"
+                HOST_CXX=$HOST_CXX" -m32"
+            fi
+            ;;
+        *)
+            panic "Unknown bitness (32 or 64 expected) !!"
+    esac
+    echo ""
+    echo "Using build C compiler: $HOST_CC"
+    echo "Using build C++ compiler: $HOST_CXX"
+    echo "GCC target name: $GCC_TARGET"
+    echo "GMP target name: $GMP_TARGET"
+    echo "GMP ABI: $GMP_ABI"
+    export CC="$HOST_CC"
+    export CXX="$HOST_CXX"
+}
+
+compute_host_flags
+
+# Return the value of a given named variable
+# $1: variable name
+#
+# example:
+#    FOO=BAR
+#    BAR=ZOO
+#    echo `var_value $FOO`
+#    will print 'ZOO'
+#
+var_value ()
+{
+    eval echo \$$1
+}
+
+var_list_append ()
+{
+    local VARNAME=$1
+    local VARVAL=`var_value $VARNAME`
+    shift
+    if [ -z "$VARVAL" ] ; then
+        eval $VARNAME=\"$@\"
+    else
+        eval $VARNAME=\"$VARVAL $@\"
+    fi
+}
+
+var_list_prepend ()
+{
+    local VARNAME=$1
+    local VARVAL=`var_value $VARNAME`
+    shift
+    if [ -z "$VARVAL" ] ; then
+        eval $VARNAME=\"$@\"
+    else
+        eval $VARNAME=\"$@ $VARVAL\"
+    fi
+}
+
+_list_first ()
+{
+    echo $1
+}
+
+_list_rest ()
+{
+    shift
+    echo "$@"
+}
+
+_list_reverse ()
+{
+    local I1 I2 I3 I4 I5 I6 I7 I8 I9 REST RET
+    I1=$1; I2=$2; I3=$3; I4=$I4; I5=$I5; I6=$I6; I7=$I7; I8=$I8; I9=$I9
+    shift 9
+    RET=$I9${I8:+" "}$I8${I7:+" "}$I7${I6:+" "}$I6${I5:+" "}$I5${I4:+" "}$I4${I3:+" "}$I3${I2:+" "}$I2${I1:+" "}$I1
+    REST="$*"
+    if [ "$REST" ]; then
+        RET=$(_list_reverse $REST)$RET
+    fi
+    echo "$RET"
+}
+
+var_list_pop_first ()
+{
+    local VARNAME=$1
+    local VARVAL=`var_value $VARNAME`
+    local FIRST=`_list_first $VARVAL`
+    eval $VARNAME=\"`_list_rest $VARVAL`\"
+    echo "$FIRST"
+}
+
+_list_first ()
+{
+    echo $1
+}
+
+_list_rest ()
+{
+    shift
+    echo "$@"
+}
+
+var_list_first ()
+{
+    local VAL=`var_value $1`
+    _list_first $VAL
+}
+
+var_list_rest ()
+{
+    local VAL=`var_value $1`
+    _list_rest $VAL
+}
+
+ALL_TASKS=
+
+# Define a new task for this build script
+# $1: Task name (e.g. build_stuff)
+# $2: Task description
+# $3: Optional: command name (will be cmd_$1 by default)
+#
+task_define ()
+{
+    local TASK="$1"
+    local DESCR="$2"
+    local COMMAND="${3:-cmd_$1}"
+
+    var_list_append ALL_TASKS $TASK
+    task_set $TASK name "$TASK"
+    task_set $TASK descr "$DESCR"
+    task_set $TASK cmd "$COMMAND"
+    task_set $TASK deps ""
+}
+
+# Variant of task define for dual tasks
+# This really defines two tasks named '<task>_1' and '<task>_2"
+# $1: Task base name
+# $2: Task description
+# $3: Optional: command name (will be cmd_$1 by default)
+task2_define ()
+{
+    local TASK="$1"
+    local DESCR="$2"
+    local COMMAND="${3:-cmd_$1}"
+
+    task_define "${TASK}_1" "$DESCR 1/2" "phase_1 $COMMAND"
+    task_define "${TASK}_2" "$DESCR 2/2" "phase_2 $COMMAND"
+}
+
+task_set ()
+{
+    local TASK="$1"
+    local FIELD="$2"
+    shift; shift;
+    eval TASK_${TASK}__${FIELD}=\"$@\"
+}
+
+task_get ()
+{
+    var_value TASK_$1__$2
+}
+
+# return the list of dependencies for a given task
+task_get_deps ()
+{
+    task_get $1 deps
+}
+
+task_get_cmd ()
+{
+    task_get $1 cmd
+}
+
+task_get_descr ()
+{
+    task_get $1 descr
+}
+
+# $1: task name
+# $2+: other tasks this task depends on.
+task_depends ()
+{
+    local TASK="$1"
+    shift;
+    var_list_append TASK_${TASK}__deps $@
+}
+
+# $1: dual task name
+# $2+: other non-dual tasks this dual task depends on
+task2_depends1 ()
+{
+    local TASK="$1"
+    shift
+    var_list_append TASK_${TASK}_1__deps $@
+    var_list_append TASK_${TASK}_2__deps $@
+}
+
+# $1: dual task name
+# $2+: other dual tasks this dual task depends on
+task2_depends2 ()
+{
+    local TASK="$1"
+    local DEP
+    shift
+    for DEP; do
+        var_list_append TASK_${TASK}_1__deps ${DEP}_1
+        var_list_append TASK_${TASK}_2__deps ${DEP}_2
+    done
+}
+
+task_dump ()
+{
+    local TASK
+    for TASK in $ALL_TASKS; do
+        local DEPS="`task_get_deps $TASK`"
+        local CMD="`task_get_cmd $TASK`"
+        local DESCR="`task_get_descr $TASK`"
+        echo "TASK $TASK: $DESCR: $CMD"
+        echo ">  $DEPS"
+    done
+}
+
+task_visit ()
+{
+    task_set $TASK visit 1
+}
+
+task_unvisit ()
+{
+    task_set $TASK visit 0
+}
+
+task_is_visited ()
+{
+    [ `task_get $TASK visit` = 1 ]
+}
+
+task_queue_reset ()
+{
+    TASK_QUEUE=
+}
+
+task_queue_push ()
+{
+    var_list_append TASK_QUEUE $1
+}
+
+task_queue_pop ()
+{
+    local FIRST=`var_list_first TASK_QUEUE`
+    TASK_QUEUE=`var_list_rest TASK_QUEUE`
+}
+
+do_all_tasks ()
+{
+    local TASK
+    local TASK_LIST=
+    task_queue_reset
+    # Clear visit flags
+    for TASK in $ALL_TASKS; do
+        task_unvisit $TASK
+    done
+    task_queue_push $1
+    while [ -n "$TASK_QUEUE" ] ; do
+        TASK=`task_queue_pop`
+        if task_is_visited $TASK; then
+            continue
+        fi
+        # Prepend the task to the list if its timestamp is not set
+        if stamp_check $TASK; then
+            var_list_prepend TASK_LIST $TASK
+        fi
+        # Add all dependencies to the work-queue
+        local SUBTASK
+        for SUBTASK in `task_get_deps $TASK`; do
+            task_queue_push $SUBTASK
+        done
+        task_visit $TASK
+    done
+
+    # Now, TASK_LIST contains the
+}
+
+
+# Return the first item of a space-separated list
+list_first () {
+    set -- "$@"
+    echo "$1"
+}
+
+# Append an item to a given list
+list_append () {
+    local ITEM=$1
+    shift;
+    echo $@${@:+" "}$1
+}
+
+# Return the second-to-last items of a space-separated list
+list_rest () {
+    set -- "$@"
+    shift
+    echo "$@"
+}
+
+# Reverse a space-separated list
+list_reverse ()
+{
+    set -- "$@"
+    local I1 I2 I3 I4 I5 I6 I7 I8 I9 REST RET
+    I1=$1; I2=$2; I3=$3; I4=$4; I5=$5; I6=$6; I7=$7; I8=$8; I9=$9
+    shift; shift; shift; shift; shift; shift; shift; shift; shift;
+    RET=$I9${I9:+" "}$I8${I8:+" "}$I7${I7:+" "}$I6${I6:+" "}$I5${I5:+" "}$I4${I4:+" "}$I3${I3:+" "}$I2${I2:+" "}$I1
+    REST="$*"
+    if [ -n "$REST" ]; then
+        RET=$(list_reverse $REST)" "$RET
+    fi
+    echo "$RET"
+}
+
+# Used to build the list of tasks with a tree post-order traversal, i.e.
+# the list starts at the leaves and finishes with the top level task,
+# so that if task(A) depends on task(B), then A will always appear _after_
+# B in the result.
+#
+# $1: space-separated list of tasks to visit
+# Out: list of all tasks in post-order
+#
+task_build_postorder_list ()
+{
+    local TASK
+    local STACK="$1"
+    local RET=""
+    for TASK in $ALL_TASKS; do
+        stamp_clear $TASK.visit
+    done
+    while true; do
+        # Peek at stack
+        TASK=$(list_first $STACK)
+        #echo >&2 "STACK: ($TASK) '$STACK'"
+        if [ -z "$TASK" ]; then
+            break
+        fi
+        HAS_DEPS=
+        for DEP in $(task_get_deps $TASK); do
+            #echo >&2 "CHECK: '$DEP'"
+            if ! stamp_check $DEP.visit; then
+                STACK=$DEP" "$STACK
+                #echo >&2 "PUSH: '$DEP' => '$STACK'"
+                HAS_DEPS=1
+            fi
+        done
+
+        if [ -z "$HAS_DEPS" ]; then
+            #echo >&2 "ADD: $TASK -> '$RET'"
+            STACK=$(list_rest $STACK)
+            if ! stamp_check $TASK.visit; then
+                RET=$RET${RET:+" "}$TASK
+                stamp_set $TASK.visit
+            fi
+        fi
+    done
+    for TASK in $ALL_TASKS; do
+        stamp_clear $TASK.visit
+    done
+    echo "$RET"
+}
+
+run_task ()
+{
+    # Build the list of tasks, in reverse order (from leafs to last)
+    local TASKS=$(task_build_postorder_list $1)
+    # Do all tasks
+    local TASK DEP DESCR
+
+    # Dump list of tasks:
+#     echo "ALL TASKS:"
+#     for TASK in $TASKS; do
+#         echo "  $TASK"
+#     done
+
+    # Clean timestamps of any tasks whose any of its dependents needs
+    # to be re-done.
+    #
+    for TASK in $TASKS; do
+       for DEP in $(task_get_deps $TASK); do
+            if ! stamp_check $DEP; then
+                #echo "Redo: $TASK due to $DEP"
+                stamp_clear $TASK
+                break
+            fi
+       done
+    done
+
+    for TASK in $TASKS; do
+        DESCR=$(task_get_descr $TASK)
+        if stamp_check $TASK; then
+            echo "Skipping: $DESCR"
+            continue
+        fi
+        echo "Running: $DESCR"
+        if [ "$VERBOSE" -ge 1 ] ; then
+            (eval $(task_get_cmd $TASK))
+        else
+            (eval $(task_get_cmd $TASK)) >> $TMPLOG 2>&1
+        fi
+        if [ $? != 0 ] ; then
+            echo "ERROR: Cannot $DESCR"
+            exit 1
+        fi
+
+        stamp_set $TASK
+    done
+}
+
+# This function is used to clone a source repository either from a given
+# git base or a git reference.
+# $1: project/subdir name
+# $2: path to SOURCES file
+toolchain_clone ()
+{
+    local GITFLAGS
+    GITFLAGS=
+    if [ "$GIT_REFERENCE" ]; then
+        GITFLAGS="$GITFLAGS --shared --reference $GIT_REFERENCE/$1"
+    fi
+    echo "cleaning up toolchain/$1"
+    rm -rf $1
+    fail_panic "Could not clean $(pwd)/$1"
+    echo "downloading sources for toolchain/$1"
+    if [ -d "$GIT_BASE/$1" ]; then
+        log "cloning $GIT_BASE/$1"
+        run $GIT_CMD clone $GITFLAGS $GIT_BASE/$1 $1
+    else
+        log "cloning $GITPREFIX/$1.git"
+        run $GIT_CMD clone $GITFLAGS $GIT_BASE/$1.git $1
+    fi
+    fail_panic "Could not clone $GIT_BASE/$1.git ?"
+    cd $1
+    if [ "$GIT_BRANCH" != "master" ] ; then
+        log "checking out $GIT_BRANCH branch of $1.git"
+        run $GIT_CMD checkout -b $GIT_BRANCH origin/$GIT_BRANCH
+        fail_panic "Could not checkout $1 ?"
+    fi
+    # If --git-date is used, or we have a default
+    if [ -n "$GIT_DATE" ] ; then
+        REVISION=`git rev-list -n 1 --until="$GIT_DATE" HEAD`
+        echo "Using sources for date '$GIT_DATE': toolchain/$1 revision $REVISION"
+        run $GIT_CMD checkout $REVISION
+        fail_panic "Could not checkout $1 ?"
+    fi
+    (printf "%-32s " "toolchain/$1.git: " && git log -1 --format=oneline) >> $2
+    cd ..
+}
+
+task_define download_toolchain_sources "Download toolchain sources from $GIT_BASE "
+cmd_download_toolchain_sources ()
+{
+    local SUBDIRS="binutils build gcc gdb gold gmp mpfr mpc isl cloog"
+    (mkdir -p $TOOLCHAIN_SRC_DIR && cd $TOOLCHAIN_SRC_DIR &&
+    # Create a temporary SOURCES file for the toolchain sources only
+    # It's content will be copied to the final SOURCES file later.
+    SOURCES_LIST=$TOOLCHAIN_SRC_DIR/SOURCES
+    rm -f $SOURCES_LIST && touch $SOURCES_LIST
+    for SUB in $SUBDIRS; do
+        toolchain_clone $SUB $SOURCES_LIST
+    done
+    )
+}
+
+task_define download_ubuntu_packages_list "Download Ubuntu packages list"
+cmd_download_ubuntu_packages_list ()
+{
+    mkdir -p $DOWNLOAD_DIR
+    get_ubuntu_packages_list "$UBUNTU_MIRROR" "$UBUNTU_RELEASE"
+    fail_panic "Unable to download packages list, try --ubuntu-mirror=<url> to use another archive mirror"
+}
+
+task_define download_packages "Download Ubuntu packages"
+task_depends download_packages download_ubuntu_packages_list
+cmd_download_packages ()
+{
+    local PACKAGE PKGURL
+
+    rm -f $DOWNLOAD_DIR/SOURCES && touch $DOWNLOAD_DIR/SOURCES
+    for PACKAGE in $UBUNTU_PACKAGES; do
+        echo "Downloading $PACKAGE"
+	    for UA in $UBUNTU_ARCHS; do
+            PKGURL=`get_ubuntu_package_deb_url $PACKAGE $UBUNTU_MIRROR $UA`
+            echo "URL: $PKGURL"
+            download_file_to $PKGURL $DOWNLOAD_DIR
+            fail_panic "Could not download $PKGURL"
+        done
+    done
+    sha1sum $DOWNLOAD_DIR/*.deb | while read LINE; do
+        PACKAGE=$(basename $(echo $LINE | awk '{ print $2;}'))
+        SHA1=$(echo $LINE | awk '{ print $1; }')
+        printf "%-64s %s\n" $PACKAGE $SHA1 >> $DOWNLOAD_DIR/SOURCES
+    done
+}
+
+task_define build_sysroot "Build sysroot"
+task_depends build_sysroot download_packages
+
+cmd_build_sysroot ()
+{
+    local PACKAGE PKGURL SRC_PKG
+    mkdir -p $SRC_PKG $ORG_SYSROOT_DIR
+    for PACKAGE in $UBUNTU_PACKAGES; do
+	    for UA in $UBUNTU_ARCHS; do
+            PKGURL=`get_ubuntu_package_deb_url $PACKAGE $UBUNTU_MIRROR $UA`
+            SRC_PKG=$DOWNLOAD_DIR/`basename $PKGURL`
+            echo "Extracting $SRC_PKG"
+            dpkg -x $SRC_PKG $ORG_SYSROOT_DIR/$UA
+	    done
+    done
+}
+
+# Now, we need to patch libc.so which is actually a linker script
+# referencing /lib and /usr/lib. Do the same for libpthread.so
+patch_library ()
+{
+    echo "Patching $1"
+    sed -i -e "s! /lib/! !g" -e "s! /usr/lib/! !g" $1
+}
+
+# Used to setup phase 1 the run a command
+phase_1 ()
+{
+    PHASE=1
+    $@
+}
+
+# Used to setup phase 2 then run a command
+phase_2 ()
+{
+    PHASE=1
+    BINPREFIX=$(install_dir)/bin/${GCC_TARGET}-
+    CC=${BINPREFIX}gcc
+    CXX=${BINPREFIX}g++
+    LD=${BINPREFIX}ld
+    AR=${BINPREFIX}ar
+    AS=${BINPREFIX}as
+    RANLIB=${BINPREFIX}ranlib
+    STRIP=${BINPREFIX}strip
+    CC_FOR_TARGET=${BINPREFIX}gcc
+    export CC CXX LD AR AS RANLIB STRIP CC_FOR_TARGET
+    PHASE=2
+    $@
+}
+
+# Return the list of all symbolic links in a given directory, excluding
+# any links in its sub-directories.
+# $1: Sub-directory path.
+find_symlinks_in () {
+    (cd $1 && find . -maxdepth 1 -type l) | sed -e 's|^\./||g'
+}
+
+task2_define copy_sysroot "Fix and copy sysroot"
+task2_depends1 copy_sysroot build_sysroot
+cmd_copy_sysroot ()
+{
+    local SL
+
+    # Copy the content of $BUILD_DIR/lib to $(sysroot_dir)/usr/lib
+    copy_directory $ORG_SYSROOT_DIR/i386/lib $(sysroot_dir)/usr/lib32
+    copy_directory $ORG_SYSROOT_DIR/i386/usr/lib $(sysroot_dir)/usr/lib32
+    copy_directory $ORG_SYSROOT_DIR/i386/usr/include $(sysroot_dir)/usr/include
+
+    copy_directory $ORG_SYSROOT_DIR/amd64/lib $(sysroot_dir)/usr/lib
+    copy_directory $ORG_SYSROOT_DIR/amd64/usr/lib $(sysroot_dir)/usr/lib
+    copy_directory $ORG_SYSROOT_DIR/amd64/usr/include $(sysroot_dir)/usr/include
+
+    for LIB in lib lib32; do
+        # We need to fix the symlink like librt.so -> /lib/librt.so.1
+        # in $(sysroot_dir)/usr/$LIB, they should point to librt.so.1 instead now.
+        SYMLINKS=$(find_symlinks_in $(sysroot_dir)/usr/$LIB)
+        cd $(sysroot_dir)/usr/$LIB
+        for SL in $SYMLINKS; do
+            # convert /lib/libfoo.so.<n> into 'libfoo.so.<n>' for the target
+            local DST=$(readlink $SL 2>/dev/null)
+            local DST2=${DST##/lib/}
+            if [ "$DST2" != "$DST" ]; then
+                echo "Fixing symlink $SL --> $DST"
+                rm $SL && ln -s $DST2 $SL
+            fi
+        done
+        patch_library $(sysroot_dir)/usr/$LIB/libc.so
+        patch_library $(sysroot_dir)/usr/$LIB/libpthread.so
+    done
+}
+
+task_define patch_toolchain_sources "Patch toolchain sources."
+task_depends patch_toolchain_sources download_toolchain_sources
+cmd_patch_toolchain_sources ()
+{
+    log "PATCHES_DIR = $PATCHES_DIR"
+    if [ ! -d "$PATCHES_DIR" ]; then
+        log "$PATCHES_DIR doesn't exist"
+        return 0
+    fi
+
+    local PATCHES=`(cd $PATCHES_DIR && find . -name "*.patch" | sort ) 2> /dev/null`
+    if [ -z "$PATCHES" ] ; then
+        log "No patches files in $PATCHES_DIR"
+        return 0
+    fi
+
+    PATCHES=`echo $PATCHES | sed -e s%^\./%%g`
+    for PATCH in $PATCHES; do
+        PATCHDIR=`dirname $PATCH`
+        PATCHNAME=`basename $PATCH`
+        log "Applying $PATCHNAME into $TOOLCHAIN_SRC_DIR/$PATCHDIR"
+        (cd $TOOLCHAIN_SRC_DIR/$PATCHDIR && patch -p1 < $PATCHES_DIR/$PATCH)
+        fail_panic "Patch failure!! Please check your patches directory!"
+    done
+
+    log "Done patching."
+}
+
+task_define prepare_toolchain_sources "Prepare toolchain sources."
+if [ -n "$GIT_BASE" -o -n "$GIT_REFERENCE" ]; then
+    task_depends prepare_toolchain_sources patch_toolchain_sources
+fi
+cmd_prepare_toolchain_sources ()
+{
+    return
+}
+
+task2_define configure_binutils "Configure binutils-$BINUTILS_VERSION"
+task2_depends1 configure_binutils prepare_toolchain_sources
+task2_depends2 configure_binutils copy_sysroot
+cmd_configure_binutils ()
+{
+    OUT_DIR=$(build_dir_for binutils)
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    run $TOOLCHAIN_SRC_DIR/binutils/binutils-$BINUTILS_VERSION/configure \
+        --prefix=$(install_dir) \
+        --with-sysroot=$(sysroot_dir) \
+        --target=$GCC_TARGET \
+        --enable-gold=default \
+        --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
+        --with-gold-ldflags='-static-libgcc -static-libstdc++' \
+        --with-bugurl=http://source.android.com/source/report-bugs.html
+}
+
+task2_define build_binutils "Build binutils-$BINUTILS_VERSION"
+task2_depends2 build_binutils configure_binutils
+cmd_build_binutils ()
+{
+    cd $(build_dir_for binutils) &&
+    make $MAKE_FLAGS
+}
+
+task2_define install_binutils "Install binutils-$BINUTILS_VERSION"
+task2_depends2 install_binutils build_binutils
+cmd_install_binutils ()
+{
+    cd $(build_dir_for binutils) &&
+    make install
+}
+
+task2_define extract_gmp "Extract sources for gmp-$GMP_VERSION"
+task2_depends1 extract_gmp prepare_toolchain_sources
+cmd_extract_gmp ()
+{
+    OUT_DIR=$(build_dir_for gmp)
+    GMP_TARBALL=$TOOLCHAIN_SRC_DIR/gmp/gmp-$GMP_VERSION.tar.bz2
+    if [ ! -f "$GMP_TARBALL" ]; then
+        GMP_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/gmp-$GMP_VERSION.tar.bz2
+        if [ ! -f "$GMP_TARBALL" ]; then
+            panic "Can't find gmp-$GMP_VERSION sources!!"
+        fi
+    fi
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    tar xjf "$GMP_TARBALL"
+}
+
+task2_define configure_gmp "Configure gmp-$GMP_VERSION"
+task2_depends2 configure_gmp extract_gmp install_binutils
+cmd_configure_gmp ()
+{
+    export ABI=$GMP_ABI &&
+    cd $(build_dir_for gmp) && mkdir -p build && cd build &&
+    ../gmp-$GMP_VERSION/configure \
+        --prefix=$(install_dir) \
+        --host=$GMP_TARGET \
+        --with-sysroot=$(install_dir) \
+        --disable-shared
+}
+
+task2_define build_gmp "Build gmp-$GMP_VERSION"
+task2_depends2 build_gmp configure_gmp
+cmd_build_gmp ()
+{
+    export ABI=$GMP_ABI &&
+    cd $(build_dir_for gmp)/build &&
+    make $MAKE_FLAGS
+}
+
+task2_define install_gmp "Install gmp-$GMP_VERSION"
+task2_depends2 install_gmp build_gmp
+cmd_install_gmp ()
+{
+    cd $(build_dir_for gmp)/build &&
+    make install
+}
+
+# Third, build mpfr
+task2_define extract_mpfr "Extract sources from mpfr-$MPFR_VERSION"
+task2_depends1 extract_mpfr prepare_toolchain_sources
+cmd_extract_mpfr ()
+{
+    OUT_DIR=$(build_dir_for mpfr)
+    MPFR_TARBALL=$TOOLCHAIN_SRC_DIR/mpfr/mpfr-$MPFR_VERSION.tar.bz2
+    if [ ! -f "$MPFR_TARBALL" ]; then
+        MPFR_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/mpfr-$MPFR_VERSION.tar.bz2
+        if [ ! -f "$MPFR_TARBALL" ]; then
+            panic "Can't find mpfr-$MPFR_VERSION sources!!"
+        fi
+    fi
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    tar xjf "$MPFR_TARBALL"
+}
+
+task2_define configure_mpfr "Configure mpfr-$MPFR_VERSION"
+task2_depends2 configure_mpfr extract_mpfr install_gmp
+cmd_configure_mpfr ()
+{
+    cd $(build_dir_for mpfr) && mkdir -p build && cd build &&
+    run ../mpfr-$MPFR_VERSION/configure \
+        --prefix=$(install_dir) \
+        --host=$GMP_TARGET \
+        --with-gmp=$(install_dir) \
+        --with-sysroot=$(sysroot_dir) \
+        --disable-shared
+}
+
+task2_define build_mpfr "Build mpfr-$MPFR_VERSION"
+task2_depends2 build_mpfr configure_mpfr
+cmd_build_mpfr ()
+{
+    cd $(build_dir_for mpfr)/build &&
+    run make $MAKE_FLAGS
+}
+
+task2_define install_mpfr "Install mpfr-$MPFR_VERSION"
+task2_depends2 install_mpfr build_mpfr
+cmd_install_mpfr ()
+{
+    cd $(build_dir_for mpfr)/build &&
+    run make install
+}
+
+task2_define extract_mpc "Extract sources for mpc-$MPC_VERSION"
+task2_depends1 extract_mpc prepare_toolchain_sources
+cmd_extract_mpc ()
+{
+    OUT_DIR=$(build_dir_for mpc)
+    MPC_TARBALL=$TOOLCHAIN_SRC_DIR/mpc/mpc-$MPC_VERSION.tar.gz
+    if [ ! -f "$MPC_TARBALL" ]; then
+        MPC_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/mpc-$MPC_VERSION.tar.gz
+        if [ ! -f "$MPC_TARBALL" ]; then
+            panic "Can't find mpc-$MPC_VERSION sources!!"
+        fi
+    fi
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    tar xzf "$MPC_TARBALL"
+}
+
+task2_define configure_mpc "Configure mpc-$MPC_VERSION"
+task2_depends2 configure_mpc extract_mpc install_mpfr
+cmd_configure_mpc ()
+{
+    cd $(build_dir_for mpc) && mkdir -p build && cd build &&
+    run ../mpc-$MPC_VERSION/configure \
+        --prefix=$(install_dir) \
+        --host=$GMP_TARGET \
+        --with-gmp=$(install_dir) \
+        --with-mpfr=$(install_dir) \
+        --disable-shared
+}
+
+task2_define build_mpc "Build mpc-$MPC_VERSION"
+task2_depends2 build_mpc configure_mpc
+cmd_build_mpc ()
+{
+    cd $(build_dir_for mpc)/build &&
+    run make $MAKE_FLAGS
+}
+
+task2_define install_mpc "Install mpc-$MPC_VERSION"
+task2_depends2 install_mpc build_mpc
+cmd_install_mpc ()
+{
+    cd $(build_dir_for mpc)/build &&
+    run make install
+}
+
+task2_define extract_isl "Extract sources for isl-$ISL_VERSION"
+task2_depends2 extract_isl prepare_toolchain_sources
+cmd_extract_isl ()
+{
+    OUT_DIR=$(build_dir_for isl)
+    ISL_TARBALL=$TOOLCHAIN_SRC_DIR/isl/isl-$ISL_VERSION.tar.bz2
+    if [ ! -f "$ISL_TARBALL" ]; then
+        panic "Can't find isl-$ISL_VERSION sources!!"
+    fi
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    tar xf "$ISL_TARBALL"
+}
+
+task2_define configure_isl "Configuring isl-$ISL_VERSION"
+task2_depends2 configure_isl extract_isl install_gmp
+cmd_configure_isl ()
+{
+    cd $(build_dir_for isl) && mkdir -p build && cd build &&
+    run ../isl-$ISL_VERSION/configure \
+        --prefix=$(install_dir) \
+        --host=$GMP_TARGET \
+        --with-gmp-prefix=$(install_dir) \
+        --with-sysroot=$(sysroot_dir) \
+        --disable-shared
+}
+
+task2_define build_isl "Building isl-$ISL_VERSION"
+task2_depends2 build_isl configure_isl
+cmd_build_isl ()
+{
+    cd $(build_dir_for isl)/build &&
+    run make $MAKE_FLAGS
+}
+
+task2_define install_isl "Installing isl-$ISL_VERSION"
+task2_depends2 install_isl build_isl
+cmd_install_isl ()
+{
+    cd $(build_dir_for isl)/build &&
+    make install
+}
+
+task2_define configure_cloog "Configure Cloog-$CLOOG_VERSION"
+task2_depends2 configure_cloog prepare_toolchain_sources install_gmp install_isl
+cmd_configure_cloog () {
+    mkdir -p $(build_dir_for cloog)/build && cd $(build_dir_for cloog)/build &&
+    run $TOOLCHAIN_SRC_DIR/cloog/cloog-$CLOOG_VERSION/configure \
+        --prefix=$(install_dir) \
+        --host=$GMP_TARGET \
+        --with-gmp-prefix=$(install_dir) \
+        --with-sysroot=$(sysroot_dir) \
+        --disable-shared
+}
+
+task2_define build_cloog "Building Cloog-$CLOOG_VERSION"
+task2_depends2 build_cloog configure_cloog
+cmd_build_cloog ()
+{
+    cd $(build_dir_for cloog)/build &&
+    run make $MAKE_FLAGS
+}
+
+task2_define install_cloog "Installing Cloog-$CLOOG_VERSION"
+task2_depends2 install_cloog build_cloog
+cmd_install_cloog ()
+{
+    cd $(build_dir_for cloog)/build &&
+    run make install
+}
+
+# Fourth, the compiler itself
+task2_define configure_gcc "Configure gcc-$GCC_VERSION"
+task2_depends1 configure_gcc prepare_toolchain_sources
+task2_depends2 configure_gcc install_binutils install_gmp install_mpfr install_mpc install_cloog
+cmd_configure_gcc ()
+{
+    local EXTRA_CONFIGURE_FLAGS=
+    if [ "$GCC_VERSION" != "4.6" ]; then
+        EXTRA_CONFIGURE_FLAGS="--with-cloog=$(install_dir)"
+    fi
+    OUT_DIR=$(build_dir_for gcc)
+    mkdir -p $OUT_DIR && cd $OUT_DIR &&
+    export CC=$HOST_CC &&
+    export CC_FOR_TARGET="$HOST_CC" &&
+    run $TOOLCHAIN_SRC_DIR/gcc/gcc-$GCC_VERSION/configure \
+        --prefix=$(install_dir) \
+        --with-sysroot=$(sysroot_dir) \
+        --disable-nls \
+        --with-gmp=$(install_dir) \
+        --with-mpfr=$(install_dir) \
+        --with-mpc=$(install_dir) \
+        --target=$GCC_TARGET \
+        --with-arch=x86-64 \
+        --with-multilib-list=m32,m64 \
+        --disable-plugin \
+        --disable-docs \
+        --disable-bootstrap \
+        --disable-libgomp \
+        --disable-libmudflap \
+        --disable-libquadmath \
+        --enable-target-optspace \
+        --enable-gold=default \
+        --enable-languages=c,c++ \
+        $EXTRA_CONFIGURE_FLAGS
+}
+
+task2_define build_gcc "Build gcc-$GCC_VERSION"
+task2_depends2 build_gcc configure_gcc
+cmd_build_gcc ()
+{
+    cd $(build_dir_for gcc) &&
+    make $MAKE_FLAGS
+}
+
+task2_define install_gcc "Install gcc-$GCC_VERSION"
+task2_depends2 install_gcc build_gcc
+cmd_install_gcc ()
+{
+    cd $(build_dir_for gcc) &&
+    make install
+}
+
+task2_define cleanup_toolchain "Cleanup toolchain"
+task2_depends2 cleanup_toolchain install_gcc
+cmd_cleanup_toolchain ()
+{
+    # Remove un-needed directories and files
+    rm -rf $(install_dir)/share
+    rm -rf $(install_dir)/man
+    rm -rf $(install_dir)/info
+    rm -rf $(install_dir)/libexec/*/*/install-tools
+    #rm -rf $(install_dir)/$GCC_TARGET/bin
+    find $(install_dir) -name "*.la" -exec rm -f {} \;
+
+    (strip $(install_dir)/bin/*)
+    (strip $(install_dir)/libexec/gcc/$GCC_TARGET/*/*)
+    true
+}
+
+task2_define package_toolchain "Package final toolchain"
+task2_depends2 package_toolchain cleanup_toolchain
+cmd_package_toolchain ()
+{
+    # Copy this script to the install directory
+    cp -f $0 $(install_dir)
+    fail_panic "Could not copy build script to install directory"
+
+    if [ -d "$PATCHES_DIR" ]; then
+        # Copy patches to the install directory
+        cp -rf "$PATCHES_DIR" $(install_dir)
+        fail_panic "Could not copy patch directory to install directory"
+    fi
+
+    # Copy the SOURCES file as well
+    cp $DOWNLOAD_DIR/SOURCES $(install_dir)/PACKAGE_SOURCES &&
+    cp $TOOLCHAIN_SRC_DIR/SOURCES $(install_dir)/TOOLCHAIN_SOURCES
+    fail_panic "Could not copy SOURCES files to install directory"
+
+    # Package everything
+    pack_archive $TOOLCHAIN_ARCHIVE "`dirname $(install_dir)`" "`basename $(install_dir)`"
+}
+
+task2_define install_toolchain "Install final toolchain"
+task2_depends2 install_toolchain cleanup_toolchain
+cmd_install_toolchain ()
+{
+    copy_directory "$(install_dir)" "$PREFIX_DIR/$TOOLCHAIN_NAME"
+    cp -f $0 "$PREFIX_DIR/$TOOLCHAIN_NAME/"
+}
+
+# Make sure that the second toolchain depends on the first one
+task_depends configure_binutils_2 install_gcc_1
+
+if [ "$ONLY_SYSROOT" = "yes" ]; then
+    MAIN_TASK=copy_sysroot
+    COMPLETION_TEXT="Done, see sysroot files in $(sysroot_dir)"
+elif [ -n "$PREFIX_DIR" ]; then
+    if [ -z "$BOOTSTRAP" ]; then
+        MAIN_TASK=install_toolchain_1
+    else
+        MAIN_TASK=install_toolchain_2
+    fi
+    COMPLETION_TEXT="Done, see $PREFIX_DIR/$TOOLCHAIN_NAME"
+else
+    if [ -z "$BOOTSTRAP" ]; then
+        MAIN_TASK=package_toolchain_1
+    else
+        MAIN_TASK=package_toolchain_2
+    fi
+    COMPLETION_TEXT="Done, see $TOOLCHAIN_ARCHIVE"
+fi
+
+if [ "$LIST_TASKS" ]; then
+    task_dump
+else
+    run_task $MAIN_TASK
+    echo "$COMPLETION_TEXT"
+fi
diff --git a/build-lucid-toolchain.sh b/build-lucid-toolchain.sh
deleted file mode 100644
index d557fea..0000000
--- a/build-lucid-toolchain.sh
+++ /dev/null
@@ -1,1811 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This script is used to rebuild the Linux 32-bit cross-toolchain
-# that allows you to generate 32-bit binaries that target Ubuntu 8.04
-# (a.k.a. Hardy Heron) instead of the host system (which usually is 10.04,
-# a.k.a. Lucid Lynx)
-#
-# Use --help for complete usage information.
-#
-# WARNING: At this time, the generated toolchain binaries will *not* run
-#          with GLibc 2.7, only the machine code it generates.
-#
-
-PROGNAME="`basename \"$0\"`"
-PATCHES_DIR="$( cd "$( dirname "$0" )" && pwd )/toolchain-patches"
-
-###########################################################################
-###########################################################################
-#####
-#####  C O N F I G U R A T I O N
-#####
-###########################################################################
-###########################################################################
-
-panic ()
-{
-    echo "ERROR: $@"
-    exit 1
-}
-
-fail_panic ()
-{
-    if [ $? != 0 ] ; then
-        echo "ERROR: $@"
-        exit 1
-    fi
-}
-
-
-# We only support running this script on Linux
-OS=$(uname -s)
-if [ "$OS" != Linux ]; then
-    panic "This script can only run on Linux machines!"
-fi
-
-# Used to set the host bitness of the generted toolchain binaries
-# First call with the build machine's bitness, and later with 32
-# if --32-bits option is used.
-# $1: 32 or 64
-set_host_bits ()
-{
-    HOST_BITS=$1
-    GMP_ABI=$1
-    case $1 in
-        32)
-            HOST_ARCH=i686
-            UBUNTU_ARCH=i386
-            GCC_TARGET=i686-linux
-            GMP_TARGET=i386-linux
-            ;;
-        64)
-            HOST_ARCH=x86_64
-            UBUNTU_ARCH=amd64
-            GCC_TARGET=x86_64-linux
-            GMP_TARGET=x86_64-linux
-            ;;
-        *)
-            panic "Invalid host bitness (32 or 64 expected): $1"
-    esac
-}
-
-# Determine build machine bitness
-BUILD_ARCH=$(uname -m)
-case "$BUILD_ARCH" in
-    x86_64|amd64)
-        BUILD_BITS=64
-        BUILD_ARCH=x86_64
-        BUILD_GCC_TARGET=x86_64-linux
-        set_host_bits 64
-        ;;
-    i?86)
-        BUILD_BITS=32
-        BUILD_ARCH=i686
-        BUILD_GCC_TARGET=i686-linux
-        set_host_bits 32
-        ;;
-    *)
-        panic "Unknown build CPU architecture: $BUILD_ARCH"
-esac
-
-# Versions of various toolchain components, do not touch unless you know
-# what you're doing!
-
-BINUTILS_VERSION=2.21
-GMP_VERSION=5.0.5
-MPFR_VERSION=3.1.1
-MPC_VERSION=1.0.1
-GCC_VERSION=4.8
-CLOOG_VERSION=0.18.0
-ISL_VERSION=0.11.1
-
-GIT_CMD=git
-GIT_DATE=
-GIT_BRANCH=master
-GIT_REFERENCE=
-GIT_BASE=
-GIT_BASE_DEFAULT=https://android.googlesource.com/toolchain
-
-# Location where we're going to install the toolchain during the build
-# This will depend on the phase of the build.
-install_dir () { echo "$WORK_DIR/$PHASE/$TOOLCHAIN_NAME"; }
-
-# Location where we're going to install the final binaries
-# If empty, TOOLCHAIN_ARCHIVE will be generated
-PREFIX_DIR=
-
-# Location of the final sysroot. This must be a sub-directory of INSTALL_DIR
-# to ensure that the toolchain binaries are properly relocatable (i.e. can
-# be used when moved to another directory).
-sysroot_dir () { echo "$(install_dir)/sysroot"; }
-
-# Try to parallelize the build for faster performance.
-JOBS=$(cat /proc/cpuinfo | grep -c processor)
-
-# The base URL of the Ubuntu mirror we're going to use.
-UBUNTU_MIRROR=http://mirrors.us.kernel.org
-
-# Ubuntu release name we want packages from. Can be a name or a number
-# (i.e. "lucid" or "10.04")
-UBUNTU_RELEASE=lucid
-
-
-# The list of packages we need to download from the Ubuntu servers and
-# extract into the original sysroot
-#
-# Call add_ubuntu_package <package-name> to add a package to the list,
-# which will be processed later.
-#
-UBUNTU_PACKAGES=
-
-add_ubuntu_package ()
-{
-    UBUNTU_PACKAGES="$UBUNTU_PACKAGES $@"
-}
-
-# The package files containing kernel headers for Hardy and the C
-# library headers and binaries
-add_ubuntu_package \
-    linux-libc-dev \
-    libc6 \
-    libc6-dev
-
-# The X11 headers and binaries (for the emulator)
-add_ubuntu_package \
-    libx11-6 \
-    libx11-dev \
-    libxcb1-dev \
-    libxau6 \
-    libxdmcp6 \
-    x11proto-core-dev \
-    x11proto-xext-dev \
-    x11proto-input-dev \
-    x11proto-kb-dev
-
-# The OpenGL-related headers and libraries (for GLES emulation)
-add_ubuntu_package \
-    mesa-common-dev \
-    libgl1-mesa-dev \
-    libgl1-mesa-glx \
-    libxxf86vm1 \
-    libxext6 \
-    libxdamage1 \
-    libxfixes3 \
-    libdrm2
-
-# Audio libraries (required by the emulator)
-add_ubuntu_package \
-    libasound2 \
-    libasound2-dev \
-    libesd0-dev \
-    libaudiofile-dev \
-    libpulse0 \
-    libpulse-dev
-
-# ZLib
-add_ubuntu_package \
-    zlib1g \
-    zlib1g-dev \
-    libncurses5 \
-    libncurses5-dev
-
-
-
-###########################################################################
-###########################################################################
-#####
-#####  E N D   O F   C O N F I G U R A T I O N
-#####
-###########################################################################
-###########################################################################
-
-# Parse all options
-OPTION_HELP=no
-VERBOSE=0
-FORCE=no
-ONLY_SYSROOT=no
-ONLY_TOOLCHAIN_DIR=
-BOOTSTRAP=
-PARAMETERS=
-FORCE_32=
-LIST_TASKS=
-
-for opt do
-  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
-  case "$opt" in
-  --help|-h|-\?) OPTION_HELP=yes
-  ;;
-  --verbose) VERBOSE=$(( $VERBOSE + 1 ))
-  ;;
-  --force) FORCE="yes"
-  ;;
-  --32-bits) FORCE_32=true
-  ;;
-  --ubuntu-mirror=*) UBUNTU_MIRROR="$optarg"
-  ;;
-  --ubuntu-release=*) UBUNTU_RELEASE="$optarg"
-  ;;
-  --prefix=*) PREFIX_DIR="$optarg"
-  ;;
-  --work-dir=*) WORK_DIR="$optarg"
-  ;;
-  --gcc-version=*) GCC_VERSION="$optarg"
-  ;;
-  --binutils-version=*) BINUTILS_VERSION="$optarg"
-  ;;
-  --gmp-version=*) GMP_VERSION="$optarg"
-  ;;
-  --mpfr-version=*) MPFR_VERSION="$optarg"
-  ;;
-  --mpc-version=*) MPC_VERSION="$optarg"
-  ;;
-  --isl-version=*) ISL_VERSION="$optarg"
-  ;;
-  --cloog-version=*) CLOOG_VERSION="$oparg"
-  ;;
-  --git=*) GIT_CMD=$optarg
-  ;;
-  --git-date=*) GIT_DATE=$optarg
-  ;;
-  --git-branch=*) GIT_BRANCH=$optarg
-  ;;
-  --git-base=*) GIT_BASE=$optarg
-  ;;
-  --git-reference=*) GIT_REFERENCE=$optarg
-  ;;
-  --out-dir=*) OPTION_OUT_DIR="$optarg"
-  ;;
-  --cc=*) OPTION_CC="$optarg"
-  ;;
-  --jobs=*) JOBS="$optarg"
-  ;;
-  -j*) JOBS=`expr "x$opt" : 'x-j\(.*\)'`
-  ;;
-  --only-sysroot) ONLY_SYSROOT=yes
-  ;;
-  --bootstrap) BOOTSTRAP=yes
-  ;;
-  --list-tasks) LIST_TASKS=yes
-  ;;
-  -*)
-    echo "unknown option '$opt', use --help"
-    exit 1
-    ;;
-  *)
-    if [ -z "$PARAMETERS" ]; then
-        PARAMETERS="$opt"
-    else
-        PARAMETERS="$PARAMETERS $opt"
-    fi
-  esac
-done
-
-if [ "$OPTION_HELP" = "yes" ]; then
-    cat << EOF
-
-Usage: $PROGNAME [options] [<path-to-toolchain-sources>]
-
-This script is used to rebuild a custom Linux host toolchain that targets
-GLibc 2.7 or higher. The machine code generated by this toolchain will run
-properly on Ubuntu 8.04 or higher.
-
-If you're running on a 32-bit system, it will generate a 32-bit toolchain.
-If you're running on a 64-bit system, it will generate a 64-bit toolchain
-unless you use the --32-bits option.
-
-You can provide the path to a local copy of the toolchain sources repository
-as a first parameter. If you don't, the sources will be downloaded and
-extracted automatically into your work directory.
-
-Note that this script will download various binary packages from Ubuntu
-servers in order to prepare a compatible "sysroot".
-
-By default, it generates a package archive ($TOOLCHAIN_ARCHIVE) but you can,
-as an alternative, ask for direct installation with --prefix=<path>
-
-Use the bootstrap option to re-generate the toolchain with itself. This is
-useful if you want to ensure that the generated compiler binaries will work
-properly on Ubuntu 8.04 or higher. By default, they will only run on systems
-that match your build system's C library ABI, or higher.
-
-Options: [defaults in brackets after descriptions]
-EOF
-    echo "Standard options:"
-    echo "  --help                        Print this message"
-    echo "  --force                       Force-rebuild everything"
-    echo "  --prefix=PATH                 Installation path [$PREFIX_DIR]"
-    echo "  --ubuntu-mirror=URL           Ubuntu mirror URL [$UBUNTU_MIRROR]"
-    echo "  --ubuntu-release=NAME         Ubuntu release name [$UBUNTU_RELEASE]"
-    echo "  --work-dir=PATH               Temporary work directory [/tmp/gcc.<random>]"
-    echo "  --only-sysroot                Only dowload and build sysroot packages"
-    echo "  --verbose                     Verbose output. Can be used twice."
-    echo "  --binutils-version=VERSION    Binutils version number [$BINUTILS_VERSION]"
-    echo "  --gcc-version=VERSION         GCC version number [$GCC_VERSION]"
-    echo "  --gmp-version=VERSION         GMP version number [$GMP_VERSION]"
-    echo "  --mpfr-version=VERSION        MPFR version numner [$MPFR_VERSION]"
-    echo "  --mpc-version=VERSION         MPC version number [$MPC_VERSION]"
-    echo "  --isl-version=VERSION         ISL version number [$ISL_VERSION]"
-    echo "  --cloog-version=VERSION       Cloog version number [$CLOOG_VERSION]"
-    echo "  --jobs=COUNT                  Run COUNT build jobs in parallel [$JOBS]"
-    echo "  -j<COUNT>                     Same as --jobs=COUNT."
-    echo "  --git=<cmd>                   Use this version of the git tool [$GIT_CMD]"
-    echo "  --git-date=<date>             Specify specific git date when download sources [none]"
-    echo "  --git-branch=<name>           Specify which branch to use when downloading the sources [$GIT_BRANCH]"
-    echo "  --git-reference=<path>        Use a git reference repository"
-    echo "  --git-base=<url>              Use this git repository base [$GIT_BASE]"
-    echo "  --bootstrap                   Bootstrap toolchain (i.e. compile it with itself)"
-    echo "  --32-bits                     Generate 32-bit toolchain on 64-bit build system."
-    echo ""
-    exit 1
-fi
-
-if [ "$FORCE_32" ]; then
-    if [ "$BUILD_BITS" = 64 ]; then
-        set_host_bits 32
-    else
-       echo "Warning: --32-bits option ignored on 32-bit build machine."
-    fi
-fi
-
-# Determine root working directory for our script
-if [ -z "$WORK_DIR" ]; then
-    WORK_DIR=$(mktemp -d /tmp/$USER-gcc-$HOST_BITS-XXXXXX)
-    WORK_DIR_CLEANUP=true
-else
-    mkdir -p "$WORK_DIR"
-    fail_panic "Could not create directory: $WORK_DIR"
-    WORK_DIR_CLEANUP=false
-fi
-
-if [ -z "$PARAMETERS" ] ; then
-    if [ -n "$GIT_REFERENCE" ] ; then
-        if [ ! -d "$GIT_REFERENCE" -o ! -d "$GIT_REFERENCE/build" ]; then
-            echo "ERROR: Invalid reference repository directory path: $GIT_REFERENCE"
-            exit 1
-        fi
-        if [ -n "$GIT_BASE" ]; then
-            echo "Using git clone reference: $GIT_REFERENCE"
-        else
-            # If we have a reference without a base, use it as a download base instead.
-            GIT_BASE=$GIT_REFERENCE
-            GIT_REFERENCE=
-            echo "Using git clone base: $GIT_BASE"
-        fi
-    elif [ -z "$GIT_BASE" ]; then
-        GIT_BASE=$GIT_BASE_DEFAULT
-        echo "Auto-config: --git-base=$GIT_BASE"
-    fi
-
-    # Location where we will download the toolchain sources
-    TOOLCHAIN_SRC_DIR=$WORK_DIR/toolchain-src
-else
-    set_parameters () {
-        TOOLCHAIN_SRC_DIR="$1"
-        if [ ! -d "$TOOLCHAIN_SRC_DIR" ]; then
-            echo "ERROR: Not a directory: $1"
-            exit 1
-        fi
-        if [ ! -d "$TOOLCHAIN_SRC_DIR/build" ]; then
-            echo "ERROR: Missing directory: $1/build"
-            exit 1
-        fi
-    }
-
-    set_parameters $PARAMETERS
-fi
-
-# Location of original sysroot. This is where we're going to extract all
-# binary Ubuntu packages.
-ORG_SYSROOT_DIR=$WORK_DIR/sysroot
-
-# Name of the final generated toolchain
-TOOLCHAIN_NAME=$GCC_TARGET-glibc2.11-$GCC_VERSION
-
-# Name of the final toolchain binary tarball that this script will create
-TOOLCHAIN_ARCHIVE=/tmp/$TOOLCHAIN_NAME.tar.bz2
-
-# A file that will contain details about all the sources used to generate
-# the final toolchain. This includes both SHA-1 for toolchain git repositories
-# and SHA-1 hashes for downloaded Ubuntu packages.
-SOURCES_LIST=$WORK_DIR/SOURCES
-
-# Determine Make flags
-MAKE_FLAGS="-j$JOBS"
-
-# Create the work directory
-mkdir -p "$WORK_DIR"
-
-# Location where we download packages from the Ubuntu servers
-DOWNLOAD_DIR=$WORK_DIR/download
-
-# Empty the SOURCES file
-rm -f "$SOURCES_LIST" && touch "$SOURCES_LIST"
-
-
-if [ "$VERBOSE" -ge 1 ] ; then
-    run () {
-        echo "## COMMAND: $@"
-        $@
-    }
-    log () {
-        echo "$@"
-    }
-    if [ "$VERBOSE" -ge 2 ] ; then
-        log2 () {
-            echo "$@"
-        }
-    else
-        log2 () {
-            return
-        }
-    fi
-else
-    run () {
-        "$@" >>$TMPLOG 2>&1
-    }
-    log () {
-        return
-    }
-    log2 () {
-        return
-    }
-fi
-
-# Sanitize a path list, we want to remove empty sub-dirs and
-# leading/trailing columns.
-sanitize_path_list ()
-{
-  local RESULT
-  RESULT=$(printf "%s\n" "$*" | tr ':' '\n' | awk '$1 != "" && $1 != "." { print $0; }' | tr '\n' ':')
-  printf "%s" ${RESULT%:}
-}
-
-OLD_PATH=$(sanitize_path_list "$PATH")
-OLD_LD_LIBRARY_PATH=$(sanitize_path_list "$LD_LIBRARY_PATH")
-
-PATH=$OLD_PATH
-LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH
-
-BUILD_DIR=$WORK_DIR/build
-mkdir -p $BUILD_DIR
-
-TMPLOG=$BUILD_DIR/build.log
-rm -rf $TMPLOG && touch $TMPLOG
-
-build_binutils_dir () { echo "$BUILD_DIR/$PHASE/binutils"; }
-build_gmp_dir () { echo "$BUILD_DIR/$PHASE/gmp"; }
-build_mpfr_dir () { echo "$BUILD_DIR/$PHASE/mpfr"; }
-build_mpc_dir () { echo "$BUILD_DIR/$PHASE/mpc"; }
-build_cloog_dir () { echo "$BUILD_DIR/$PHASE/cloog"; }
-build_isl_dir () { echo "$BUILD_DIR/$PHASE/isl"; }
-build_gcc_dir () { echo "$BUILD_DIR/$PHASE/gcc"; }
-
-TIMESTAMPS_DIR=$BUILD_DIR/timestamps
-mkdir -p $TIMESTAMPS_DIR
-
-stamp_check () {
-    [ -f "$TIMESTAMPS_DIR/$1" ]
-}
-
-stamp_clear () {
-    rm -f "$TIMESTAMPS_DIR/$1"
-}
-
-stamp_set () {
-    touch "$TIMESTAMPS_DIR/$1"
-}
-
-if [ "$FORCE" = "yes" ] ; then
-    echo "Cleaning up timestamps (forcing the build)."
-    rm -f $TIMESTAMPS_DIR/*
-fi
-
-if [ "$VERBOSE" = 0 ] ; then
-    echo "To follow build, run: tail -F $TMPLOG"
-fi
-
-# returns 0 iff the string in $2 matches the pattern in $1
-# $1: pattern
-# $2: string
-pattern_match ()
-{
-    echo "$2" | grep -q -E -e "$1"
-}
-
-# Find if a given shell program is available.
-# We need to take care of the fact that the 'which <foo>' command
-# may return either an empty string (Linux) or something like
-# "no <foo> in ..." (Darwin). Also, we need to redirect stderr
-# to /dev/null for Cygwin
-#
-# $1: variable name
-# $2: program name
-#
-# Result: set $1 to the full path of the corresponding command
-#         or to the empty/undefined string if not available
-#
-find_program ()
-{
-    local PROG
-    PROG=`which $2 2>/dev/null`
-    if [ -n "$PROG" ] ; then
-        if pattern_match '^no ' "$PROG"; then
-            PROG=
-        fi
-    fi
-    eval $1="$PROG"
-}
-
-# Copy a directory, create target location if needed
-#
-# $1: source directory
-# $2: target directory location
-#
-copy_directory ()
-{
-    local SRCDIR="$1"
-    local DSTDIR="$2"
-    if [ ! -d "$SRCDIR" ] ; then
-        panic "Can't copy from non-directory: $SRCDIR"
-    fi
-    log2 "Directory copy: $SRCDIR -> $DSTDIR"
-    mkdir -p "$DSTDIR" && (cd "$SRCDIR" && tar cf - *) | (tar xf - -C "$DSTDIR")
-    fail_panic "Cannot copy to directory: $DSTDIR"
-}
-
-find_program CMD_WGET wget
-find_program CMD_CURL curl
-find_program CMD_SCP  scp
-
-# Download a file with either 'curl', 'wget' or 'scp'
-#
-# $1: source URL (e.g. http://foo.com, ssh://blah, /some/path)
-# $2: target file
-download_file ()
-{
-    # Is this HTTP, HTTPS or FTP ?
-    if pattern_match "^(http|https|ftp):.*" "$1"; then
-        if [ -n "$CMD_WGET" ] ; then
-            run $CMD_WGET -O $2 $1
-        elif [ -n "$CMD_CURL" ] ; then
-            run $CMD_CURL -o $2 $1
-        else
-            echo "Please install wget or curl on this machine"
-            exit 1
-        fi
-        return
-    fi
-
-    # Is this SSH ?
-    # Accept both ssh://<path> or <machine>:<path>
-    #
-    if pattern_match "^(ssh|[^:]+):.*" "$1"; then
-        if [ -n "$CMD_SCP" ] ; then
-            scp_src=`echo $1 | sed -e s%ssh://%%g`
-            run $CMD_SCP $scp_src $2
-        else
-            echo "Please install scp on this machine"
-            exit 1
-        fi
-        return
-    fi
-
-    # Is this a file copy ?
-    # Accept both file://<path> or /<path>
-    #
-    if pattern_match "^(file://|/).*" "$1"; then
-        cp_src=`echo $1 | sed -e s%^file://%%g`
-        run cp -f $cp_src $2
-        return
-    fi
-
-    # Unknown schema
-    echo "ERROR: Unsupported source URI: $1"
-    exit 1
-}
-
-# A variant of 'download_file' used to specify the target directory
-# $1: source URL
-# $2: target directory
-download_file_to ()
-{
-    local URL="$1"
-    local DIR="$2"
-    local DST="$DIR/`basename $URL`"
-    mkdir -p $DIR
-    download_file "$URL" "$DST"
-}
-
-# Pack a given archive
-#
-# $1: archive file path (including extension)
-# $2: source directory for archive content
-# $3+: list of files (including patterns), all if empty
-pack_archive ()
-{
-    local ARCHIVE="$1"
-    local SRCDIR="$2"
-    local SRCFILES
-    local TARFLAGS ZIPFLAGS
-    shift; shift;
-    if [ -z "$1" ] ; then
-        SRCFILES="*"
-    else
-        SRCFILES="$@"
-    fi
-    if [ "`basename $ARCHIVE`" = "$ARCHIVE" ] ; then
-        ARCHIVE="`pwd`/$ARCHIVE"
-    fi
-    mkdir -p `dirname $ARCHIVE`
-    if [ "$VERBOSE" -ge 2 ] ; then
-        TARFLAGS="vcf"
-        ZIPFLAGS="-9r"
-    else
-        TARFLAGS="cf"
-        ZIPFLAGS="-9qr"
-    fi
-    case "$ARCHIVE" in
-        *.zip)
-            (cd $SRCDIR && run zip $ZIPFLAGS "$ARCHIVE" $SRCFILES)
-            ;;
-        *.tar)
-            (cd $SRCDIR && run tar $TARFLAGS "$ARCHIVE" $SRCFILES)
-            ;;
-        *.tar.gz)
-            (cd $SRCDIR && run tar z$TARFLAGS "$ARCHIVE" $SRCFILES)
-            ;;
-        *.tar.bz2)
-            (cd $SRCDIR && run tar j$TARFLAGS "$ARCHIVE" $SRCFILES)
-            ;;
-        *)
-            panic "Unsupported archive format: $ARCHIVE"
-            ;;
-    esac
-}
-
-no_trailing_slash ()
-{
-    echo ${1##/}
-}
-
-# Load the Ubuntu packages file. This is a long text file that will list
-# each package for a given release.
-#
-# $1: Ubuntu mirror base URL (e.g. http://mirrors.us.kernel.org/)
-# $2: Release name
-#
-get_ubuntu_packages_list ()
-{
-    local RELEASE=$2
-    local BASE="`no_trailing_slash \"$1\"`"
-    local SRCFILE="$BASE/ubuntu/dists/$RELEASE/main/binary-$UBUNTU_ARCH/Packages.bz2"
-    local DSTFILE="$DOWNLOAD_DIR/Packages.bz2"
-    log "Trying to load $SRCFILE"
-    download_file "$SRCFILE" "$DSTFILE"
-    fail_panic "Could not download $SRCFILE"
-    (cd $DOWNLOAD_DIR && bunzip2 -f Packages.bz2)
-    fail_panic "Could not uncompress $DSTFILE"
-
-    # Write a small awk script used to extract filenames for a given package
-    cat > $DOWNLOAD_DIR/extract-filename.awk <<EOF
-BEGIN {
-    # escape special characters in package name
-    gsub("\\\\.","\\\\.",PKG)
-    gsub("\\\\+","\\\\+",PKG)
-    FILE = ""
-    PACKAGE = ""
-}
-
-\$1 == "Package:" {
-    if (\$2 == PKG) {
-        PACKAGE = \$2
-    } else {
-        PACKAGE = ""
-    }
-}
-
-\$1 == "Filename:" && PACKAGE == PKG {
-    FILE = \$2
-}
-
-END {
-    print FILE
-}
-EOF
-}
-
-# Convert an unversioned package name into a .deb package URL
-#
-# $1: Package name without version information (e.g. libc6-dev)
-# $2: Ubuntu mirror base URL
-#
-get_ubuntu_package_deb_url ()
-{
-    # The following is an awk command to parse the Packages file and extract
-    # the filename of a given package.
-    local BASE="`no_trailing_slash \"$1\"`"
-    local FILE=`awk -f "$DOWNLOAD_DIR/extract-filename.awk" -v PKG=$1 $DOWNLOAD_DIR/Packages`
-    if [ -z "$FILE" ]; then
-        log "Could not find filename for package $1"
-        exit 1
-    fi
-    echo "$2/ubuntu/$FILE"
-}
-
-# Does the host compiler generate 32-bit machine code?
-# If not, add the -m32 flag to the compiler name to ensure this.
-#
-compute_host_flags ()
-{
-    HOST_CC=${CC:-gcc}
-    HOST_CXX=${CXX-g++}
-    if [ -n "$USE_CCACHE" ]; then
-        echo -n "Checking for ccache..."
-        find_program CMD_CCACHE ccache
-        if [ -n "$CMD_CCACHE" ] ; then
-            echo "$HOST_CC" | tr ' ' '\n' | grep -q -e "ccache"
-            if [ $? = 0 ] ; then
-                echo "yes (ignored)"
-            else
-                echo "yes"
-                HOST_CC="ccache $HOST_CC"
-                HOST_CXX="ccache $HOST_CXX"
-            fi
-        else
-            echo "no"
-        fi
-    fi
-    echo -n "Checking compiler bitness... "
-    cat > "$BUILD_DIR"/conftest.c << EOF
-#include <stdio.h>
-int main(void) {
-    printf("%d\n",sizeof(void*)*8);
-    return 0;
-}
-EOF
-    $HOST_CC -o "$BUILD_DIR"/conftest "$BUILD_DIR"/conftest.c > "$BUILD_DIR"/conftest.log 2>&1
-    if [ $? != 0 ] ; then
-        echo "Could not compile test program!!"
-        echo "Error log is:"
-        cat "$BUILD_DIR"/conftest.log
-        rm "$BUID_DIR"/conftest.log
-        panic "Need a working build toolchain!"
-    fi
-    HOST_CC_BITS=$("$BUILD_DIR"/conftest)
-    echo -n "$HOST_CC_BITS"
-    case $HOST_CC_BITS in
-        32) # Nothing to do
-            ;;
-        64) # Do we need to force 32-bits
-            if [ "$FORCE_32" ]; then
-                echo " (forcing generation of 32-bit binaries)"
-                HOST_CC=$HOST_CC" -m32"
-                HOST_CXX=$HOST_CXX" -m32"
-            fi
-            ;;
-        *)
-            panic "Unknown bitness (32 or 64 expected) !!"
-    esac
-    echo ""
-    echo "Using build C compiler: $HOST_CC"
-    echo "Using build C++ compiler: $HOST_CXX"
-    echo "GCC target name: $GCC_TARGET"
-    echo "GMP target name: $GMP_TARGET"
-    echo "GMP ABI: $GMP_ABI"
-    export CC="$HOST_CC"
-    export CXX="$HOST_CXX"
-}
-
-compute_host_flags
-
-# Return the value of a given named variable
-# $1: variable name
-#
-# example:
-#    FOO=BAR
-#    BAR=ZOO
-#    echo `var_value $FOO`
-#    will print 'ZOO'
-#
-var_value ()
-{
-    eval echo \$$1
-}
-
-var_list_append ()
-{
-    local VARNAME=$1
-    local VARVAL=`var_value $VARNAME`
-    shift
-    if [ -z "$VARVAL" ] ; then
-        eval $VARNAME=\"$@\"
-    else
-        eval $VARNAME=\"$VARVAL $@\"
-    fi
-}
-
-var_list_prepend ()
-{
-    local VARNAME=$1
-    local VARVAL=`var_value $VARNAME`
-    shift
-    if [ -z "$VARVAL" ] ; then
-        eval $VARNAME=\"$@\"
-    else
-        eval $VARNAME=\"$@ $VARVAL\"
-    fi
-}
-
-_list_first ()
-{
-    echo $1
-}
-
-_list_rest ()
-{
-    shift
-    echo "$@"
-}
-
-_list_reverse ()
-{
-    local I1 I2 I3 I4 I5 I6 I7 I8 I9 REST RET
-    I1=$1; I2=$2; I3=$3; I4=$I4; I5=$I5; I6=$I6; I7=$I7; I8=$I8; I9=$I9
-    shift 9
-    RET=$I9${I8:+" "}$I8${I7:+" "}$I7${I6:+" "}$I6${I5:+" "}$I5${I4:+" "}$I4${I3:+" "}$I3${I2:+" "}$I2${I1:+" "}$I1
-    REST="$*"
-    if [ "$REST" ]; then
-        RET=$(_list_reverse $REST)$RET
-    fi
-    echo "$RET"
-}
-
-var_list_pop_first ()
-{
-    local VARNAME=$1
-    local VARVAL=`var_value $VARNAME`
-    local FIRST=`_list_first $VARVAL`
-    eval $VARNAME=\"`_list_rest $VARVAL`\"
-    echo "$FIRST"
-}
-
-_list_first ()
-{
-    echo $1
-}
-
-_list_rest ()
-{
-    shift
-    echo "$@"
-}
-
-var_list_first ()
-{
-    local VAL=`var_value $1`
-    _list_first $VAL
-}
-
-var_list_rest ()
-{
-    local VAL=`var_value $1`
-    _list_rest $VAL
-}
-
-ALL_TASKS=
-
-# Define a new task for this build script
-# $1: Task name (e.g. build_stuff)
-# $2: Task description
-# $3: Optional: command name (will be cmd_$1 by default)
-#
-task_define ()
-{
-    local TASK="$1"
-    local DESCR="$2"
-    local COMMAND="${3:-cmd_$1}"
-
-    var_list_append ALL_TASKS $TASK
-    task_set $TASK name "$TASK"
-    task_set $TASK descr "$DESCR"
-    task_set $TASK cmd "$COMMAND"
-    task_set $TASK deps ""
-}
-
-# Variant of task define for dual tasks
-# This really defines two tasks named '<task>_1' and '<task>_2"
-# $1: Task base name
-# $2: Task description
-# $3: Optional: command name (will be cmd_$1 by default)
-task2_define ()
-{
-    local TASK="$1"
-    local DESCR="$2"
-    local COMMAND="${3:-cmd_$1}"
-
-    task_define "${TASK}_1" "$DESCR 1/2" "phase_1 $COMMAND"
-    task_define "${TASK}_2" "$DESCR 2/2" "phase_2 $COMMAND"
-}
-
-task_set ()
-{
-    local TASK="$1"
-    local FIELD="$2"
-    shift; shift;
-    eval TASK_${TASK}__${FIELD}=\"$@\"
-}
-
-task_get ()
-{
-    var_value TASK_$1__$2
-}
-
-# return the list of dependencies for a given task
-task_get_deps ()
-{
-    task_get $1 deps
-}
-
-task_get_cmd ()
-{
-    task_get $1 cmd
-}
-
-task_get_descr ()
-{
-    task_get $1 descr
-}
-
-# $1: task name
-# $2+: other tasks this task depends on.
-task_depends ()
-{
-    local TASK="$1"
-    shift;
-    var_list_append TASK_${TASK}__deps $@
-}
-
-# $1: dual task name
-# $2+: other non-dual tasks this dual task depends on
-task2_depends1 ()
-{
-    local TASK="$1"
-    shift
-    var_list_append TASK_${TASK}_1__deps $@
-    var_list_append TASK_${TASK}_2__deps $@
-}
-
-# $1: dual task name
-# $2+: other dual tasks this dual task depends on
-task2_depends2 ()
-{
-    local TASK="$1"
-    local DEP
-    shift
-    for DEP; do
-        var_list_append TASK_${TASK}_1__deps ${DEP}_1
-        var_list_append TASK_${TASK}_2__deps ${DEP}_2
-    done
-}
-
-task_dump ()
-{
-    local TASK
-    for TASK in $ALL_TASKS; do
-        local DEPS="`task_get_deps $TASK`"
-        local CMD="`task_get_cmd $TASK`"
-        local DESCR="`task_get_descr $TASK`"
-        echo "TASK $TASK: $DESCR: $CMD"
-        echo ">  $DEPS"
-    done
-}
-
-task_visit ()
-{
-    task_set $TASK visit 1
-}
-
-task_unvisit ()
-{
-    task_set $TASK visit 0
-}
-
-task_is_visited ()
-{
-    [ `task_get $TASK visit` = 1 ]
-}
-
-task_queue_reset ()
-{
-    TASK_QUEUE=
-}
-
-task_queue_push ()
-{
-    var_list_append TASK_QUEUE $1
-}
-
-task_queue_pop ()
-{
-    local FIRST=`var_list_first TASK_QUEUE`
-    TASK_QUEUE=`var_list_rest TASK_QUEUE`
-}
-
-do_all_tasks ()
-{
-    local TASK
-    local TASK_LIST=
-    task_queue_reset
-    # Clear visit flags
-    for TASK in $ALL_TASKS; do
-        task_unvisit $TASK
-    done
-    task_queue_push $1
-    while [ -n "$TASK_QUEUE" ] ; do
-        TASK=`task_queue_pop`
-        if task_is_visited $TASK; then
-            continue
-        fi
-        # Prepend the task to the list if its timestamp is not set
-        if stamp_check $TASK; then
-            var_list_prepend TASK_LIST $TASK
-        fi
-        # Add all dependencies to the work-queue
-        local SUBTASK
-        for SUBTASK in `task_get_deps $TASK`; do
-            task_queue_push $SUBTASK
-        done
-        task_visit $TASK
-    done
-
-    # Now, TASK_LIST contains the
-}
-
-
-# Return the first item of a space-separated list
-list_first () {
-    set -- "$@"
-    echo "$1"
-}
-
-# Append an item to a given list
-list_append () {
-    local ITEM=$1
-    shift;
-    echo $@${@:+" "}$1
-}
-
-# Return the second-to-last items of a space-separated list
-list_rest () {
-    set -- "$@"
-    shift
-    echo "$@"
-}
-
-# Reverse a space-separated list
-list_reverse ()
-{
-    set -- "$@"
-    local I1 I2 I3 I4 I5 I6 I7 I8 I9 REST RET
-    I1=$1; I2=$2; I3=$3; I4=$4; I5=$5; I6=$6; I7=$7; I8=$8; I9=$9
-    shift; shift; shift; shift; shift; shift; shift; shift; shift;
-    RET=$I9${I9:+" "}$I8${I8:+" "}$I7${I7:+" "}$I6${I6:+" "}$I5${I5:+" "}$I4${I4:+" "}$I3${I3:+" "}$I2${I2:+" "}$I1
-    REST="$*"
-    if [ -n "$REST" ]; then
-        RET=$(list_reverse $REST)" "$RET
-    fi
-    echo "$RET"
-}
-
-# Used to build the list of tasks with a tree post-order traversal, i.e.
-# the list starts at the leaves and finishes with the top level task,
-# so that if task(A) depends on task(B), then A will always appear _after_
-# B in the result.
-#
-# $1: space-separated list of tasks to visit
-# Out: list of all tasks in post-order
-#
-task_build_postorder_list ()
-{
-    local TASK
-    local STACK="$1"
-    local RET=""
-    for TASK in $ALL_TASKS; do
-        stamp_clear $TASK.visit
-    done
-    while true; do
-        # Peek at stack
-        TASK=$(list_first $STACK)
-        #echo >&2 "STACK: ($TASK) '$STACK'"
-        if [ -z "$TASK" ]; then
-            break
-        fi
-        HAS_DEPS=
-        for DEP in $(task_get_deps $TASK); do
-            #echo >&2 "CHECK: '$DEP'"
-            if ! stamp_check $DEP.visit; then
-                STACK=$DEP" "$STACK
-                #echo >&2 "PUSH: '$DEP' => '$STACK'"
-                HAS_DEPS=1
-            fi
-        done
-
-        if [ -z "$HAS_DEPS" ]; then
-            #echo >&2 "ADD: $TASK -> '$RET'"
-            STACK=$(list_rest $STACK)
-            if ! stamp_check $TASK.visit; then
-                RET=$RET${RET:+" "}$TASK
-                stamp_set $TASK.visit
-            fi
-        fi
-    done
-    for TASK in $ALL_TASKS; do
-        stamp_clear $TASK.visit
-    done
-    echo "$RET"
-}
-
-run_task ()
-{
-    # Build the list of tasks, in reverse order (from leafs to last)
-    local TASKS=$(task_build_postorder_list $1)
-    # Do all tasks
-    local TASK DEP DESCR
-
-    # Dump list of tasks:
-#     echo "ALL TASKS:"
-#     for TASK in $TASKS; do
-#         echo "  $TASK"
-#     done
-
-    # Clean timestamps of any tasks whose any of its dependents needs
-    # to be re-done.
-    #
-    for TASK in $TASKS; do
-       for DEP in $(task_get_deps $TASK); do
-            if ! stamp_check $DEP; then
-                #echo "Redo: $TASK due to $DEP"
-                stamp_clear $TASK
-                break
-            fi
-       done
-    done
-
-    for TASK in $TASKS; do
-        DESCR=$(task_get_descr $TASK)
-        if stamp_check $TASK; then
-            echo "Skipping: $DESCR"
-            continue
-        fi
-        echo "Running: $DESCR"
-        if [ "$VERBOSE" -ge 1 ] ; then
-            (eval $(task_get_cmd $TASK))
-        else
-            (eval $(task_get_cmd $TASK)) >> $TMPLOG 2>&1
-        fi
-        if [ $? != 0 ] ; then
-            echo "ERROR: Cannot $DESCR"
-            exit 1
-        fi
-
-        stamp_set $TASK
-    done
-}
-
-# This function is used to clone a source repository either from a given
-# git base or a git reference.
-# $1: project/subdir name
-# $2: path to SOURCES file
-toolchain_clone ()
-{
-    local GITFLAGS
-    GITFLAGS=
-    if [ "$GIT_REFERENCE" ]; then
-        GITFLAGS="$GITFLAGS --shared --reference $GIT_REFERENCE/$1"
-    fi
-    echo "cleaning up toolchain/$1"
-    rm -rf $1
-    fail_panic "Could not clean $(pwd)/$1"
-    echo "downloading sources for toolchain/$1"
-    if [ -d "$GIT_BASE/$1" ]; then
-        log "cloning $GIT_BASE/$1"
-        run $GIT_CMD clone $GITFLAGS $GIT_BASE/$1 $1
-    else
-        log "cloning $GITPREFIX/$1.git"
-        run $GIT_CMD clone $GITFLAGS $GIT_BASE/$1.git $1
-    fi
-    fail_panic "Could not clone $GIT_BASE/$1.git ?"
-    cd $1
-    if [ "$GIT_BRANCH" != "master" ] ; then
-        log "checking out $GIT_BRANCH branch of $1.git"
-        run $GIT_CMD checkout -b $GIT_BRANCH origin/$GIT_BRANCH
-        fail_panic "Could not checkout $1 ?"
-    fi
-    # If --git-date is used, or we have a default
-    if [ -n "$GIT_DATE" ] ; then
-        REVISION=`git rev-list -n 1 --until="$GIT_DATE" HEAD`
-        echo "Using sources for date '$GIT_DATE': toolchain/$1 revision $REVISION"
-        run $GIT_CMD checkout $REVISION
-        fail_panic "Could not checkout $1 ?"
-    fi
-    (printf "%-32s " "toolchain/$1.git: " && git log -1 --format=oneline) >> $2
-    cd ..
-}
-
-task_define download_toolchain_sources "Download toolchain sources from $GIT_BASE "
-cmd_download_toolchain_sources ()
-{
-    local SUBDIRS="binutils build gcc gdb gold gmp mpfr mpc isl cloog"
-    (mkdir -p $TOOLCHAIN_SRC_DIR && cd $TOOLCHAIN_SRC_DIR &&
-    # Create a temporary SOURCES file for the toolchain sources only
-    # It's content will be copied to the final SOURCES file later.
-    SOURCES_LIST=$TOOLCHAIN_SRC_DIR/SOURCES
-    rm -f $SOURCES_LIST && touch $SOURCES_LIST
-    for SUB in $SUBDIRS; do
-        toolchain_clone $SUB $SOURCES_LIST
-    done
-    )
-}
-
-task_define download_ubuntu_packages_list "Download Ubuntu packages list"
-cmd_download_ubuntu_packages_list ()
-{
-    mkdir -p $DOWNLOAD_DIR
-    get_ubuntu_packages_list "$UBUNTU_MIRROR" "$UBUNTU_RELEASE"
-    fail_panic "Unable to download packages list, try --ubuntu-mirror=<url> to use another archive mirror"
-}
-
-task_define download_packages "Download Ubuntu packages"
-task_depends download_packages download_ubuntu_packages_list
-cmd_download_packages ()
-{
-    local PACKAGE
-
-    rm -f $DOWNLOAD_DIR/SOURCES && touch $DOWNLOAD_DIR/SOURCES
-    for PACKAGE in $UBUNTU_PACKAGES; do
-        echo "Downloading $PACKAGE"
-        local PKGURL=`get_ubuntu_package_deb_url $PACKAGE $UBUNTU_MIRROR`
-        echo "URL: $PKGURL"
-        download_file_to $PKGURL $DOWNLOAD_DIR
-        fail_panic "Could not download $PACKAGE"
-    done
-    sha1sum $DOWNLOAD_DIR/*.deb | while read LINE; do
-        PACKAGE=$(basename $(echo $LINE | awk '{ print $2;}'))
-        SHA1=$(echo $LINE | awk '{ print $1; }')
-        printf "%-64s %s\n" $PACKAGE $SHA1 >> $DOWNLOAD_DIR/SOURCES
-    done
-}
-
-task_define build_sysroot "Build sysroot"
-task_depends build_sysroot download_packages
-
-cmd_build_sysroot ()
-{
-    local PACKAGE
-    for PACKAGE in $UBUNTU_PACKAGES; do
-        local PKGURL=`get_ubuntu_package_deb_url $PACKAGE $UBUNTU_MIRROR`
-        local SRC_PKG=$DOWNLOAD_DIR/`basename $PKGURL`
-        echo "Extracting $SRC_PKG"
-        dpkg -x $SRC_PKG $ORG_SYSROOT_DIR/
-    done
-}
-
-# Now, we need to patch libc.so which is actually a linker script
-# referencing /lib and /usr/lib. Do the same for libpthread.so
-patch_library ()
-{
-    echo "Patching $1"
-    sed -i -e "s! /lib/! !g" -e "s! /usr/lib/! !g" $1
-}
-
-# Used to setup phase 1 the run a command
-phase_1 ()
-{
-    PHASE=1
-    $@
-}
-
-# Used to setup phase 2 then run a command
-phase_2 ()
-{
-    PHASE=1
-    BINPREFIX=$(install_dir)/bin/${GCC_TARGET}-
-    CC=${BINPREFIX}gcc
-    CXX=${BINPREFIX}g++
-    LD=${BINPREFIX}ld
-    AR=${BINPREFIX}ar
-    AS=${BINPREFIX}as
-    RANLIB=${BINPREFIX}ranlib
-    STRIP=${BINPREFIX}strip
-    CC_FOR_TARGET=${BINPREFIX}gcc
-    export CC CXX LD AR AS RANLIB STRIP CC_FOR_TARGET
-    PHASE=2
-    $@
-}
-
-# Return the list of all symbolic links in a given directory, excluding
-# any links in its sub-directories.
-# $1: Sub-directory path.
-find_symlinks_in () {
-    (cd $1 && find . -maxdepth 1 -type l) | sed -e 's|^\./||g'
-}
-
-task2_define copy_sysroot "Fix and copy sysroot"
-task2_depends1 copy_sysroot build_sysroot
-cmd_copy_sysroot ()
-{
-    local SL
-
-    # Copy the content of $BUILD_DIR/lib to $(sysroot_dir)/usr/lib
-    copy_directory $ORG_SYSROOT_DIR/lib $(sysroot_dir)/usr/lib
-    copy_directory $ORG_SYSROOT_DIR/usr/lib $(sysroot_dir)/usr/lib
-    copy_directory $ORG_SYSROOT_DIR/usr/include $(sysroot_dir)/usr/include
-
-    # We need to fix the symlink like librt.so -> /lib/librt.so.1
-    # in $(sysroot_dir)/usr/lib, they should point to librt.so.1 instead now.
-    SYMLINKS=$(find_symlinks_in $(sysroot_dir)/usr/lib)
-    cd $(sysroot_dir)/usr/lib
-    for SL in $SYMLINKS; do
-        # convert /lib/libfoo.so.<n> into 'libfoo.so.<n>' for the target
-        local DST=$(readlink $SL 2>/dev/null)
-        local DST2=${DST##/lib/}
-        if [ "$DST2" != "$DST" ]; then
-            echo "Fixing symlink $SL --> $DST"
-            rm $SL && ln -s $DST2 $SL
-        fi
-    done
-
-#     # Also deal with a few direct symlinks that don't use the /lib/ prefix
-#     # we simply copy them. Useful for libGL.so -> libGL.so.1 for example.
-#     SYMLINKS=$(find_symlinks_in $(sysroot_dir)/usr/lib)
-#     cd $(sysroot_dir)/usr/lib
-#     for SL in $SYMLINKS; do
-#         # convert /lib/libfoo.so.<n> into 'libfoo.so.<n>' for the target
-#         local DST=$(readlink $SL 2>/dev/null)
-#         # convert libfoo.so.<n> into libfoo.so for the source
-#         local SRC=`echo $DST | sed -e 's!\.[0-9]*$!!g'`
-#         if [ "$DST" != "$SRC" ]; then
-#             echo "Copying symlink $SRC --> $DST"
-#             ln -sf $DST $SRC
-#         fi
-#     done
-
-    patch_library $(sysroot_dir)/usr/lib/libc.so
-    patch_library $(sysroot_dir)/usr/lib/libpthread.so
-}
-
-task_define patch_toolchain_sources "Patch toolchain sources."
-task_depends patch_toolchain_sources download_toolchain_sources
-cmd_patch_toolchain_sources ()
-{
-    log "PATCHES_DIR = $PATCHES_DIR"
-    if [ ! -d "$PATCHES_DIR" ]; then
-        log "$PATCHES_DIR doesn't exist"
-        return 0
-    fi
-
-    local PATCHES=`(cd $PATCHES_DIR && find . -name "*.patch" | sort ) 2> /dev/null`
-    if [ -z "$PATCHES" ] ; then
-        log "No patches files in $PATCHES_DIR"
-        return 0
-    fi
-    
-    PATCHES=`echo $PATCHES | sed -e s%^\./%%g`
-    for PATCH in $PATCHES; do
-        PATCHDIR=`dirname $PATCH`
-        PATCHNAME=`basename $PATCH`
-        log "Applying $PATCHNAME into $TOOLCHAIN_SRC_DIR/$PATCHDIR"
-        (cd $TOOLCHAIN_SRC_DIR/$PATCHDIR && patch -p1 < $PATCHES_DIR/$PATCH)
-        fail_panic "Patch failure!! Please check your patches directory!"
-    done
-
-    log "Done patching."
-}
-
-task_define prepare_toolchain_sources "Prepare toolchain sources."
-if [ -n "$GIT_BASE" -o -n "$GIT_REFERENCE" ]; then
-    task_depends prepare_toolchain_sources patch_toolchain_sources
-fi
-cmd_prepare_toolchain_sources ()
-{
-    return
-}
-
-task2_define configure_binutils "Configure binutils-$BINUTILS_VERSION"
-task2_depends1 configure_binutils prepare_toolchain_sources
-task2_depends2 configure_binutils copy_sysroot
-cmd_configure_binutils ()
-{
-    OUT_DIR=$(build_binutils_dir)
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    $TOOLCHAIN_SRC_DIR/binutils/binutils-$BINUTILS_VERSION/configure \
-        --prefix=$(install_dir) \
-        --with-sysroot=$(sysroot_dir) \
-        --target=$GCC_TARGET
-}
-
-task2_define build_binutils "Build binutils-$BINUTILS_VERSION"
-task2_depends2 build_binutils configure_binutils
-cmd_build_binutils ()
-{
-    cd $(build_binutils_dir) &&
-    make $MAKE_FLAGS
-}
-
-task2_define install_binutils "Install binutils-$BINUTILS_VERSION"
-task2_depends2 install_binutils build_binutils
-cmd_install_binutils ()
-{
-    cd $(build_binutils_dir) &&
-    make install
-}
-
-task2_define extract_gmp "Extract sources for gmp-$GMP_VERSION"
-task2_depends1 extract_gmp prepare_toolchain_sources
-cmd_extract_gmp ()
-{
-    OUT_DIR=$(build_gmp_dir)
-    GMP_TARBALL=$TOOLCHAIN_SRC_DIR/gmp/gmp-$GMP_VERSION.tar.bz2
-    if [ ! -f "$GMP_TARBALL" ]; then
-        GMP_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/gmp-$GMP_VERSION.tar.bz2
-        if [ ! -f "$GMP_TARBALL" ]; then
-            panic "Can't find gmp-$GMP_VERSION sources!!"
-        fi
-    fi
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    tar xjf "$GMP_TARBALL"
-}
-
-task2_define configure_gmp "Configure gmp-$GMP_VERSION"
-task2_depends2 configure_gmp extract_gmp install_binutils
-cmd_configure_gmp ()
-{
-    export ABI=$GMP_ABI &&
-    cd $(build_gmp_dir) && mkdir -p build && cd build &&
-    ../gmp-$GMP_VERSION/configure \
-        --prefix=$(install_dir) \
-        --host=$GMP_TARGET \
-        --with-sysroot=$(install_dir) \
-        --disable-shared
-}
-
-task2_define build_gmp "Build gmp-$GMP_VERSION"
-task2_depends2 build_gmp configure_gmp
-cmd_build_gmp ()
-{
-    export ABI=$GMP_ABI &&
-    cd $(build_gmp_dir)/build &&
-    make $MAKE_FLAGS
-}
-
-task2_define install_gmp "Install gmp-$GMP_VERSION"
-task2_depends2 install_gmp build_gmp
-cmd_install_gmp ()
-{
-    cd $(build_gmp_dir)/build &&
-    make install
-}
-
-# Third, build mpfr
-task2_define extract_mpfr "Extract sources from mpfr-$MPFR_VERSION"
-task2_depends1 extract_mpfr prepare_toolchain_sources
-cmd_extract_mpfr ()
-{
-    OUT_DIR=$(build_mpfr_dir)
-    MPFR_TARBALL=$TOOLCHAIN_SRC_DIR/mpfr/mpfr-$MPFR_VERSION.tar.bz2
-    if [ ! -f "$MPFR_TARBALL" ]; then
-        MPFR_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/mpfr-$MPFR_VERSION.tar.bz2
-        if [ ! -f "$MPFR_TARBALL" ]; then
-            panic "Can't find mpfr-$MPFR_VERSION sources!!"
-        fi
-    fi
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    tar xjf "$MPFR_TARBALL"
-}
-
-task2_define configure_mpfr "Configure mpfr-$MPFR_VERSION"
-task2_depends2 configure_mpfr extract_mpfr install_gmp
-cmd_configure_mpfr ()
-{
-    cd $(build_mpfr_dir) && mkdir -p build && cd build &&
-    run ../mpfr-$MPFR_VERSION/configure \
-        --prefix=$(install_dir) \
-        --host=$GMP_TARGET \
-        --with-gmp=$(install_dir) \
-        --with-sysroot=$(sysroot_dir) \
-        --disable-shared
-}
-
-task2_define build_mpfr "Build mpfr-$MPFR_VERSION"
-task2_depends2 build_mpfr configure_mpfr
-cmd_build_mpfr ()
-{
-    cd $(build_mpfr_dir)/build &&
-    run make $MAKE_FLAGS
-}
-
-task2_define install_mpfr "Install mpfr-$MPFR_VERSION"
-task2_depends2 install_mpfr build_mpfr
-cmd_install_mpfr ()
-{
-    cd $(build_mpfr_dir)/build &&
-    run make install
-}
-
-task2_define extract_mpc "Extract sources for mpc-$MPC_VERSION"
-task2_depends1 extract_mpc prepare_toolchain_sources
-cmd_extract_mpc ()
-{
-    OUT_DIR=$(build_mpc_dir)
-    MPC_TARBALL=$TOOLCHAIN_SRC_DIR/mpc/mpc-$MPC_VERSION.tar.gz
-    if [ ! -f "$MPC_TARBALL" ]; then
-        MPC_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/mpc-$MPC_VERSION.tar.gz
-        if [ ! -f "$MPC_TARBALL" ]; then
-            panic "Can't find mpc-$MPC_VERSION sources!!"
-        fi
-    fi
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    tar xzf "$MPC_TARBALL"
-}
-
-task2_define configure_mpc "Configure mpc-$MPC_VERSION"
-task2_depends2 configure_mpc extract_mpc install_mpfr
-cmd_configure_mpc ()
-{
-    cd $(build_mpc_dir) && mkdir -p build && cd build &&
-    run ../mpc-$MPC_VERSION/configure \
-        --prefix=$(install_dir) \
-        --host=$GMP_TARGET \
-        --with-gmp=$(install_dir) \
-        --with-mpfr=$(install_dir) \
-        --disable-shared
-}
-
-task2_define build_mpc "Build mpc-$MPC_VERSION"
-task2_depends2 build_mpc configure_mpc
-cmd_build_mpc ()
-{
-    cd $(build_mpc_dir)/build &&
-    run make $MAKE_FLAGS
-}
-
-task2_define install_mpc "Install mpc-$MPC_VERSION"
-task2_depends2 install_mpc build_mpc
-cmd_install_mpc ()
-{
-    cd $(build_mpc_dir)/build &&
-    run make install
-}
-
-task2_define extract_isl "Extract sources for isl-$ISL_VERSION"
-task2_depends2 extract_isl prepare_toolchain_sources
-cmd_extract_isl ()
-{
-    OUT_DIR=$(build_isl_dir)
-    ISL_TARBALL=$TOOLCHAIN_SRC_DIR/isl/isl-$ISL_VERSION.tar.bz2
-    if [ ! -f "$ISL_TARBALL" ]; then
-        panic "Can't find isl-$ISL_VERSION sources!!"
-    fi
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    tar xf "$ISL_TARBALL"
-}
-
-task2_define configure_isl "Configuring isl-$ISL_VERSION"
-task2_depends2 configure_isl extract_isl install_gmp
-cmd_configure_isl ()
-{
-    cd $(build_isl_dir) && mkdir -p build && cd build &&
-    run ../isl-$ISL_VERSION/configure \
-        --prefix=$(install_dir) \
-        --host=$GMP_TARGET \
-        --with-gmp-prefix=$(install_dir) \
-        --with-sysroot=$(sysroot_dir) \
-        --disable-shared
-}
-
-task2_define build_isl "Building isl-$ISL_VERSION"
-task2_depends2 build_isl configure_isl
-cmd_build_isl ()
-{
-    cd $(build_isl_dir)/build &&
-    run make $MAKE_FLAGS
-}
-
-task2_define install_isl "Installing isl-$ISL_VERSION"
-task2_depends2 install_isl build_isl
-cmd_install_isl ()
-{
-    cd $(build_isl_dir)/build &&
-    make install
-}
-
-# task2_define extract_cloog "Extract sources for Cloog-$CLOOG_VERSION"
-# task2_depends2 extract_cloog prepare_toolchain_sources
-# cmd_extract_cloog ()
-# {
-#     OUT_DIR=$(build_cloog_dir)
-#     CLOOG_TARBALL=$TOOLCHAIN_SRC_DIR/cloog/cloog-$CLOOG_VERSION.tar.gz
-#     if [ ! -f "$CLOOG_TARBALL" ]; then
-#         CLOOG_TARBALL=$TOOLCHAIN_SRC_DIR/tarballs/cloog-$CLOOG_VERSION.tar.gz
-#         if [ ! -f "$CLOOG_TARBALL" ]; then
-#             panic "Can't find cloog-$CLOOG_VERSION sources!!"
-#         fi
-#     fi
-#     mkdir -p $OUT_DIR && cd $OUT_DIR &&
-#     tar xzf "$CLOOG_TARBALL"
-# }
-# 
-task2_define configure_cloog "Configure Cloog-$CLOOG_VERSION"
-task2_depends2 configure_cloog prepare_toolchain_sources install_gmp install_isl
-cmd_configure_cloog () {
-    mkdir -p $(build_cloog_dir)/build && cd $(build_cloog_dir)/build &&
-    run $TOOLCHAIN_SRC_DIR/cloog/cloog-$CLOOG_VERSION/configure \
-        --prefix=$(install_dir) \
-        --host=$GMP_TARGET \
-        --with-gmp-prefix=$(install_dir) \
-        --with-sysroot=$(sysroot_dir) \
-        --disable-shared
-}
-
-task2_define build_cloog "Building Cloog-$CLOOG_VERSION"
-task2_depends2 build_cloog configure_cloog
-cmd_build_cloog ()
-{
-    cd $(build_cloog_dir)/build &&
-    run make $MAKE_FLAGS
-}
-
-task2_define install_cloog "Installing Cloog-$CLOOG_VERSION"
-task2_depends2 install_cloog build_cloog
-cmd_install_cloog ()
-{
-    cd $(build_cloog_dir)/build &&
-    run make install
-}
-
-# Fourth, the compiler itself
-task2_define configure_gcc "Configure gcc-$GCC_VERSION"
-task2_depends1 configure_gcc prepare_toolchain_sources
-task2_depends2 configure_gcc install_binutils install_gmp install_mpfr install_mpc install_cloog
-cmd_configure_gcc ()
-{
-    OUT_DIR=$(build_gcc_dir)
-    mkdir -p $OUT_DIR && cd $OUT_DIR &&
-    export PATH=$(install_dir)/bin:$OLD_PATH &&
-    export CC=$HOST_CC &&
-    export CC_FOR_TARGET="$HOST_CC" &&
-    export LD_LIBRARY_PATH=$(install_dir)/lib:$OLD_LD_LIBRARY_PATH &&
-    export LDFLAGS="-L$(install_dir)/lib" &&
-    run $TOOLCHAIN_SRC_DIR/gcc/gcc-$GCC_VERSION/configure \
-        --prefix=$(install_dir) \
-        --with-sysroot=$(sysroot_dir) \
-        --disable-nls \
-        --with-gmp=$(install_dir) \
-        --with-mpfr=$(install_dir) \
-        --with-mpc=$(install_dir) \
-        --with-cloog=$(install_dir) \
-        --target=$GCC_TARGET \
-        --disable-plugin \
-        --disable-docs \
-        --disable-multilib \
-        --disable-bootstrap \
-        --disable-libgomp \
-        --disable-libmudflap \
-        --disable-libquadmath \
-        --enable-target-optspace \
-        --enable-gold=default \
-        --enable-languages=c,c++
-}
-
-task2_define build_gcc "Build gcc-$GCC_VERSION"
-task2_depends2 build_gcc configure_gcc
-cmd_build_gcc ()
-{
-    export PATH=$(install_dir)/bin:$OLD_PATH &&
-    export LD_LIBRARY_PATH=$(install_dir)/lib:$OLD_LD_LIBRARY_PATH &&
-    cd $(build_gcc_dir) &&
-    make $MAKE_FLAGS
-}
-
-task2_define install_gcc "Install gcc-$GCC_VERSION"
-task2_depends2 install_gcc build_gcc
-cmd_install_gcc ()
-{
-    export PATH=$(install_dir)/bin:$OLD_PATH &&
-    export LD_LIBRARY_PATH=$(install_dir)/lib:$OLD_LD_LIBRARY_PATH &&
-    cd $(build_gcc_dir) &&
-    make install
-}
-
-task2_define cleanup_toolchain "Cleanup toolchain"
-task2_depends2 cleanup_toolchain install_gcc
-cmd_cleanup_toolchain ()
-{
-    # Remove un-needed directories and files
-    rm -rf $(install_dir)/share
-    rm -rf $(install_dir)/man
-    rm -rf $(install_dir)/info
-    rm -rf $(install_dir)/lib32
-    rm -rf $(install_dir)/lib64
-    rm -rf $(install_dir)/libexec/*/*/install-tools
-    #rm -rf $(install_dir)/$GCC_TARGET/bin
-
-    (strip $(install_dir)/bin/*)
-    (strip $(install_dir)/libexec/gcc/$GCC_TARGET/*/*)
-    true
-}
-
-task2_define package_toolchain "Package final toolchain"
-task2_depends2 package_toolchain cleanup_toolchain
-cmd_package_toolchain ()
-{
-    # Copy this script to the install directory
-    cp -f $0 $(install_dir)
-    fail_panic "Could not copy build script to install directory"
-
-    if [ -d "$PATCHES_DIR" ]; then
-        # Copy patches to the install directory
-        cp -rf "$PATCHES_DIR" $(install_dir)
-        fail_panic "Could not copy patch directory to install directory"
-    fi
-
-    # Copy the SOURCES file as well
-    cp $DOWNLOAD_DIR/SOURCES $(install_dir)/PACKAGE_SOURCES &&
-    cp $TOOLCHAIN_SRC_DIR/SOURCES $(install_dir)/TOOLCHAIN_SOURCES
-    fail_panic "Could not copy SOURCES files to install directory"
-
-    # Package everything
-    pack_archive $TOOLCHAIN_ARCHIVE "`dirname $(install_dir)`" "`basename $(install_dir)`"
-}
-
-task2_define install_toolchain "Install final toolchain"
-task2_depends2 install_toolchain cleanup_toolchain
-cmd_install_toolchain ()
-{
-    copy_directory "$(install_dir)" "$PREFIX_DIR/$TOOLCHAIN_NAME"
-    cp -f $0 "$PREFIX_DIR/$TOOLCHAIN_NAME/"
-}
-
-# Make sure that the second toolchain depends on the first one
-task_depends configure_binutils_2 install_gcc_1
-
-if [ "$ONLY_SYSROOT" = "yes" ]; then
-    MAIN_TASK=copy_sysroot
-    COMPLETION_TEXT="Done, see sysroot files in $(sysroot_dir)"
-elif [ -n "$PREFIX_DIR" ]; then
-    if [ -z "$BOOTSTRAP" ]; then
-        MAIN_TASK=install_toolchain_1
-    else
-        MAIN_TASK=install_toolchain_2
-    fi
-    COMPLETION_TEXT="Done, see $PREFIX_DIR/$TOOLCHAIN_NAME"
-else
-    if [ -z "$BOOTSTRAP" ]; then
-        MAIN_TASK=package_toolchain_1
-    else
-        MAIN_TASK=package_toolchain_2
-    fi
-    COMPLETION_TEXT="Done, see $TOOLCHAIN_ARCHIVE"
-fi
-
-if [ "$LIST_TASKS" ]; then
-    task_dump
-else
-    run_task $MAIN_TASK
-    echo "$COMPLETION_TEXT"
-fi
diff --git a/include/cloog/block.h b/include/cloog/block.h
new file mode 100644
index 0000000..95f2a44
--- /dev/null
+++ b/include/cloog/block.h
@@ -0,0 +1,117 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                             block.h                               **
+    **-------------------------------------------------------------------**
+    **                    First version: June 11th 2005                  **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_BLOCK_H
+#define CLOOG_BLOCK_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+/**
+ * CloogBlock structure:
+ * this structure contains the informations of a statement block. It may happen
+ * that users are lazy enough to ask CLooG to generate the code for statements
+ * with exactly the same domain/scattering pair (possibly differing by only one
+ * constant) instead of giving only one pair. CLooG provides them a last chance
+ * to save time and memory by trying to find these blocks itself. The block
+ * contains the statement list and the common informations of the statements.
+ * This structure contains also the number of existing active references to it:
+ * because CLooG uses many copies of blocks there is no need to actually copy
+ * these blocks but just to return a pointer to them and to increment the number
+ * of active references. Each time a CloogBlock will be freed, we will decrement
+ * the active reference counter and actually free it if its value is zero.
+ */
+struct cloogblock
+{
+  CloogState *state;            /**< State. */
+  CloogStatement * statement ;  /**< The list of statements in the block. */
+  int  nb_scaldims ;            /**< Number of scalar dimensions. */
+  cloog_int_t *scaldims;        /**< Scalar dimension values. */
+  int depth ;                   /**< Original block depth (outer loop number).*/
+  int references ;              /**< Number of references to this structure. */
+  void * usr;		        /**< User field, for library user convenience.
+				 *   This pointer is not freed when the
+				 *   CloogBlock structure is freed.
+			         */
+} ;
+typedef struct cloogblock CloogBlock ;
+
+
+/**
+ * CloogBlockList structure:
+ * this structure reprensents a node of a linked list of CloogBlock structures.
+ */
+struct cloogblocklist
+{ CloogBlock * block ;          /**< An element of the list. */
+  struct cloogblocklist * next ;/**< Pointer to the next element of the list.*/
+} ;
+typedef struct cloogblocklist CloogBlockList ;
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_block_print_structure(FILE *, CloogBlock *, int) ;
+void cloog_block_print(FILE *, CloogBlock *) ;
+void cloog_block_list_print(FILE *, CloogBlockList *) ;
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_block_free(CloogBlock *) ;
+void cloog_block_list_free(CloogBlockList *) ;
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogBlock     * cloog_block_malloc(CloogState *state);
+CloogBlock     * cloog_block_alloc(CloogStatement *statement, int nb_scaldims,
+				    cloog_int_t *scaldims, int depth);
+CloogBlockList * cloog_block_list_malloc(void);
+CloogBlockList * cloog_block_list_alloc(CloogBlock *) ;
+CloogBlock     * cloog_block_copy(CloogBlock * block) ;
+void             cloog_block_merge(CloogBlock *, CloogBlock *) ;
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
+
diff --git a/include/cloog/clast.h b/include/cloog/clast.h
new file mode 100644
index 0000000..fd56dd7
--- /dev/null
+++ b/include/cloog/clast.h
@@ -0,0 +1,176 @@
+#ifndef CLOOG_CLAST_H
+#define CLOOG_CLAST_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+enum clast_expr_type {
+    clast_expr_name,
+    clast_expr_term,
+    clast_expr_bin,
+    clast_expr_red
+};
+struct clast_expr {
+    enum clast_expr_type type;
+};
+
+struct clast_name {
+    struct clast_expr	expr;
+    const char *	name;
+};
+
+/* Represents the term
+ *	val * var	(if var != NULL)
+ * or
+ *	val		(if var == NULL)
+ */
+struct clast_term {
+    struct clast_expr	expr;
+    cloog_int_t		val;
+    struct clast_expr  *var;
+};
+
+#define CLAST_PARALLEL_NOT 0
+#define CLAST_PARALLEL_OMP 1
+#define CLAST_PARALLEL_MPI 2
+#define CLAST_PARALLEL_VEC 4
+
+enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max };
+struct clast_reduction {
+    struct clast_expr	expr;
+    enum clast_red_type	type;
+    int			n;
+    struct clast_expr*	elts[1];
+};
+
+enum clast_bin_type { clast_bin_fdiv, clast_bin_cdiv, 
+		      clast_bin_div, clast_bin_mod };
+struct clast_binary {
+    struct clast_expr	expr;
+    enum clast_bin_type type;
+    struct clast_expr*	LHS;
+    cloog_int_t		RHS;
+};
+
+struct clast_stmt;
+struct clast_stmt_op {
+    void (*free)(struct clast_stmt *);
+};
+
+#define CLAST_STMT_IS_A(stmt, type) ((stmt)->op == &(type))
+
+extern const struct clast_stmt_op stmt_root;
+extern const struct clast_stmt_op stmt_ass;
+extern const struct clast_stmt_op stmt_user;
+extern const struct clast_stmt_op stmt_block;
+extern const struct clast_stmt_op stmt_for;
+extern const struct clast_stmt_op stmt_guard;
+
+struct clast_stmt {
+    const struct clast_stmt_op    *op;
+    struct clast_stmt	*next;
+};
+
+struct clast_root {
+    struct clast_stmt	stmt;
+    CloogNames *	names;       /**< Names of iterators and parameters. */
+};
+
+struct clast_assignment {
+    struct clast_stmt	stmt;
+    const char *	LHS;
+    struct clast_expr *	RHS;
+};
+
+struct clast_block {
+    struct clast_stmt	stmt;
+    struct clast_stmt *	body;
+};
+
+struct clast_user_stmt {
+    struct clast_stmt	stmt;
+    CloogDomain *	domain;
+    CloogStatement *	statement;
+    struct clast_stmt *	substitutions;
+};
+
+struct clast_for {
+    struct clast_stmt	stmt;
+    CloogDomain *	domain;
+    const char *	iterator;
+    struct clast_expr *	LB;
+    struct clast_expr *	UB;
+    cloog_int_t		stride;
+    struct clast_stmt *	body;
+    int parallel;
+    /* Comma separated list of loop private variables for OpenMP parallelization */
+    char *private_vars;
+    /* Comma separated list of reduction variable/operators for OpenMP parallelization */
+    char *reduction_vars;
+};
+
+struct clast_equation {
+    struct clast_expr *	LHS;
+    struct clast_expr *	RHS;
+    int			sign;
+};
+
+struct clast_guard {
+    struct clast_stmt	stmt;
+    struct clast_stmt *	then;
+    int			n;
+    struct clast_equation	eq[1];
+};
+
+
+struct clast_stmt *cloog_clast_create_from_input(CloogInput *input,
+						 CloogOptions *options);
+struct clast_stmt *cloog_clast_create(CloogProgram *program,
+				      CloogOptions *options);
+void cloog_clast_free(struct clast_stmt *s);
+
+struct clast_name *new_clast_name(const char *name);
+struct clast_term *new_clast_term(cloog_int_t c, struct clast_expr *v);
+struct clast_binary *new_clast_binary(enum clast_bin_type t, 
+				      struct clast_expr *lhs, cloog_int_t rhs);
+struct clast_reduction *new_clast_reduction(enum clast_red_type t, int n);
+struct clast_root *new_clast_root(CloogNames *names);
+struct clast_assignment *new_clast_assignment(const char *lhs,
+					      struct clast_expr *rhs);
+struct clast_user_stmt *new_clast_user_stmt(CloogDomain *domain,
+    CloogStatement *stmt, struct clast_stmt *subs);
+struct clast_block *new_clast_block(void);
+struct clast_for *new_clast_for(CloogDomain *domain, const char *it,
+                                struct clast_expr *LB, struct clast_expr *UB,
+                                CloogStride *stride);
+struct clast_guard *new_clast_guard(int n);
+
+void free_clast_name(struct clast_name *t);
+void free_clast_term(struct clast_term *t);
+void free_clast_binary(struct clast_binary *b);
+void free_clast_reduction(struct clast_reduction *r);
+void free_clast_expr(struct clast_expr *e);
+void free_clast_stmt(struct clast_stmt *s);
+
+int clast_expr_equal(struct clast_expr *e1, struct clast_expr *e2);
+
+struct clast_expr *clast_bound_from_constraint(CloogConstraint *constraint,
+					       int level, CloogNames *names);
+
+typedef enum filterType {exact, subset} ClastFilterType;
+
+typedef struct clastFilter{
+    const char *iter;
+    const int *stmts_filter;
+    int nstmts_filter;
+    ClastFilterType filter_type;
+} ClastFilter;
+
+void clast_filter(struct clast_stmt *node, ClastFilter filter,
+        struct clast_for ***loops, int *nloops, int **stmts, int *nstmts);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/cloog.h b/include/cloog/cloog.h
new file mode 100644
index 0000000..a8c3f28
--- /dev/null
+++ b/include/cloog/cloog.h
@@ -0,0 +1,62 @@
+
+   /**-------------------------------------------------------------------**
+    **                               CLooG                               **
+    **-------------------------------------------------------------------**
+    **                              cloog.h                              **
+    **-------------------------------------------------------------------**
+    **                   First version: july 25th 2002                   **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+/******************************************************************************
+ *  THIS FILE HAS BEEN AUTOMATICALLY GENERATED FROM clooh.h.in BY configure   *
+ ******************************************************************************/
+
+#ifndef CLOOG_H
+#define CLOOG_H
+
+#include <cloog/version.h>
+#include <cloog/int.h>
+#include <cloog/matrix.h>
+#include <cloog/state.h>
+#include <cloog/options.h>
+#include <cloog/names.h>
+#include <cloog/constraints.h>
+#include <cloog/stride.h>
+#include <cloog/domain.h>
+#include <cloog/statement.h>
+#include <cloog/block.h>
+#include <cloog/loop.h>
+#include <cloog/union_domain.h>
+#include <cloog/input.h>
+#include <cloog/program.h>
+#include <cloog/clast.h>
+#include <cloog/pprint.h>
+
+#endif /* !CLOOG_H */
diff --git a/include/cloog/constraints.h b/include/cloog/constraints.h
new file mode 100644
index 0000000..4818c4c
--- /dev/null
+++ b/include/cloog/constraints.h
@@ -0,0 +1,121 @@
+
+   /**-------------------------------------------------------------------**
+    **                               CLooG                               **
+    **-------------------------------------------------------------------**
+    **                           constraints.h                           **
+    **-------------------------------------------------------------------**
+    **                    First version: april 17th 2005                 **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2005 Cedric Bastoul                                          *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_CONSTRAINTS_H
+#define CLOOG_CONSTRAINTS_H
+
+struct cloogconstraint;
+typedef struct cloogconstraint CloogConstraint;
+struct cloogconstraintset;
+typedef struct cloogconstraintset CloogConstraintSet;
+struct cloogequalities;
+typedef struct cloogequalities CloogEqualities;
+
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+/******************************************************************************
+ *                        Equalities spreading functions                      *
+ ******************************************************************************/
+CloogEqualities *cloog_equal_alloc(int n, int nb_levels,
+			int nb_parameters);
+void		 cloog_equal_free(CloogEqualities *equal);
+int              cloog_equal_count(CloogEqualities *equal);
+int              cloog_equal_type(CloogEqualities *equal, int level);
+void             cloog_equal_del(CloogEqualities *equal, int level);
+int              cloog_equal_total_dimension(CloogEqualities *equal);
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+void          cloog_constraint_set_normalize(CloogConstraintSet *, int);
+void          cloog_constraint_set_free(CloogConstraintSet *);
+int           cloog_constraint_set_contains_level(CloogConstraintSet *constraints,
+			int level, int nb_parameters);
+int           cloog_constraint_set_total_dimension(CloogConstraintSet *constraints);
+int           cloog_constraint_set_n_iterators(CloogConstraintSet *constraints,
+			int nb_parameters);
+CloogConstraintSet *cloog_constraint_set_copy(CloogConstraintSet *);
+CloogConstraintSet *cloog_constraint_set_simplify(CloogConstraintSet *, CloogEqualities *, int, int);
+
+int cloog_constraint_needs_reduction(CloogConstraint *upper, int level);
+CloogConstraintSet *cloog_constraint_set_for_reduction(CloogConstraint *upper,
+	       CloogConstraint *lower);
+CloogConstraintSet *cloog_constraint_set_reduce(CloogConstraintSet *constraints,
+	int level, CloogEqualities *equal, int nb_par, cloog_int_t *bound);
+int cloog_constraint_set_foreach_constraint(CloogConstraintSet *constraints,
+	int (*fn)(CloogConstraint *constraint, void *user), void *user);
+int              cloog_constraint_is_valid(CloogConstraint *constraint);
+CloogConstraint *cloog_constraint_copy(CloogConstraint *constraint);
+void             cloog_constraint_release(CloogConstraint *constraint);
+CloogConstraint *cloog_constraint_invalid(void);
+int              cloog_constraint_total_dimension(CloogConstraint *constraint);
+
+CloogConstraint *cloog_equal_constraint(CloogEqualities *equal, int j);
+void             cloog_equal_add(CloogEqualities *equal,
+				  CloogConstraintSet *constraints,
+				  int level, CloogConstraint *line, int nb_par);
+
+CloogConstraint *cloog_constraint_set_defining_equality(
+			CloogConstraintSet *constraints, int level);
+CloogConstraint *cloog_constraint_set_defining_inequalities(
+			CloogConstraintSet *constraints,
+			int level, CloogConstraint **lower, int nb_parameters);
+int           cloog_constraint_involves(CloogConstraint *constraint, int v);
+int           cloog_constraint_is_lower_bound(CloogConstraint *constraint, int v);
+int           cloog_constraint_is_upper_bound(CloogConstraint *constraint, int v);
+int           cloog_constraint_is_equality(CloogConstraint *constraint);
+void          cloog_constraint_constant_get(CloogConstraint *constraint,
+			cloog_int_t *val);
+void          cloog_constraint_coefficient_get(CloogConstraint *constraint,
+			int var, cloog_int_t *val);
+void          cloog_constraint_coefficient_set(CloogConstraint *constraint,
+			int var, cloog_int_t val);
+void          cloog_constraint_copy_coefficients(CloogConstraint *constraint,
+			cloog_int_t *dst);
+CloogConstraintSet *cloog_constraint_set_drop_constraint(
+	CloogConstraintSet *constraints, CloogConstraint *constraint);
+
+struct clast_expr *cloog_constraint_variable_expr(CloogConstraint *constraint,
+			int level, CloogNames *names);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/domain.h b/include/cloog/domain.h
new file mode 100644
index 0000000..767771b
--- /dev/null
+++ b/include/cloog/domain.h
@@ -0,0 +1,177 @@
+
+   /**-------------------------------------------------------------------**
+    **                               CLooG                               **
+    **-------------------------------------------------------------------**
+    **                             domain.h                              **
+    **-------------------------------------------------------------------**
+    **                  First version: october 28th 2001                 **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_DOMAIN_H
+#define CLOOG_DOMAIN_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+struct cloogdomain;
+typedef struct cloogdomain CloogDomain ;
+struct cloogscattering;
+typedef struct cloogscattering CloogScattering;
+struct osl_relation;
+
+
+/**
+ * CloogDomainList structure:
+ * this structure reprensents a node of a linked list of CloogDomain structures.
+ */
+struct cloogdomainlist {
+  CloogDomain *domain;         /**< An element of the list. */
+  struct cloogdomainlist *next;/**< Pointer to the next element of the list.*/
+} ;
+typedef struct cloogdomainlist CloogDomainList;
+
+
+/**
+ * CloogScatteringList structure:
+ * this structure reprensents a node of a linked list of CloogScattering structures.
+ */
+struct cloogscatteringlist {
+  CloogScattering *scatt;          /**< An element of the list. */
+  struct cloogscatteringlist *next;/**< Pointer to the next element of the list.*/
+} ;
+typedef struct cloogscatteringlist CloogScatteringList;
+
+
+/******************************************************************************
+ *                              PolyLib interface                             *
+ ******************************************************************************/
+void          cloog_domain_print_constraints(FILE *, CloogDomain *,
+						int print_number);
+void          cloog_scattering_print_constraints(FILE *, CloogScattering *);
+void          cloog_domain_free(CloogDomain *) ;
+void          cloog_scattering_free(CloogScattering *);
+CloogDomain * cloog_domain_copy(CloogDomain *) ;
+CloogDomain * cloog_domain_convex(CloogDomain * Pol) ;
+CloogDomain * cloog_domain_simple_convex(CloogDomain * domain);
+CloogDomain * cloog_domain_simplify(CloogDomain *, CloogDomain *) ;
+CloogDomain * cloog_domain_union(CloogDomain *, CloogDomain *) ;
+CloogDomain * cloog_domain_intersection(CloogDomain *, CloogDomain *) ;
+CloogDomain * cloog_domain_difference(CloogDomain *, CloogDomain *) ;
+void          cloog_domain_sort(CloogDomain**,unsigned,unsigned,int *);
+int cloog_domain_follows(CloogDomain *dom1, CloogDomain *dom2, unsigned level);
+CloogDomain * cloog_domain_empty(CloogDomain *model);
+int cloog_domain_is_bounded(CloogDomain *dim, unsigned level);
+CloogDomain *cloog_domain_bound_splitter(CloogDomain *dom, int level);
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_domain_print_structure(FILE *file, CloogDomain *domain, int level,
+				  const char *name);
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_domain_list_free(CloogDomainList *);
+void cloog_scattering_list_free(CloogScatteringList *);
+
+
+/*+****************************************************************************
+ *                               Reading function                             *
+ ******************************************************************************/
+CloogDomain * cloog_domain_read_context(CloogState *state, FILE * foo);
+CloogDomain * cloog_domain_union_read(CloogState *state, FILE *foo, int nb_par);
+CloogScattering *cloog_domain_read_scattering(CloogDomain *domain, FILE *foo);
+
+CloogDomain * cloog_domain_from_cloog_matrix(CloogState *state,
+				CloogMatrix *matrix, int nb_par);
+CloogScattering * cloog_scattering_from_cloog_matrix(CloogState *state,
+				CloogMatrix *matrix, int nb_scat, int nb_par);
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogDomain *cloog_domain_from_osl_relation(CloogState *,
+                                            struct osl_relation *);
+CloogScattering *cloog_scattering_from_osl_relation(CloogState *,
+                                                    struct osl_relation *);
+CloogConstraintSet *cloog_domain_constraints(CloogDomain *);
+int           cloog_domain_isempty(CloogDomain *) ;
+CloogDomain * cloog_domain_universe(CloogState *state, unsigned dim);
+CloogDomain * cloog_domain_project(CloogDomain *, int);
+CloogDomain * cloog_domain_extend(CloogDomain *, int);
+int           cloog_domain_never_integral(CloogDomain *) ;
+void          cloog_domain_stride(CloogDomain *, int, cloog_int_t *, cloog_int_t *);
+int           cloog_domain_can_stride(CloogDomain *domain, int level);
+int           cloog_domain_is_otl(CloogDomain *domain, int level);
+CloogDomain * cloog_domain_stride_lower_bound(CloogDomain *domain, int level,
+					CloogStride *stride);
+CloogDomain * cloog_domain_add_stride_constraint(CloogDomain *domain,
+					CloogStride *stride);
+int           cloog_domain_can_unroll(CloogDomain *domain, int level,
+				cloog_int_t *n, CloogConstraint **lb);
+CloogDomain * cloog_domain_fixed_offset(CloogDomain *domain, int level,
+				CloogConstraint *lb, cloog_int_t offset);
+int           cloog_domain_lazy_disjoint(CloogDomain *, CloogDomain *) ;
+int           cloog_domain_lazy_equal(CloogDomain *, CloogDomain *) ;
+int           cloog_scattering_lazy_block(CloogScattering *, CloogScattering *,
+                                      CloogScatteringList *, int);
+int           cloog_scattering_lazy_isscalar(CloogScattering *, int,
+								cloog_int_t *);
+int           cloog_domain_lazy_isconstant(CloogDomain *domain, int dimension,
+					   cloog_int_t *value);
+int           cloog_scattering_list_lazy_same(CloogScatteringList *);
+CloogDomain * cloog_domain_cut_first(CloogDomain *domain, CloogDomain **rest);
+CloogDomain * cloog_domain_simplify_union(CloogDomain *domain);
+CloogScattering * cloog_scattering_erase_dimension(CloogScattering *, int);
+
+int           cloog_domain_dimension(CloogDomain *) ;
+int           cloog_domain_parameter_dimension(CloogDomain *domain);
+int           cloog_scattering_dimension(CloogScattering *, CloogDomain *);
+int           cloog_domain_isconvex(CloogDomain *) ;
+CloogDomain * cloog_domain_cube(CloogState *state,
+				int dim, cloog_int_t min, cloog_int_t max);
+CloogDomain * cloog_domain_from_context(CloogDomain *context);
+CloogDomain * cloog_domain_scatter(CloogDomain *domain, CloogScattering *scatt);
+int           cloog_scattering_fully_specified(CloogScattering *scattering,
+						CloogDomain *domain);
+
+CloogStride *cloog_domain_list_stride(CloogDomainList *list, int level);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/input.h b/include/cloog/input.h
new file mode 100644
index 0000000..b3d3c53
--- /dev/null
+++ b/include/cloog/input.h
@@ -0,0 +1,27 @@
+#ifndef CLOOG_INPUT_H
+#define CLOOG_INPUT_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif 
+
+struct osl_scop;
+
+struct clooginput {
+	CloogDomain *context;
+	CloogUnionDomain *ud;
+};
+typedef struct clooginput CloogInput;
+
+CloogInput *cloog_input_from_osl_scop(CloogState *, struct osl_scop *);
+CloogInput *cloog_input_read(FILE *file, CloogOptions *options);
+CloogInput *cloog_input_alloc(CloogDomain *context, CloogUnionDomain *ud);
+void cloog_input_free(CloogInput *input);
+
+void cloog_input_dump_cloog(FILE *file, CloogInput *input, CloogOptions *opt);
+
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif
diff --git a/include/cloog/int.h b/include/cloog/int.h
new file mode 100644
index 0000000..623a1cb
--- /dev/null
+++ b/include/cloog/int.h
@@ -0,0 +1,174 @@
+#ifndef CLOOG_INT_H
+#define CLOOG_INT_H
+
+#include <assert.h>
+#include <stdio.h>
+#if defined(CLOOG_INT_GMP)
+#include <string.h>
+#include <gmp.h>
+#ifndef mp_get_memory_functions
+void mp_get_memory_functions(
+		void *(**alloc_func_ptr) (size_t),
+		void *(**realloc_func_ptr) (void *, size_t, size_t),
+		void (**free_func_ptr) (void *, size_t));
+#endif
+#endif
+
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+#if defined(CLOOG_INT_INT)
+typedef int		cloog_int_t;
+#define CLOOG_INT_FORMAT	"%d"
+#elif defined(CLOOG_INT_LONG)
+typedef long		cloog_int_t;
+#define CLOOG_INT_FORMAT	"%ld"
+#elif defined(CLOOG_INT_LONG_LONG)
+typedef long long	cloog_int_t;
+#define CLOOG_INT_FORMAT	"%lld"
+#elif defined(CLOOG_INT_GMP)
+typedef mpz_t		cloog_int_t;
+#else
+#error "No integer type defined"
+#endif
+
+#if defined(CLOOG_INT_GMP)
+
+#define cloog_int_init(i)	mpz_init(i)
+#define cloog_int_clear(i)	mpz_clear(i);
+
+#define cloog_int_set(r,i)	mpz_set(r,i)
+#define cloog_int_set_si(r,i)	mpz_set_si(r,i)
+#define cloog_int_abs(r,i)	mpz_abs(r,i)
+#define cloog_int_neg(r,i)	mpz_neg(r,i)
+#define cloog_int_swap(i,j)	mpz_swap(i,j)
+
+#define cloog_int_add(r,i,j)	mpz_add(r,i,j)
+#define cloog_int_add_ui(r,i,j)	mpz_add_ui(r,i,j)
+#define cloog_int_sub(r,i,j)	mpz_sub(r,i,j)
+#define cloog_int_sub_ui(r,i,j)	mpz_sub_ui(r,i,j)
+#define cloog_int_mul(r,i,j)	mpz_mul(r,i,j)
+#define cloog_int_addmul(r,i,j)	mpz_addmul(r,i,j)
+#define cloog_int_divexact(r,i,j)	mpz_divexact(r,i,j)
+#define cloog_int_tdiv_q(r,i,j)	mpz_tdiv_q(r,i,j)
+#define cloog_int_fdiv_q(r,i,j)	mpz_fdiv_q(r,i,j)
+#define cloog_int_fdiv_r(r,i,j)	mpz_fdiv_r(r,i,j)
+#define cloog_int_cdiv_q(r,i,j)	mpz_cdiv_q(r,i,j)
+#define cloog_int_gcd(r,i,j)	mpz_gcd(r,i,j)
+
+#define cloog_int_sgn(i)	mpz_sgn(i)
+#define cloog_int_cmp(i,j)	mpz_cmp(i,j)
+#define cloog_int_abs_cmp(i,j)	mpz_cmpabs(i,j)
+#define cloog_int_cmp_si(i,si)	mpz_cmp_si(i,si)
+#define cloog_int_eq(i,j)	(mpz_cmp(i,j) == 0)
+#define cloog_int_ne(i,j)	(mpz_cmp(i,j) != 0)
+#define cloog_int_gt(i,j)	(mpz_cmp(i,j) > 0)
+
+#define cloog_int_is_divisible_by(i,j)	mpz_divisible_p(i,j)
+
+#define cloog_int_read(r,s)	mpz_set_str(r,s,10)
+typedef void (*cloog_int_print_gmp_free_t)(void *, size_t);
+#define cloog_int_print(out,i)						\
+	do {								\
+		char *s;						\
+		cloog_int_print_gmp_free_t gmp_free;			\
+		s = mpz_get_str(0, 10, i);				\
+		fprintf(out, "%s", s);					\
+		mp_get_memory_functions(NULL, NULL, &gmp_free);		\
+		(*gmp_free)(s, strlen(s)+1);				\
+	} while (0)
+
+#else
+
+#define cloog_int_init(i)	((i) = 0)
+#define cloog_int_clear(i)	do { } while (0)
+
+#define cloog_int_set(r,i)	((r) = (i))
+#define cloog_int_set_si(r,i)	((r) = (i))
+#define cloog_int_abs(r,i)	((r) = (i) > 0 ? (i) : -(i))
+#define cloog_int_neg(r,i)	((r) = -(i))
+#define cloog_int_swap(i,j)	do {					\
+					cloog_int_t _t = i;		\
+					i = j;				\
+					j = _t;				\
+				} while (0)
+
+#define cloog_int_add(r,i,j)	((r) = (i) + (j))
+#define cloog_int_add_ui(r,i,j)	((r) = (i) + (j))
+#define cloog_int_sub(r,i,j)	((r) = (i) - (j))
+#define cloog_int_sub_ui(r,i,j)	((r) = (i) - (j))
+#define cloog_int_mul(r,i,j)	((r) = (i) * (j))
+#define cloog_int_addmul(r,i,j)	((r) += (i) * (j))
+#define cloog_int_divexact(r,i,j)	((r) = (i) / (j))
+#define cloog_int_tdiv_q(r,i,j)	((r) = (i) / (j))
+#define cloog_int_fdiv_q(r,i,j)	do {					\
+					assert((j) > 0);		\
+					(r) = (i) >= 0 ? (i) / (j) :	\
+					    -((-(i)+(j)-1)/(j));	\
+				} while (0)
+#define cloog_int_fdiv_r(r,i,j)	do {					\
+					assert((j) > 0);		\
+					(r) = (i) >= 0 ? (i) % (j) :	\
+					    (j)-1 - ((-(i)+(j)-1)%(j));	\
+				} while (0)
+#define cloog_int_cdiv_q(r,i,j)	do {					\
+					assert((j) > 0);		\
+					(r) = (i) >= 0 ?		\
+					    ((i)+(j)-1) / (j) :		\
+					    -(-(i)/(j));		\
+				} while (0)
+cloog_int_t cloog_gcd(cloog_int_t a, cloog_int_t b);
+#define cloog_int_gcd(r,i,j)	(r) = cloog_gcd(i,j)
+
+#define cloog_int_sgn(i)	((i) > 0 ? 1 : (i) < 0 ? -1 : 0)
+#define cloog_int_cmp(i,j)	(i - j)
+#define cloog_int_abs_cmp(i,j)	(((i) > 0 ? (i) : -(i)) - ((j) > 0 ? (j) : -(j)))
+#define cloog_int_cmp_si(i,si)	(i - si)
+#define cloog_int_eq(i,j)	((i) == (j))
+#define cloog_int_ne(i,j)	((i) != (j))
+#define cloog_int_gt(i,j)	((i) > (j))
+
+#define cloog_int_is_divisible_by(i,j)	((i) % (j) == 0)
+
+#define cloog_int_read(i,s)	sscanf(s, CLOOG_INT_FORMAT, &i)
+#define cloog_int_print(out,i)	fprintf(out, CLOOG_INT_FORMAT, i)
+
+#endif
+
+#define cloog_int_is_pos(i)	(cloog_int_sgn(i) > 0)
+#define cloog_int_is_neg(i)	(cloog_int_sgn(i) < 0)
+#define cloog_int_is_zero(i)	(cloog_int_sgn(i) == 0)
+#define cloog_int_is_one(i)	(cloog_int_cmp_si(i,1) == 0)
+#define cloog_int_is_neg_one(i)	(cloog_int_cmp_si(i,-1) == 0)
+#define cloog_int_gt_si(i,si)	(cloog_int_cmp_si(i,si) > 0)
+#define cloog_int_ne_si(i,j)	(cloog_int_cmp_si(i,j) != 0)
+#define cloog_int_lt(i,j)	(cloog_int_cmp(i,j) < 0)
+#define cloog_int_le(i,j)	(cloog_int_cmp(i,j) <= 0)
+#define cloog_int_abs_ne(i,j)	(cloog_int_abs_cmp(i,j) != 0)
+#define cloog_int_abs_ge(i,j)	(cloog_int_abs_cmp(i,j) >= 0)
+#define cloog_int_abs_lt(i,j)	(cloog_int_abs_cmp(i,j) < 0)
+
+struct cloog_vec {
+	unsigned	size;
+	cloog_int_t	*p;
+};
+
+struct cloog_vec *cloog_vec_alloc(unsigned size);
+void cloog_vec_free(struct cloog_vec *vec);
+
+int cloog_seq_first_non_zero(cloog_int_t *p, unsigned len);
+void cloog_seq_cpy(cloog_int_t *dst, cloog_int_t *src, unsigned len);
+void cloog_seq_neg(cloog_int_t *dst, cloog_int_t *src, unsigned len);
+void cloog_seq_combine(cloog_int_t *dst, cloog_int_t m1, cloog_int_t *src1,
+			cloog_int_t m2, cloog_int_t *src2, unsigned len);
+void cloog_seq_gcd(cloog_int_t *p, unsigned len, cloog_int_t *gcd);
+int cloog_seq_is_neg(cloog_int_t *p1, cloog_int_t *p2, unsigned len);
+void cloog_seq_normalize(cloog_int_t *p, unsigned len);
+
+#if defined(__cplusplus)
+  }
+#endif 
+
+#endif
diff --git a/include/cloog/isl/backend.h b/include/cloog/isl/backend.h
new file mode 100644
index 0000000..e4576d9
--- /dev/null
+++ b/include/cloog/isl/backend.h
@@ -0,0 +1,11 @@
+#ifndef CLOOG_ISL_BACKEND_H
+#define CLOOG_ISL_BACKEND_H
+
+#include <isl/constraint.h>
+
+struct cloogbackend {
+	struct isl_ctx	*ctx;
+	unsigned	ctx_allocated : 1;
+};
+
+#endif /* define _H */
diff --git a/include/cloog/isl/cloog.h b/include/cloog/isl/cloog.h
new file mode 100644
index 0000000..9379054
--- /dev/null
+++ b/include/cloog/isl/cloog.h
@@ -0,0 +1,22 @@
+#ifndef CLOOG_ISL_H
+#define CLOOG_ISL_H
+
+#ifndef CLOOG_INT_GMP
+#define CLOOG_INT_GMP
+#endif
+
+#include <cloog/cloog.h>
+#include <cloog/isl/constraintset.h>
+#include <cloog/isl/domain.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif 
+
+CloogState *cloog_isl_state_malloc(struct isl_ctx *ctx);
+
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif /* define _H */
diff --git a/include/cloog/isl/constraintset.h b/include/cloog/isl/constraintset.h
new file mode 100644
index 0000000..c3c2eed
--- /dev/null
+++ b/include/cloog/isl/constraintset.h
@@ -0,0 +1,33 @@
+#ifndef CLOOG_ISL_CONSTRAINTSET_H
+#define CLOOG_ISL_CONSTRAINTSET_H
+
+#include <cloog/isl/backend.h>
+
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+struct cloogconstraintset {
+	int dummy;	/* Solaris cc doesn't like zero-sized structs */
+};
+
+struct cloogequalities {
+	int			  n;
+	unsigned		  total_dim;
+	isl_constraint		**constraints;
+	int			 *types;
+};
+
+struct cloogconstraint {
+	int dummy;	/* Solaris cc doesn't like zero-sized structs */
+};
+
+CloogConstraintSet *cloog_constraint_set_from_isl_basic_set(struct isl_basic_set *bset);
+CloogConstraint *cloog_constraint_from_isl_constraint(struct isl_constraint *constraint);
+isl_constraint *cloog_constraint_to_isl(CloogConstraint *constraint);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/isl/domain.h b/include/cloog/isl/domain.h
new file mode 100644
index 0000000..35b47f2
--- /dev/null
+++ b/include/cloog/isl/domain.h
@@ -0,0 +1,36 @@
+#ifndef CLOOG_ISL_DOMAIN_H
+#define CLOOG_ISL_DOMAIN_H
+
+#include <isl/map.h>
+#include <isl/set.h>
+#include <isl/union_map.h>
+#include <isl/union_set.h>
+
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+struct cloogdomain {
+	int dummy;	/* Solaris cc doesn't like zero-sized structs */
+};
+
+struct cloogscattering {
+	int dummy;	/* Solaris cc doesn't like zero-sized structs */
+};
+
+CloogDomain *cloog_domain_from_isl_set(__isl_take isl_set *set);
+CloogScattering *cloog_scattering_from_isl_map(__isl_take isl_map *map);
+CloogUnionDomain *cloog_union_domain_from_isl_union_map(
+	__isl_take isl_union_map *umap);
+CloogUnionDomain *cloog_union_domain_from_isl_set(
+	__isl_take isl_set *set);
+
+__isl_give isl_set *isl_set_from_cloog_domain(CloogDomain *domain);
+
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/loop.h b/include/cloog/loop.h
new file mode 100644
index 0000000..b62a274
--- /dev/null
+++ b/include/cloog/loop.h
@@ -0,0 +1,120 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                             loop.h                                **
+    **-------------------------------------------------------------------**
+    **                 First version: october 26th 2001                  **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_LOOP_H
+#define CLOOG_LOOP_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+/**
+ * CloogLoop structure:
+ * this structure contains all the informations of a loop generated or to be
+ * generated.
+ * - if the loop has not been processed yet (it is not a result of a call to
+ *   cloog_loop_generate), the domain is the whole iteration domain of a given
+ *   block, the stride is 1 (i.e. there is no stride), block is necessarily not
+ *   NULL and inner is NULL.
+ * - if the loop comes as a result of a cloog_loop_generate call, the domain
+ *   describes the constraints (guards and loop bounds) for only one dimension
+ *   (the last one: outer dimensions being considered as parameters), the stride
+ *   may differ from one (this means that on the considered dimension, a step of
+ *   'stride' must be considered between integral point, the first integral
+ *   point to be considered being the lower bound of the loop), inner may differ
+ *   from NULL, meaning that there are further dimensions and nesting levels in
+ *   the loop.
+ */
+struct cloogloop
+{
+  CloogState *state;          /**< State. */
+  CloogDomain * domain ;      /**< The iteration domain. */
+  CloogDomain *unsimplified;  /**< Unsimplified version of domain. */
+  int otl;                    /**< Loop is executed at most once. */
+  CloogStride *stride;        /**< If not NULL, stride information on iterator
+                               *   (filled only after loop generation).
+                               */
+  CloogBlock * block ;        /**< The included statement block, NULL if none.*/
+  void * usr;		      /**< User field, for library user convenience.
+			       *   This pointer is not freed when the
+			       *   CloogLoop structure is freed.
+			       */
+  struct cloogloop * inner ;  /**< Loops at the next level. */
+  struct cloogloop * next ;   /**< Next loop at the same level. */
+} ;
+typedef struct cloogloop CloogLoop ;
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_loop_print_structure(FILE *, CloogLoop *, int) ;
+void cloog_loop_print(FILE *, CloogLoop *) ;
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_loop_free(CloogLoop *) ;
+
+
+/******************************************************************************
+ *                              Reading functions                             *
+ ******************************************************************************/
+CloogLoop *cloog_loop_from_domain(CloogState *state, CloogDomain *domain,
+				  int number);
+CloogLoop * cloog_loop_read(CloogState *state,
+			    FILE * foo, int number, int nb_parameters);
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogLoop * cloog_loop_block(CloogLoop *loop, int *scaldims, int nb_scattdims);
+CloogLoop * cloog_loop_malloc(CloogState *state);
+CloogLoop *cloog_loop_generate(CloogLoop *loop, CloogDomain *context,
+	int level, int scalar, int *scaldims, int nb_scattdims,
+	CloogOptions *options);
+CloogLoop *cloog_loop_simplify(CloogLoop *loop, CloogDomain *context, int level,
+	int nb_scattdims, CloogOptions *options);
+void cloog_loop_scatter(CloogLoop *, CloogScattering *);
+
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/matrix.h b/include/cloog/matrix.h
new file mode 100644
index 0000000..2b73039
--- /dev/null
+++ b/include/cloog/matrix.h
@@ -0,0 +1,59 @@
+#ifndef CLOOG_MATRIX_H
+#define CLOOG_MATRIX_H
+#if defined(__cplusplus)
+extern "C"
+  {
+#endif
+
+/* The CloogMatrix structure is equivalent to the PolyLib Matrix data structure
+ * (see Wil93). This structure is devoted to represent a set of constraints.
+ *
+ * The whole matrix is stored in memory row after row at the p_Init address. p
+ * is an array of pointers where p[i] points to the first element of the i^{th
+ * row. NbRows and NbColumns are respectively the number of rows and columns of
+ * the matrix. Each row corresponds to a constraint. The first element of each
+ * row is an equality/inequality tag. The constraint is an equality p(x) = 0 if
+ * the first element is 0, but it is an inequality p(x) \geq 0 if the first
+ * element is 1. The next elements are the unknown coefficients, followed by
+ * the parameter coefficients, then the constant term. For instance, the
+ * following three constraints:
+ *
+ *     -i + m  = 0
+ *     -j + n >= 0
+ *  i + j - k >= 0
+ *
+ * would be represented by the following rows:
+ *
+ * # eq/in  i   j   k   m   n   cst
+ *     0    0  -1   0   1   0    0
+ *     1   -1   0   0   0   1    0
+ *     1    1   1  -1   0   0    0
+ *
+ * To be able to provide different precision version (CLooG supports 32 bits,
+ * 64 bits and arbitrary precision through the GMP library), the cloog_int_t
+ * type depends on the configuration options (it may be long int for 32 bits
+ * version, long long int for 64 bits version, and mpz_t for multiple precision
+ * version). */
+
+struct cloogmatrix
+{ unsigned NbRows;    /* Number of rows. */
+  unsigned NbColumns; /* Number of columns. */
+  cloog_int_t ** p;         /* Array of pointers to the matrix rows. */
+  cloog_int_t * p_Init;     /* Matrix rows contiguously in memory. */
+};
+
+typedef struct cloogmatrix CloogMatrix;
+
+CloogMatrix *cloog_matrix_alloc (unsigned, unsigned);
+void cloog_matrix_free (CloogMatrix *);
+void cloog_matrix_print_structure(FILE *file, CloogMatrix *M,
+		const char *prefix, const char *suffix);
+CloogMatrix *cloog_matrix_read(FILE *input);
+CloogMatrix *cloog_matrix_read_of_size(FILE *input,
+		unsigned n_row, unsigned n_col);
+void cloog_matrix_print(FILE*, CloogMatrix*);
+
+#if defined(__cplusplus)
+  }
+#endif
+#endif /* define _H */
diff --git a/include/cloog/matrix/constraintset.h b/include/cloog/matrix/constraintset.h
new file mode 100644
index 0000000..5023162
--- /dev/null
+++ b/include/cloog/matrix/constraintset.h
@@ -0,0 +1,28 @@
+#ifndef CLOOG_MATRIX_CONSTRAINTSET_H
+#define CLOOG_MATRIX_CONSTRAINTSET_H
+
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+struct cloogconstraintset {
+	CloogMatrix M;
+};
+
+struct cloogequalities {
+	CloogConstraintSet	*constraints;
+	int			*types;
+};
+
+struct cloogconstraint {
+	CloogConstraintSet	*set;
+	cloog_int_t		**line;
+};
+
+CloogConstraintSet *cloog_constraint_set_from_cloog_matrix(CloogMatrix *M);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/names.h b/include/cloog/names.h
new file mode 100644
index 0000000..7f566f1
--- /dev/null
+++ b/include/cloog/names.h
@@ -0,0 +1,103 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                             names.h                               **
+    **-------------------------------------------------------------------**
+    **                  First version: august 1st 2002                   **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_NAMES_H
+#define CLOOG_NAMES_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+# define MAX_NAME 50
+# define FIRST_PARAMETER 'M'
+# define FIRST_ITERATOR  'i'
+
+
+/**
+ * CloogNames structure:
+ * this structure contains all the informations about parameter and iterator
+ * names (as strings).
+ */
+struct cloognames
+{ int nb_scalars ;         /**< Scalar dimension number. */
+  int nb_scattering ;      /**< Scattering iterator number. */
+  int nb_iterators ;       /**< Iterator number. */
+  int nb_parameters ;      /**< Parameter number. */
+  char ** scalars ;        /**< The scalar names     (an array of strings). */
+  char ** scattering ;     /**< The scattering names (an array of strings). */
+  char ** iterators ;      /**< The iterator names   (an array of strings). */
+  char ** parameters ;     /**< The parameter names  (an array of strings). */
+  int references;          /**< Number of references to this structure. */
+} ;
+typedef struct cloognames CloogNames ;
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_names_print_structure(FILE *, CloogNames *, int) ;
+void cloog_names_print(FILE *, CloogNames *) ;
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_names_free(CloogNames *) ;
+
+
+/******************************************************************************
+ *                              Reading functions                             *
+ ******************************************************************************/
+char ** cloog_names_read_strings(FILE *file, int nb_items);
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogNames * cloog_names_malloc(void);
+CloogNames * cloog_names_copy(CloogNames *names);
+CloogNames * cloog_names_alloc(void);
+char ** cloog_names_generate_items(int, char *, char) ;
+CloogNames * cloog_names_generate(int, int, int, int, char, char, char, char) ;
+void cloog_names_scalarize(CloogNames *, int, int *) ;
+const char * cloog_names_name_at_level(CloogNames *names, int level);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/options.h b/include/cloog/options.h
new file mode 100644
index 0000000..f4dd70e
--- /dev/null
+++ b/include/cloog/options.h
@@ -0,0 +1,169 @@
+
+   /**-------------------------------------------------------------------**
+    **                               CLooG                               **
+    **-------------------------------------------------------------------**
+    **                             options.h                             **
+    **-------------------------------------------------------------------**
+    **                  First version: april 19th 2003                   **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+#include <stdio.h>
+
+#ifndef CLOOG_OPTIONS_H
+#define CLOOG_OPTIONS_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+/* Uncomment the following line if you want some information about
+ * maximum total allocated memory for code generation.
+#define CLOOG_MEMORY 
+ */
+#define CLOOG_SCALARS
+
+struct osl_scop;
+
+struct cloogoptions;
+typedef struct cloogoptions CloogOptions;
+struct osl_scop;
+
+struct cloogoptions
+{
+  CloogState *state; /* State. */
+  /* OPTIONS FOR LOOP GENERATION */
+  int l ;           /* Last level to optimize. */
+  int f ;           /* First level to optimize. */
+
+  int *ls;         /* Last level to optimize (statement-wise). */
+  int *fs;         /* First level to optimize (statement-wise). */
+  int fs_ls_size;  /* Size of the fs and ls arrays (same size) */
+  int stop ;        /* Level to stop code generation. */
+  int strides ;     /* 1 if user wants to handle non-unit strides (then loop
+                     * increment can be something else than one), 0 otherwise.
+                     */
+  int sh;	    /* 1 for computing simple hulls */
+  int first_unroll; /* The first dimension to unroll */
+
+  /* OPTIONS FOR PRETTY PRINTING */
+  int esp ;       /* 1 if user wants to spread all equalities, i.e. when there
+                   * is something like "i = 3*j + 1 ; A[i] = 0 ;" the generator
+                   * will write "A[3*j + 1] = 0 ;", 0 otherwise.
+                   */
+  int fsp ;       /* The iteration level where equalities spreading can begin
+                   * (it might happen that the user wants not to spread values
+                   * of scattering iterators).
+                   */
+  int otl ;       /* 1 for eliminate loops running just one time and write them
+                   * as an affectation of the iterator, 0 otherwise.
+                   */
+  int block ;     /* 1 to make one new block {...} per new dimension,
+                   * 0 otherwise.
+                   */
+  int compilable; /* 1 to generate a compilable code by using
+                   * preprocessing, 0 otherwise.
+                   */
+  int callable;   /* 1 to generate callable code by using
+                   * preprocessing, 0 otherwise.
+                   */
+  int language;   /* 1 to generate FORTRAN, 0 for C otherwise. */
+
+  int save_domains;/* Save unsimplified copy of domain. */
+
+  /* MISC OPTIONS */
+  char * name ;   /* Name of the input file. */
+  float time ;    /* Time spent for code generation in seconds. */
+  int openscop;   /* 1 if the input file has OpenScop format, 0 otherwise. */
+  struct osl_scop *scop; /* Input OpenScop scop if any, NULL otherwise. */
+#ifdef CLOOG_MEMORY
+  int memory ;    /* Memory spent for code generation in kilobytes. */
+#endif
+  int quiet;      /* Don't print any informational messages. */
+  /* UNDOCUMENTED OPTIONS FOR THE AUTHOR ONLY */
+  int leaks ;     /* 1 if I want to print the allocation statistics,
+                   * 0 otherwise.
+		   */
+  int backtrack;  /* 1 to perform backtracking in 
+                   * Quillere's algorithm, 0 otherwise.
+		   */
+  int override ;  /* 1 if I want to bypass CLooG decisions on option correctness
+                   * (generated code may be incorrect), 0 otherwise.
+		   */
+  int structure ; /* 1 if I want to print the CloogProgram structure before the
+                   * pretty printed code, 0 otherwise.
+		   */
+  int noblocks ;  /* 1 if I don't want to make statement blocks, 0 otherwise. */
+  int noscalars ; /* 1 if I don't want to use scalar dimensions, 0 otherwise. */
+  int nosimplify; /* 1 if I don't want to simplify polyhedra, 0 otherwise. */
+} ;
+
+
+/******************************************************************************
+ *                          Error reporting functions                         *
+ ******************************************************************************/
+
+enum cloog_msg_type { CLOOG_ERROR, CLOOG_WARNING, CLOOG_INFO };
+
+void cloog_msg(CloogOptions *options, enum cloog_msg_type type,
+		const char *msg, ...);
+void cloog_die(const char *msg, ...);
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_options_print(FILE *, CloogOptions *) ;
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_options_free(CloogOptions *) ;
+
+
+/******************************************************************************
+ *                               Reading function                             *
+ ******************************************************************************/
+void cloog_options_read(CloogState *state, int argc, char **argv,
+			FILE **input, FILE **output, CloogOptions **options);
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogOptions *cloog_options_malloc(CloogState *state);
+void cloog_options_copy_from_osl_scop(struct osl_scop *, CloogOptions *);
+
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/pprint.h b/include/cloog/pprint.h
new file mode 100644
index 0000000..55e2b5e
--- /dev/null
+++ b/include/cloog/pprint.h
@@ -0,0 +1,67 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                             pprint.h                              **
+    **-------------------------------------------------------------------**
+    **                 First version: october 26th 2001                  **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_PPRINT_H
+#define CLOOG_PPRINT_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+# define MAX_STRING_VAL 32
+# define INDENT_STEP 2
+
+# define EQTYPE_NONE	 0
+# define EQTYPE_CONSTANT 1
+# define EQTYPE_PUREITEM 2
+# define EQTYPE_EXAFFINE 3
+
+#define CLOOG_LANGUAGE_C 0
+#define CLOOG_LANGUAGE_FORTRAN 1
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void clast_pprint(FILE *foo, struct clast_stmt *root, int indent, 
+	    CloogOptions *options);
+
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/cloog/program.h b/include/cloog/program.h
new file mode 100644
index 0000000..530d21f
--- /dev/null
+++ b/include/cloog/program.h
@@ -0,0 +1,116 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                            program.h                              **
+    **-------------------------------------------------------------------**
+    **                 First version: october 25th 2001                  **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_PROGRAM_H
+#define CLOOG_PROGRAM_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+# define MAX_STRING 1024
+# define MEGA 1000000  /* One million. */
+
+
+/**
+ * CloogProgram structure:
+ * this structure contains all the informations of a program generated or to be
+ * generated.
+ */
+struct cloogprogram
+{ /* Basic program description fields. */
+  char language ;              /**< The language of the program. */
+  int  nb_scattdims ;          /**< Scattering dimension number. */
+  CloogDomain    * context ;   /**< The context of the program. */
+  CloogLoop      * loop ;      /**< The loops of the program. */
+  CloogNames     * names ;     /**< Iterators and parameters names. */
+  CloogBlockList * blocklist ; /**< The statement block list. */
+  
+  /* Internal service fields, filled up by cloog_program_scatter function. */
+  int * scaldims ;             /**< Boolean array saying whether a given
+                                *   scattering dimension is scalar or not.
+				*/
+  /* Library user reserved field. */
+  void * usr;		       /**< User field, for library user convenience.
+			        *   This pointer is not freed when the
+			        *   CloogProgram structure is freed.
+			        */
+} ;
+typedef struct cloogprogram CloogProgram ;
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_program_print_structure(FILE *, CloogProgram *, int) ;
+void cloog_program_print(FILE *, CloogProgram *) ;
+void cloog_program_pprint(FILE *, CloogProgram *, CloogOptions *) ;
+void cloog_program_dump_cloog(FILE *, CloogProgram *, CloogScatteringList *);
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_program_free(CloogProgram *) ;
+
+
+/******************************************************************************
+ *                               Reading function                             *
+ ******************************************************************************/
+CloogProgram * cloog_program_read(FILE *, CloogOptions *) ;
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogProgram * cloog_program_malloc(void);
+CloogProgram * cloog_program_alloc(CloogDomain *context, CloogUnionDomain *ud,
+	CloogOptions *options);
+CloogProgram * cloog_program_generate(CloogProgram *, CloogOptions *) ;
+void cloog_program_block(CloogProgram *program,
+	CloogScatteringList *scattering, CloogOptions *options);
+void cloog_program_extract_scalars(CloogProgram *program,
+	CloogScatteringList *scattering, CloogOptions *options);
+void cloog_program_scatter(CloogProgram *program,
+			CloogScatteringList *scattering, CloogOptions *options);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
+
diff --git a/include/cloog/state.h b/include/cloog/state.h
new file mode 100644
index 0000000..ebc3272
--- /dev/null
+++ b/include/cloog/state.h
@@ -0,0 +1,46 @@
+#ifndef CLOOG_STATE_H
+#define CLOOG_STATE_H
+
+struct cloogbackend;
+typedef struct cloogbackend CloogBackend;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif 
+
+struct cloogstate {
+  CloogBackend *backend;
+
+  cloog_int_t zero;
+  cloog_int_t one;
+  cloog_int_t negone;
+
+  int block_allocated;
+  int block_freed;
+  int block_max;
+
+  int domain_allocated;
+  int domain_freed;
+  int domain_max;
+
+  int loop_allocated;
+  int loop_freed;
+  int loop_max;
+
+  int statement_allocated;
+  int statement_freed;
+  int statement_max;
+};
+typedef struct cloogstate CloogState;
+
+CloogState *cloog_core_state_malloc(void);
+CloogState *cloog_state_malloc(void);
+
+void cloog_core_state_free(CloogState *state);
+void cloog_state_free(CloogState *state);
+
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif
diff --git a/include/cloog/statement.h b/include/cloog/statement.h
new file mode 100644
index 0000000..abc505e
--- /dev/null
+++ b/include/cloog/statement.h
@@ -0,0 +1,85 @@
+
+   /**-------------------------------------------------------------------**
+    **                              CLooG                                **
+    **-------------------------------------------------------------------**
+    **                           statement.h                             **
+    **-------------------------------------------------------------------**
+    **                  First version: november 4th 2001                 **
+    **-------------------------------------------------------------------**/
+
+
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_STATEMENT_H
+#define CLOOG_STATEMENT_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+
+struct cloogstatement
+{
+  CloogState *state;             /* State. */
+  char *name;			 /* Name of the statement. */
+  int number;                    /* The statement unique number. */
+  void * usr ;                   /* A pointer for library users convenience. */
+  struct cloogstatement * next ; /* Pointer to the next statement with the
+                                  * same original domain and the same
+				  * scattering function.
+				  */
+} ;
+typedef struct cloogstatement CloogStatement ;
+
+
+/******************************************************************************
+ *                          Structure display function                        *
+ ******************************************************************************/
+void cloog_statement_print_structure(FILE *, CloogStatement *, int) ;
+void cloog_statement_print(FILE *, CloogStatement *) ;
+
+
+/******************************************************************************
+ *                         Memory deallocation function                       *
+ ******************************************************************************/
+void cloog_statement_free(CloogStatement *) ;
+
+
+/******************************************************************************
+ *                            Processing functions                            *
+ ******************************************************************************/
+CloogStatement * cloog_statement_malloc(CloogState *state);
+CloogStatement * cloog_statement_alloc(CloogState *state, int);
+CloogStatement * cloog_statement_copy(CloogStatement *) ;
+void cloog_statement_add(CloogStatement**, CloogStatement**, CloogStatement*) ;
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
+
diff --git a/include/cloog/stride.h b/include/cloog/stride.h
new file mode 100644
index 0000000..f93dc4e
--- /dev/null
+++ b/include/cloog/stride.h
@@ -0,0 +1,33 @@
+#ifndef CLOOG_STRIDE_H
+#define CLOOG_STRIDE_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif 
+
+/**
+ * Information about strides.
+ */
+struct cloogstride {
+  int references;
+  cloog_int_t stride;         /**< The actual stride. */
+  cloog_int_t offset;         /**< Offset of strided loop. */
+  cloog_int_t factor;
+  CloogConstraint *constraint;
+};
+typedef struct cloogstride CloogStride;
+
+CloogStride *cloog_stride_alloc(cloog_int_t stride, cloog_int_t offset);
+CloogStride *cloog_stride_alloc_from_constraint(cloog_int_t stride,
+	CloogConstraint *constraint, cloog_int_t factor);
+CloogStride *cloog_stride_copy(CloogStride *stride);
+void cloog_stride_free(CloogStride *stride);
+
+CloogConstraint *cloog_constraint_stride_lower_bound(CloogConstraint *c,
+	int level, CloogStride *stride);
+
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif
diff --git a/include/cloog/union_domain.h b/include/cloog/union_domain.h
new file mode 100644
index 0000000..5c6ff86
--- /dev/null
+++ b/include/cloog/union_domain.h
@@ -0,0 +1,52 @@
+#ifndef CLOOG_UNION_DOMAIN_H
+#define CLOOG_UNION_DOMAIN_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif 
+
+struct osl_scop;
+
+/**
+ * CloogNamedDomainList structure:
+ * this structure reprensents a node of a linked list of CloogDomain structures.
+ */
+struct cloognameddomainlist {
+  CloogDomain *domain;              /**< An element of the list. */
+  CloogScattering *scattering;      /**< Scattering function for domain. */
+  char *name;                       /**< Name of the domain. */
+  void *usr;                        /**< A pointer for library user's convenience. */
+  struct cloognameddomainlist *next;/**< Pointer to the next element of the list.*/
+};
+typedef struct cloognameddomainlist CloogNamedDomainList;
+
+/**
+ * A structure representing the input domains and scattering functions.
+ */
+struct clooguniondomain {
+	int n_name[3];
+	char **name[3];
+	CloogNamedDomainList *domain;
+	CloogNamedDomainList **next_domain;
+};
+typedef struct clooguniondomain CloogUnionDomain;
+
+enum cloog_dim_type { CLOOG_PARAM, CLOOG_ITER, CLOOG_SCAT };
+
+CloogUnionDomain *cloog_union_domain_read(FILE *file, int nb_par,
+	CloogOptions *options);
+CloogUnionDomain *cloog_union_domain_alloc(int nb_par);
+CloogUnionDomain *cloog_union_domain_add_domain(CloogUnionDomain *ud,
+	const char *name, CloogDomain *domain, CloogScattering *scattering,
+	void *usr);
+CloogUnionDomain *cloog_union_domain_set_name(CloogUnionDomain *ud,
+	enum cloog_dim_type type, int index, const char *name);
+void cloog_union_domain_free(CloogUnionDomain *ud);
+CloogUnionDomain *cloog_union_domain_from_osl_scop(CloogState *,
+                                                   struct osl_scop *);
+
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif
diff --git a/include/cloog/version.h b/include/cloog/version.h
new file mode 100644
index 0000000..e24356c
--- /dev/null
+++ b/include/cloog/version.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+ *               CLooG : the Chunky Loop Generator (experimental)             *
+ ******************************************************************************
+ *                                                                            *
+ * Copyright (C) 2001-2005 Cedric Bastoul                                     *
+ *                                                                            *
+ * This library is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU Lesser General Public                 *
+ * License as published by the Free Software Foundation; either               *
+ * version 2.1 of the License, or (at your option) any later version.         *
+ *                                                                            *
+ * This library is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this library; if not, write to the Free Software        *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
+ * Boston, MA  02110-1301  USA                                                *
+ *                                                                            *
+ * CLooG, the Chunky Loop Generator                                           *
+ * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
+ *                                                                            *
+ ******************************************************************************/
+
+
+#ifndef CLOOG_VERSION_H
+#define CLOOG_VERSION_H
+#if defined(__cplusplus)
+extern "C" 
+  {
+#endif 
+
+#define CLOOG_VERSION_MAJOR 0
+#define CLOOG_VERSION_MINOR 18
+#define CLOOG_VERSION_REVISION 0
+
+const char *cloog_version(void);
+
+int cloog_version_major(void);
+
+int cloog_version_minor(void);
+
+int cloog_version_revision(void);
+
+#if defined(__cplusplus)
+  }
+#endif 
+#endif /* define _H */
diff --git a/include/gmp.h b/include/gmp.h
new file mode 100644
index 0000000..a94cd82
--- /dev/null
+++ b/include/gmp.h
@@ -0,0 +1,2279 @@
+/* Definitions for GNU multiple precision functions.   -*- mode: c -*-
+
+Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
+2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
+Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
+
+#ifndef __GMP_H__
+
+#if defined (__cplusplus)
+#include <iosfwd>   /* for std::istream, std::ostream, std::string */
+#include <cstdio>
+#endif
+
+
+/* Instantiated by configure. */
+#if ! defined (__GMP_WITHIN_CONFIGURE)
+#define __GMP_HAVE_HOST_CPU_FAMILY_power   0
+#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0
+#define GMP_LIMB_BITS                      64
+#define GMP_NAIL_BITS                      0
+#endif
+#define GMP_NUMB_BITS     (GMP_LIMB_BITS - GMP_NAIL_BITS)
+#define GMP_NUMB_MASK     ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)
+#define GMP_NUMB_MAX      GMP_NUMB_MASK
+#define GMP_NAIL_MASK     (~ GMP_NUMB_MASK)
+
+
+/* The following (everything under ifndef __GNU_MP__) must be identical in
+   gmp.h and mp.h to allow both to be included in an application or during
+   the library build.  */
+#ifndef __GNU_MP__
+#define __GNU_MP__ 5
+
+#define __need_size_t  /* tell gcc stddef.h we only want size_t */
+#if defined (__cplusplus)
+#include <cstddef>     /* for size_t */
+#else
+#include <stddef.h>    /* for size_t */
+#endif
+#undef __need_size_t
+
+/* Instantiated by configure. */
+#if ! defined (__GMP_WITHIN_CONFIGURE)
+/* #undef _LONG_LONG_LIMB */
+#define __GMP_LIBGMP_DLL  0
+#endif
+
+
+/* __STDC__ - some ANSI compilers define this only to 0, hence the use of
+       "defined" and not "__STDC__-0".  In particular Sun workshop C 5.0
+       sets __STDC__ to 0, but requires "##" for token pasting.
+
+   _AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but
+       don't always define __STDC__.
+
+   __DECC - current versions of DEC C (5.9 for instance) for alpha are ANSI,
+       but don't define __STDC__ in their default mode.  Don't know if old
+       versions might have been K&R, but let's not worry about that unless
+       someone is still using one.
+
+   _mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR4
+       mode, but doesn't define __STDC__.
+
+   _MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za
+       option is given (in which case it's 1).
+
+   _WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that
+      all w32 compilers are ansi.
+
+   Note: This same set of tests is used by gen-psqr.c and
+   demos/expr/expr-impl.h, so if anything needs adding, then be sure to
+   update those too.  */
+
+#if  defined (__STDC__)                                 \
+  || defined (__cplusplus)                              \
+  || defined (_AIX)                                     \
+  || defined (__DECC)                                   \
+  || (defined (__mips) && defined (_SYSTYPE_SVR4))      \
+  || defined (_MSC_VER)                                 \
+  || defined (_WIN32)
+#define __GMP_HAVE_CONST        1
+#define __GMP_HAVE_PROTOTYPES   1
+#define __GMP_HAVE_TOKEN_PASTE  1
+#else
+#define __GMP_HAVE_CONST        0
+#define __GMP_HAVE_PROTOTYPES   0
+#define __GMP_HAVE_TOKEN_PASTE  0
+#endif
+
+
+#if __GMP_HAVE_CONST
+#define __gmp_const   const
+#define __gmp_signed  signed
+#else
+#define __gmp_const
+#define __gmp_signed
+#endif
+
+
+/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in
+   all other circumstances.
+
+   When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,
+   or when compiling for an application it's an import directive.  The two
+   cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles
+   (and not defined from an application).
+
+   __GMP_DECLSPEC_XX is similarly used for libgmpxx.  __GMP_WITHIN_GMPXX
+   indicates when building libgmpxx, and in that case libgmpxx functions are
+   exports, but libgmp functions which might get called are imports.
+
+   Libtool DLL_EXPORT define is not used.
+
+   There's no attempt to support GMP built both static and DLL.  Doing so
+   would mean applications would have to tell us which of the two is going
+   to be used when linking, and that seems very tedious and error prone if
+   using GMP by hand, and equally tedious from a package since autoconf and
+   automake don't give much help.
+
+   __GMP_DECLSPEC is required on all documented global functions and
+   variables, the various internals in gmp-impl.h etc can be left unadorned.
+   But internals used by the test programs or speed measuring programs
+   should have __GMP_DECLSPEC, and certainly constants or variables must
+   have it or the wrong address will be resolved.
+
+   In gcc __declspec can go at either the start or end of a prototype.
+
+   In Microsoft C __declspec must go at the start, or after the type like
+   void __declspec(...) *foo()".  There's no __dllexport or anything to
+   guard against someone foolish #defining dllexport.  _export used to be
+   available, but no longer.
+
+   In Borland C _export still exists, but needs to go after the type, like
+   "void _export foo();".  Would have to change the __GMP_DECLSPEC syntax to
+   make use of that.  Probably more trouble than it's worth.  */
+
+#if defined (__GNUC__)
+#define __GMP_DECLSPEC_EXPORT  __declspec(__dllexport__)
+#define __GMP_DECLSPEC_IMPORT  __declspec(__dllimport__)
+#endif
+#if defined (_MSC_VER) || defined (__BORLANDC__)
+#define __GMP_DECLSPEC_EXPORT  __declspec(dllexport)
+#define __GMP_DECLSPEC_IMPORT  __declspec(dllimport)
+#endif
+#ifdef __WATCOMC__
+#define __GMP_DECLSPEC_EXPORT  __export
+#define __GMP_DECLSPEC_IMPORT  __import
+#endif
+#ifdef __IBMC__
+#define __GMP_DECLSPEC_EXPORT  _Export
+#define __GMP_DECLSPEC_IMPORT  _Import
+#endif
+
+#if __GMP_LIBGMP_DLL
+#if __GMP_WITHIN_GMP
+/* compiling to go into a DLL libgmp */
+#define __GMP_DECLSPEC  __GMP_DECLSPEC_EXPORT
+#else
+/* compiling to go into an application which will link to a DLL libgmp */
+#define __GMP_DECLSPEC  __GMP_DECLSPEC_IMPORT
+#endif
+#else
+/* all other cases */
+#define __GMP_DECLSPEC
+#endif
+
+
+#ifdef __GMP_SHORT_LIMB
+typedef unsigned int		mp_limb_t;
+typedef int			mp_limb_signed_t;
+#else
+#ifdef _LONG_LONG_LIMB
+typedef unsigned long long int	mp_limb_t;
+typedef long long int		mp_limb_signed_t;
+#else
+typedef unsigned long int	mp_limb_t;
+typedef long int		mp_limb_signed_t;
+#endif
+#endif
+typedef unsigned long int	mp_bitcnt_t;
+
+/* For reference, note that the name __mpz_struct gets into C++ mangled
+   function names, which means although the "__" suggests an internal, we
+   must leave this name for binary compatibility.  */
+typedef struct
+{
+  int _mp_alloc;		/* Number of *limbs* allocated and pointed
+				   to by the _mp_d field.  */
+  int _mp_size;			/* abs(_mp_size) is the number of limbs the
+				   last field points to.  If _mp_size is
+				   negative this is a negative number.  */
+  mp_limb_t *_mp_d;		/* Pointer to the limbs.  */
+} __mpz_struct;
+
+#endif /* __GNU_MP__ */
+
+
+typedef __mpz_struct MP_INT;    /* gmp 1 source compatibility */
+typedef __mpz_struct mpz_t[1];
+
+typedef mp_limb_t *		mp_ptr;
+typedef __gmp_const mp_limb_t *	mp_srcptr;
+#if defined (_CRAY) && ! defined (_CRAYMPP)
+/* plain `int' is much faster (48 bits) */
+#define __GMP_MP_SIZE_T_INT     1
+typedef int			mp_size_t;
+typedef int			mp_exp_t;
+#else
+#define __GMP_MP_SIZE_T_INT     0
+typedef long int		mp_size_t;
+typedef long int		mp_exp_t;
+#endif
+
+typedef struct
+{
+  __mpz_struct _mp_num;
+  __mpz_struct _mp_den;
+} __mpq_struct;
+
+typedef __mpq_struct MP_RAT;    /* gmp 1 source compatibility */
+typedef __mpq_struct mpq_t[1];
+
+typedef struct
+{
+  int _mp_prec;			/* Max precision, in number of `mp_limb_t's.
+				   Set by mpf_init and modified by
+				   mpf_set_prec.  The area pointed to by the
+				   _mp_d field contains `prec' + 1 limbs.  */
+  int _mp_size;			/* abs(_mp_size) is the number of limbs the
+				   last field points to.  If _mp_size is
+				   negative this is a negative number.  */
+  mp_exp_t _mp_exp;		/* Exponent, in the base of `mp_limb_t'.  */
+  mp_limb_t *_mp_d;		/* Pointer to the limbs.  */
+} __mpf_struct;
+
+/* typedef __mpf_struct MP_FLOAT; */
+typedef __mpf_struct mpf_t[1];
+
+/* Available random number generation algorithms.  */
+typedef enum
+{
+  GMP_RAND_ALG_DEFAULT = 0,
+  GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential.  */
+} gmp_randalg_t;
+
+/* Random state struct.  */
+typedef struct
+{
+  mpz_t _mp_seed;	  /* _mp_d member points to state of the generator. */
+  gmp_randalg_t _mp_alg;  /* Currently unused. */
+  union {
+    void *_mp_lc;         /* Pointer to function pointers structure.  */
+  } _mp_algdata;
+} __gmp_randstate_struct;
+typedef __gmp_randstate_struct gmp_randstate_t[1];
+
+/* Types for function declarations in gmp files.  */
+/* ??? Should not pollute user name space with these ??? */
+typedef __gmp_const __mpz_struct *mpz_srcptr;
+typedef __mpz_struct *mpz_ptr;
+typedef __gmp_const __mpf_struct *mpf_srcptr;
+typedef __mpf_struct *mpf_ptr;
+typedef __gmp_const __mpq_struct *mpq_srcptr;
+typedef __mpq_struct *mpq_ptr;
+
+
+/* This is not wanted in mp.h, so put it outside the __GNU_MP__ common
+   section. */
+#if __GMP_LIBGMP_DLL
+#if __GMP_WITHIN_GMPXX
+/* compiling to go into a DLL libgmpxx */
+#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_EXPORT
+#else
+/* compiling to go into a application which will link to a DLL libgmpxx */
+#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_IMPORT
+#endif
+#else
+/* all other cases */
+#define __GMP_DECLSPEC_XX
+#endif
+
+
+#if __GMP_HAVE_PROTOTYPES
+#define __GMP_PROTO(x) x
+#else
+#define __GMP_PROTO(x) ()
+#endif
+
+#ifndef __MPN
+#if __GMP_HAVE_TOKEN_PASTE
+#define __MPN(x) __gmpn_##x
+#else
+#define __MPN(x) __gmpn_/**/x
+#endif
+#endif
+
+/* For reference, "defined(EOF)" cannot be used here.  In g++ 2.95.4,
+   <iostream> defines EOF but not FILE.  */
+#if defined (FILE)                                              \
+  || defined (H_STDIO)                                          \
+  || defined (_H_STDIO)               /* AIX */                 \
+  || defined (_STDIO_H)               /* glibc, Sun, SCO */     \
+  || defined (_STDIO_H_)              /* BSD, OSF */            \
+  || defined (__STDIO_H)              /* Borland */             \
+  || defined (__STDIO_H__)            /* IRIX */                \
+  || defined (_STDIO_INCLUDED)        /* HPUX */                \
+  || defined (__dj_include_stdio_h_)  /* DJGPP */               \
+  || defined (_FILE_DEFINED)          /* Microsoft */           \
+  || defined (__STDIO__)              /* Apple MPW MrC */       \
+  || defined (_MSL_STDIO_H)           /* Metrowerks */          \
+  || defined (_STDIO_H_INCLUDED)      /* QNX4 */		\
+  || defined (_ISO_STDIO_ISO_H)       /* Sun C++ */		\
+  || defined (__STDIO_LOADED)         /* VMS */
+#define _GMP_H_HAVE_FILE 1
+#endif
+
+/* In ISO C, if a prototype involving "struct obstack *" is given without
+   that structure defined, then the struct is scoped down to just the
+   prototype, causing a conflict if it's subsequently defined for real.  So
+   only give prototypes if we've got obstack.h.  */
+#if defined (_OBSTACK_H)   /* glibc <obstack.h> */
+#define _GMP_H_HAVE_OBSTACK 1
+#endif
+
+/* The prototypes for gmp_vprintf etc are provided only if va_list is
+   available, via an application having included <stdarg.h> or <varargs.h>.
+   Usually va_list is a typedef so can't be tested directly, but C99
+   specifies that va_start is a macro (and it was normally a macro on past
+   systems too), so look for that.
+
+   <stdio.h> will define some sort of va_list for vprintf and vfprintf, but
+   let's not bother trying to use that since it's not standard and since
+   application uses for gmp_vprintf etc will almost certainly require the
+   whole <stdarg.h> or <varargs.h> anyway.  */
+
+#ifdef va_start
+#define _GMP_H_HAVE_VA_LIST 1
+#endif
+
+/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
+#if defined (__GNUC__) && defined (__GNUC_MINOR__)
+#define __GMP_GNUC_PREREQ(maj, min) \
+  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+#define __GMP_GNUC_PREREQ(maj, min)  0
+#endif
+
+/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes".  Basically
+   it means a function does nothing but examine its arguments and memory
+   (global or via arguments) to generate a return value, but changes nothing
+   and has no side-effects.  __GMP_NO_ATTRIBUTE_CONST_PURE lets
+   tune/common.c etc turn this off when trying to write timing loops.  */
+#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)
+#define __GMP_ATTRIBUTE_PURE   __attribute__ ((__pure__))
+#else
+#define __GMP_ATTRIBUTE_PURE
+#endif
+
+
+/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean
+   to "g++ -Wold-style-cast".
+
+   Casts in "extern inline" code within an extern "C" block don't induce
+   these warnings, so __GMP_CAST only needs to be used on documented
+   macros.  */
+
+#ifdef __cplusplus
+#define __GMP_CAST(type, expr)  (static_cast<type> (expr))
+#else
+#define __GMP_CAST(type, expr)  ((type) (expr))
+#endif
+
+
+/* An empty "throw ()" means the function doesn't throw any C++ exceptions,
+   this can save some stack frame info in applications.
+
+   Currently it's given only on functions which never divide-by-zero etc,
+   don't allocate memory, and are expected to never need to allocate memory.
+   This leaves open the possibility of a C++ throw from a future GMP
+   exceptions scheme.
+
+   mpz_set_ui etc are omitted to leave open the lazy allocation scheme
+   described in doc/tasks.html.  mpz_get_d etc are omitted to leave open
+   exceptions for float overflows.
+
+   Note that __GMP_NOTHROW must be given on any inlines the same as on their
+   prototypes (for g++ at least, where they're used together).  Note also
+   that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like
+   __GMP_ATTRIBUTE_PURE.  */
+
+#if defined (__cplusplus)
+#define __GMP_NOTHROW  throw ()
+#else
+#define __GMP_NOTHROW
+#endif
+
+
+/* PORTME: What other compilers have a useful "extern inline"?  "static
+   inline" would be an acceptable substitute if the compiler (or linker)
+   discards unused statics.  */
+
+ /* gcc has __inline__ in all modes, including strict ansi.  Give a prototype
+    for an inline too, so as to correctly specify "dllimport" on windows, in
+    case the function is called rather than inlined.
+    GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+    inline semantics, unless -fgnu89-inline is used.  */
+#ifdef __GNUC__
+#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2)
+#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))
+#else
+#define __GMP_EXTERN_INLINE      extern __inline__
+#endif
+#define __GMP_INLINE_PROTOTYPES  1
+#endif
+
+/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
+   strict ANSI mode.  Inlining is done even when not optimizing (ie. -O0
+   mode, which is the default), but an unnecessary local copy of foo is
+   emitted unless -O is used.  "extern __inline" is accepted, but the
+   "extern" appears to be ignored, ie. it becomes a plain global function
+   but which is inlined within its file.  Don't know if all old versions of
+   DEC C supported __inline, but as a start let's do the right thing for
+   current versions.  */
+#ifdef __DECC
+#define __GMP_EXTERN_INLINE  static __inline
+#endif
+
+/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict
+   ANSI mode (__STDC__ is 1 in that mode).  Inlining only actually takes
+   place under -O.  Without -O "foo" seems to be emitted whether it's used
+   or not, which is wasteful.  "extern inline foo()" isn't useful, the
+   "extern" is apparently ignored, so foo is inlined if possible but also
+   emitted as a global, which causes multiple definition errors when
+   building a shared libgmp.  */
+#ifdef __SCO_VERSION__
+#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \
+  && ! defined (__GMP_EXTERN_INLINE)
+#define __GMP_EXTERN_INLINE  static inline
+#endif
+#endif
+
+/* Microsoft's C compiler accepts __inline */
+#ifdef _MSC_VER
+#define __GMP_EXTERN_INLINE  __inline
+#endif
+
+/* Recent enough Sun C compilers want "inline" */
+#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \
+  && ! defined (__GMP_EXTERN_INLINE)
+#define __GMP_EXTERN_INLINE  inline
+#endif
+
+/* Somewhat older Sun C compilers want "static inline" */
+#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \
+  && ! defined (__GMP_EXTERN_INLINE)
+#define __GMP_EXTERN_INLINE  static inline
+#endif
+
+
+/* C++ always has "inline" and since it's a normal feature the linker should
+   discard duplicate non-inlined copies, or if it doesn't then that's a
+   problem for everyone, not just GMP.  */
+#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)
+#define __GMP_EXTERN_INLINE  inline
+#endif
+
+/* Don't do any inlining within a configure run, since if the compiler ends
+   up emitting copies of the code into the object file it can end up
+   demanding the various support routines (like mpn_popcount) for linking,
+   making the "alloca" test and perhaps others fail.  And on hppa ia64 a
+   pre-release gcc 3.2 was seen not respecting the "extern" in "extern
+   __inline__", triggering this problem too.  */
+#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE
+#undef __GMP_EXTERN_INLINE
+#endif
+
+/* By default, don't give a prototype when there's going to be an inline
+   version.  Note in particular that Cray C++ objects to the combination of
+   prototype and inline.  */
+#ifdef __GMP_EXTERN_INLINE
+#ifndef __GMP_INLINE_PROTOTYPES
+#define __GMP_INLINE_PROTOTYPES  0
+#endif
+#else
+#define __GMP_INLINE_PROTOTYPES  1
+#endif
+
+
+#define __GMP_ABS(x)   ((x) >= 0 ? (x) : -(x))
+#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))
+
+/* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted
+   to int by "~".  */
+#define __GMP_UINT_MAX   (~ (unsigned) 0)
+#define __GMP_ULONG_MAX  (~ (unsigned long) 0)
+#define __GMP_USHRT_MAX  ((unsigned short) ~0)
+
+
+/* __builtin_expect is in gcc 3.0, and not in 2.95. */
+#if __GMP_GNUC_PREREQ (3,0)
+#define __GMP_LIKELY(cond)    __builtin_expect ((cond) != 0, 1)
+#define __GMP_UNLIKELY(cond)  __builtin_expect ((cond) != 0, 0)
+#else
+#define __GMP_LIKELY(cond)    (cond)
+#define __GMP_UNLIKELY(cond)  (cond)
+#endif
+
+#ifdef _CRAY
+#define __GMP_CRAY_Pragma(str)  _Pragma (str)
+#else
+#define __GMP_CRAY_Pragma(str)
+#endif
+
+
+/* Allow direct user access to numerator and denominator of a mpq_t object.  */
+#define mpq_numref(Q) (&((Q)->_mp_num))
+#define mpq_denref(Q) (&((Q)->_mp_den))
+
+
+#if defined (__cplusplus)
+extern "C" {
+using std::FILE;
+#endif
+
+#define mp_set_memory_functions __gmp_set_memory_functions
+__GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t),
+				      void *(*) (void *, size_t, size_t),
+				      void (*) (void *, size_t))) __GMP_NOTHROW;
+
+#define mp_get_memory_functions __gmp_get_memory_functions
+__GMP_DECLSPEC void mp_get_memory_functions __GMP_PROTO ((void *(**) (size_t),
+                                      void *(**) (void *, size_t, size_t),
+                                      void (**) (void *, size_t))) __GMP_NOTHROW;
+
+#define mp_bits_per_limb __gmp_bits_per_limb
+__GMP_DECLSPEC extern __gmp_const int mp_bits_per_limb;
+
+#define gmp_errno __gmp_errno
+__GMP_DECLSPEC extern int gmp_errno;
+
+#define gmp_version __gmp_version
+__GMP_DECLSPEC extern __gmp_const char * __gmp_const gmp_version;
+
+
+/**************** Random number routines.  ****************/
+
+/* obsolete */
+#define gmp_randinit __gmp_randinit
+__GMP_DECLSPEC void gmp_randinit __GMP_PROTO ((gmp_randstate_t, gmp_randalg_t, ...));
+
+#define gmp_randinit_default __gmp_randinit_default
+__GMP_DECLSPEC void gmp_randinit_default __GMP_PROTO ((gmp_randstate_t));
+
+#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp
+__GMP_DECLSPEC void gmp_randinit_lc_2exp __GMP_PROTO ((gmp_randstate_t,
+						       mpz_srcptr, unsigned long int,
+						       mp_bitcnt_t));
+
+#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size
+__GMP_DECLSPEC int gmp_randinit_lc_2exp_size __GMP_PROTO ((gmp_randstate_t, mp_bitcnt_t));
+
+#define gmp_randinit_mt __gmp_randinit_mt
+__GMP_DECLSPEC void gmp_randinit_mt __GMP_PROTO ((gmp_randstate_t));
+
+#define gmp_randinit_set __gmp_randinit_set
+__GMP_DECLSPEC void gmp_randinit_set __GMP_PROTO ((gmp_randstate_t, __gmp_const __gmp_randstate_struct *));
+
+#define gmp_randseed __gmp_randseed
+__GMP_DECLSPEC void gmp_randseed __GMP_PROTO ((gmp_randstate_t, mpz_srcptr));
+
+#define gmp_randseed_ui __gmp_randseed_ui
+__GMP_DECLSPEC void gmp_randseed_ui __GMP_PROTO ((gmp_randstate_t, unsigned long int));
+
+#define gmp_randclear __gmp_randclear
+__GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t));
+
+#define gmp_urandomb_ui __gmp_urandomb_ui
+__GMP_DECLSPEC unsigned long gmp_urandomb_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));
+
+#define gmp_urandomm_ui __gmp_urandomm_ui
+__GMP_DECLSPEC unsigned long gmp_urandomm_ui __GMP_PROTO ((gmp_randstate_t, unsigned long));
+
+
+/**************** Formatted output routines.  ****************/
+
+#define gmp_asprintf __gmp_asprintf
+__GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, __gmp_const char *, ...));
+
+#define gmp_fprintf __gmp_fprintf
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, __gmp_const char *, ...));
+#endif
+
+#define gmp_obstack_printf __gmp_obstack_printf
+#if defined (_GMP_H_HAVE_OBSTACK)
+__GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, __gmp_const char *, ...));
+#endif
+
+#define gmp_obstack_vprintf __gmp_obstack_vprintf
+#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, __gmp_const char *, va_list));
+#endif
+
+#define gmp_printf __gmp_printf
+__GMP_DECLSPEC int gmp_printf __GMP_PROTO ((__gmp_const char *, ...));
+
+#define gmp_snprintf __gmp_snprintf
+__GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, ...));
+
+#define gmp_sprintf __gmp_sprintf
+__GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, __gmp_const char *, ...));
+
+#define gmp_vasprintf __gmp_vasprintf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, __gmp_const char *, va_list));
+#endif
+
+#define gmp_vfprintf __gmp_vfprintf
+#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));
+#endif
+
+#define gmp_vprintf __gmp_vprintf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((__gmp_const char *, va_list));
+#endif
+
+#define gmp_vsnprintf __gmp_vsnprintf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, va_list));
+#endif
+
+#define gmp_vsprintf __gmp_vsprintf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, __gmp_const char *, va_list));
+#endif
+
+
+/**************** Formatted input routines.  ****************/
+
+#define gmp_fscanf __gmp_fscanf
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, __gmp_const char *, ...));
+#endif
+
+#define gmp_scanf __gmp_scanf
+__GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((__gmp_const char *, ...));
+
+#define gmp_sscanf __gmp_sscanf
+__GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, ...));
+
+#define gmp_vfscanf __gmp_vfscanf
+#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, __gmp_const char *, va_list));
+#endif
+
+#define gmp_vscanf __gmp_vscanf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((__gmp_const char *, va_list));
+#endif
+
+#define gmp_vsscanf __gmp_vsscanf
+#if defined (_GMP_H_HAVE_VA_LIST)
+__GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, va_list));
+#endif
+
+
+/**************** Integer (i.e. Z) routines.  ****************/
+
+#define _mpz_realloc __gmpz_realloc
+#define mpz_realloc __gmpz_realloc
+__GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t));
+
+#define mpz_abs __gmpz_abs
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)
+__GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+#endif
+
+#define mpz_add __gmpz_add
+__GMP_DECLSPEC void mpz_add __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_add_ui __gmpz_add_ui
+__GMP_DECLSPEC void mpz_add_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_addmul __gmpz_addmul
+__GMP_DECLSPEC void mpz_addmul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_addmul_ui __gmpz_addmul_ui
+__GMP_DECLSPEC void mpz_addmul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_and __gmpz_and
+__GMP_DECLSPEC void mpz_and __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_array_init __gmpz_array_init
+__GMP_DECLSPEC void mpz_array_init __GMP_PROTO ((mpz_ptr, mp_size_t, mp_size_t));
+
+#define mpz_bin_ui __gmpz_bin_ui
+__GMP_DECLSPEC void mpz_bin_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_bin_uiui __gmpz_bin_uiui
+__GMP_DECLSPEC void mpz_bin_uiui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
+
+#define mpz_cdiv_q __gmpz_cdiv_q
+__GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp
+__GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui
+__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_cdiv_qr __gmpz_cdiv_qr
+__GMP_DECLSPEC void mpz_cdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui
+__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_cdiv_r __gmpz_cdiv_r
+__GMP_DECLSPEC void mpz_cdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp
+__GMP_DECLSPEC void mpz_cdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui
+__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_cdiv_ui __gmpz_cdiv_ui
+__GMP_DECLSPEC unsigned long int mpz_cdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_clear __gmpz_clear
+__GMP_DECLSPEC void mpz_clear __GMP_PROTO ((mpz_ptr));
+
+#define mpz_clears __gmpz_clears
+__GMP_DECLSPEC void mpz_clears __GMP_PROTO ((mpz_ptr, ...));
+
+#define mpz_clrbit __gmpz_clrbit
+__GMP_DECLSPEC void mpz_clrbit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t));
+
+#define mpz_cmp __gmpz_cmp
+__GMP_DECLSPEC int mpz_cmp __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_cmp_d __gmpz_cmp_d
+__GMP_DECLSPEC int mpz_cmp_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
+
+#define _mpz_cmp_si __gmpz_cmp_si
+__GMP_DECLSPEC int _mpz_cmp_si __GMP_PROTO ((mpz_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define _mpz_cmp_ui __gmpz_cmp_ui
+__GMP_DECLSPEC int _mpz_cmp_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_cmpabs __gmpz_cmpabs
+__GMP_DECLSPEC int mpz_cmpabs __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_cmpabs_d __gmpz_cmpabs_d
+__GMP_DECLSPEC int mpz_cmpabs_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_cmpabs_ui __gmpz_cmpabs_ui
+__GMP_DECLSPEC int mpz_cmpabs_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_com __gmpz_com
+__GMP_DECLSPEC void mpz_com __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+
+#define mpz_combit __gmpz_combit
+__GMP_DECLSPEC void mpz_combit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t));
+
+#define mpz_congruent_p __gmpz_congruent_p
+__GMP_DECLSPEC int mpz_congruent_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p
+__GMP_DECLSPEC int mpz_congruent_2exp_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_congruent_ui_p __gmpz_congruent_ui_p
+__GMP_DECLSPEC int mpz_congruent_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long, unsigned long)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_divexact __gmpz_divexact
+__GMP_DECLSPEC void mpz_divexact __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_divexact_ui __gmpz_divexact_ui
+__GMP_DECLSPEC void mpz_divexact_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
+
+#define mpz_divisible_p __gmpz_divisible_p
+__GMP_DECLSPEC int mpz_divisible_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_divisible_ui_p __gmpz_divisible_ui_p
+__GMP_DECLSPEC int mpz_divisible_ui_p __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p
+__GMP_DECLSPEC int mpz_divisible_2exp_p __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_dump __gmpz_dump
+__GMP_DECLSPEC void mpz_dump __GMP_PROTO ((mpz_srcptr));
+
+#define mpz_export __gmpz_export
+__GMP_DECLSPEC void *mpz_export __GMP_PROTO ((void *, size_t *, int, size_t, int, size_t, mpz_srcptr));
+
+#define mpz_fac_ui __gmpz_fac_ui
+__GMP_DECLSPEC void mpz_fac_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
+
+#define mpz_fdiv_q __gmpz_fdiv_q
+__GMP_DECLSPEC void mpz_fdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp
+__GMP_DECLSPEC void mpz_fdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui
+__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_fdiv_qr __gmpz_fdiv_qr
+__GMP_DECLSPEC void mpz_fdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui
+__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_fdiv_r __gmpz_fdiv_r
+__GMP_DECLSPEC void mpz_fdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp
+__GMP_DECLSPEC void mpz_fdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui
+__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_fdiv_ui __gmpz_fdiv_ui
+__GMP_DECLSPEC unsigned long int mpz_fdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_fib_ui __gmpz_fib_ui
+__GMP_DECLSPEC void mpz_fib_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
+
+#define mpz_fib2_ui __gmpz_fib2_ui
+__GMP_DECLSPEC void mpz_fib2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
+
+#define mpz_fits_sint_p __gmpz_fits_sint_p
+__GMP_DECLSPEC int mpz_fits_sint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_fits_slong_p __gmpz_fits_slong_p
+__GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_fits_sshort_p __gmpz_fits_sshort_p
+__GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_fits_uint_p __gmpz_fits_uint_p
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)
+__GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_fits_ulong_p __gmpz_fits_ulong_p
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)
+__GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_fits_ushort_p __gmpz_fits_ushort_p
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)
+__GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_gcd __gmpz_gcd
+__GMP_DECLSPEC void mpz_gcd __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_gcd_ui __gmpz_gcd_ui
+__GMP_DECLSPEC unsigned long int mpz_gcd_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_gcdext __gmpz_gcdext
+__GMP_DECLSPEC void mpz_gcdext __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_get_d __gmpz_get_d
+__GMP_DECLSPEC double mpz_get_d __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_get_d_2exp __gmpz_get_d_2exp
+__GMP_DECLSPEC double mpz_get_d_2exp __GMP_PROTO ((signed long int *, mpz_srcptr));
+
+#define mpz_get_si __gmpz_get_si
+__GMP_DECLSPEC /* signed */ long int mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_get_str __gmpz_get_str
+__GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr));
+
+#define mpz_get_ui __gmpz_get_ui
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)
+__GMP_DECLSPEC unsigned long int mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_getlimbn __gmpz_getlimbn
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)
+__GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_hamdist __gmpz_hamdist
+__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_import __gmpz_import
+__GMP_DECLSPEC void mpz_import __GMP_PROTO ((mpz_ptr, size_t, int, size_t, int, size_t, __gmp_const void *));
+
+#define mpz_init __gmpz_init
+__GMP_DECLSPEC void mpz_init __GMP_PROTO ((mpz_ptr));
+
+#define mpz_init2 __gmpz_init2
+__GMP_DECLSPEC void mpz_init2 __GMP_PROTO ((mpz_ptr, mp_bitcnt_t));
+
+#define mpz_inits __gmpz_inits
+__GMP_DECLSPEC void mpz_inits __GMP_PROTO ((mpz_ptr, ...));
+
+#define mpz_init_set __gmpz_init_set
+__GMP_DECLSPEC void mpz_init_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+
+#define mpz_init_set_d __gmpz_init_set_d
+__GMP_DECLSPEC void mpz_init_set_d __GMP_PROTO ((mpz_ptr, double));
+
+#define mpz_init_set_si __gmpz_init_set_si
+__GMP_DECLSPEC void mpz_init_set_si __GMP_PROTO ((mpz_ptr, signed long int));
+
+#define mpz_init_set_str __gmpz_init_set_str
+__GMP_DECLSPEC int mpz_init_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
+
+#define mpz_init_set_ui __gmpz_init_set_ui
+__GMP_DECLSPEC void mpz_init_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
+
+#define mpz_inp_raw __gmpz_inp_raw
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpz_inp_raw __GMP_PROTO ((mpz_ptr, FILE *));
+#endif
+
+#define mpz_inp_str __gmpz_inp_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpz_inp_str __GMP_PROTO ((mpz_ptr, FILE *, int));
+#endif
+
+#define mpz_invert __gmpz_invert
+__GMP_DECLSPEC int mpz_invert __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_ior __gmpz_ior
+__GMP_DECLSPEC void mpz_ior __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_jacobi __gmpz_jacobi
+__GMP_DECLSPEC int mpz_jacobi __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_kronecker mpz_jacobi  /* alias */
+
+#define mpz_kronecker_si __gmpz_kronecker_si
+__GMP_DECLSPEC int mpz_kronecker_si __GMP_PROTO ((mpz_srcptr, long)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_kronecker_ui __gmpz_kronecker_ui
+__GMP_DECLSPEC int mpz_kronecker_ui __GMP_PROTO ((mpz_srcptr, unsigned long)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_si_kronecker __gmpz_si_kronecker
+__GMP_DECLSPEC int mpz_si_kronecker __GMP_PROTO ((long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_ui_kronecker __gmpz_ui_kronecker
+__GMP_DECLSPEC int mpz_ui_kronecker __GMP_PROTO ((unsigned long, mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_lcm __gmpz_lcm
+__GMP_DECLSPEC void mpz_lcm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_lcm_ui __gmpz_lcm_ui
+__GMP_DECLSPEC void mpz_lcm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long));
+
+#define mpz_legendre mpz_jacobi  /* alias */
+
+#define mpz_lucnum_ui __gmpz_lucnum_ui
+__GMP_DECLSPEC void mpz_lucnum_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
+
+#define mpz_lucnum2_ui __gmpz_lucnum2_ui
+__GMP_DECLSPEC void mpz_lucnum2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, unsigned long int));
+
+#define mpz_millerrabin __gmpz_millerrabin
+__GMP_DECLSPEC int mpz_millerrabin __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_mod __gmpz_mod
+__GMP_DECLSPEC void mpz_mod __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */
+
+#define mpz_mul __gmpz_mul
+__GMP_DECLSPEC void mpz_mul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_mul_2exp __gmpz_mul_2exp
+__GMP_DECLSPEC void mpz_mul_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_mul_si __gmpz_mul_si
+__GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, long int));
+
+#define mpz_mul_ui __gmpz_mul_ui
+__GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_neg __gmpz_neg
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)
+__GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+#endif
+
+#define mpz_nextprime __gmpz_nextprime
+__GMP_DECLSPEC void mpz_nextprime __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+
+#define mpz_out_raw __gmpz_out_raw
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpz_out_raw __GMP_PROTO ((FILE *, mpz_srcptr));
+#endif
+
+#define mpz_out_str __gmpz_out_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr));
+#endif
+
+#define mpz_perfect_power_p __gmpz_perfect_power_p
+__GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_perfect_square_p __gmpz_perfect_square_p
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)
+__GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_popcount __gmpz_popcount
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)
+__GMP_DECLSPEC mp_bitcnt_t mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_pow_ui __gmpz_pow_ui
+__GMP_DECLSPEC void mpz_pow_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_powm __gmpz_powm
+__GMP_DECLSPEC void mpz_powm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_powm_sec __gmpz_powm_sec
+__GMP_DECLSPEC void mpz_powm_sec __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_powm_ui __gmpz_powm_ui
+__GMP_DECLSPEC void mpz_powm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
+
+#define mpz_probab_prime_p __gmpz_probab_prime_p
+__GMP_DECLSPEC int mpz_probab_prime_p __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_random __gmpz_random
+__GMP_DECLSPEC void mpz_random __GMP_PROTO ((mpz_ptr, mp_size_t));
+
+#define mpz_random2 __gmpz_random2
+__GMP_DECLSPEC void mpz_random2 __GMP_PROTO ((mpz_ptr, mp_size_t));
+
+#define mpz_realloc2 __gmpz_realloc2
+__GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, mp_bitcnt_t));
+
+#define mpz_remove __gmpz_remove
+__GMP_DECLSPEC mp_bitcnt_t mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_root __gmpz_root
+__GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_rootrem __gmpz_rootrem
+__GMP_DECLSPEC void mpz_rootrem __GMP_PROTO ((mpz_ptr,mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_rrandomb __gmpz_rrandomb
+__GMP_DECLSPEC void mpz_rrandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mp_bitcnt_t));
+
+#define mpz_scan0 __gmpz_scan0
+__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_scan1 __gmpz_scan1
+__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_set __gmpz_set
+__GMP_DECLSPEC void mpz_set __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+
+#define mpz_set_d __gmpz_set_d
+__GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double));
+
+#define mpz_set_f __gmpz_set_f
+__GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr));
+
+#define mpz_set_q __gmpz_set_q
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)
+__GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr));
+#endif
+
+#define mpz_set_si __gmpz_set_si
+__GMP_DECLSPEC void mpz_set_si __GMP_PROTO ((mpz_ptr, signed long int));
+
+#define mpz_set_str __gmpz_set_str
+__GMP_DECLSPEC int mpz_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int));
+
+#define mpz_set_ui __gmpz_set_ui
+__GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int));
+
+#define mpz_setbit __gmpz_setbit
+__GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t));
+
+#define mpz_size __gmpz_size
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)
+__GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpz_sizeinbase __gmpz_sizeinbase
+__GMP_DECLSPEC size_t mpz_sizeinbase __GMP_PROTO ((mpz_srcptr, int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_sqrt __gmpz_sqrt
+__GMP_DECLSPEC void mpz_sqrt __GMP_PROTO ((mpz_ptr, mpz_srcptr));
+
+#define mpz_sqrtrem __gmpz_sqrtrem
+__GMP_DECLSPEC void mpz_sqrtrem __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
+
+#define mpz_sub __gmpz_sub
+__GMP_DECLSPEC void mpz_sub __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_sub_ui __gmpz_sub_ui
+__GMP_DECLSPEC void mpz_sub_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_ui_sub __gmpz_ui_sub
+__GMP_DECLSPEC void mpz_ui_sub __GMP_PROTO ((mpz_ptr, unsigned long int, mpz_srcptr));
+
+#define mpz_submul __gmpz_submul
+__GMP_DECLSPEC void mpz_submul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_submul_ui __gmpz_submul_ui
+__GMP_DECLSPEC void mpz_submul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_swap __gmpz_swap
+__GMP_DECLSPEC void mpz_swap __GMP_PROTO ((mpz_ptr, mpz_ptr)) __GMP_NOTHROW;
+
+#define mpz_tdiv_ui __gmpz_tdiv_ui
+__GMP_DECLSPEC unsigned long int mpz_tdiv_ui __GMP_PROTO ((mpz_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpz_tdiv_q __gmpz_tdiv_q
+__GMP_DECLSPEC void mpz_tdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp
+__GMP_DECLSPEC void mpz_tdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui
+__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_tdiv_qr __gmpz_tdiv_qr
+__GMP_DECLSPEC void mpz_tdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui
+__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_tdiv_r __gmpz_tdiv_r
+__GMP_DECLSPEC void mpz_tdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp
+__GMP_DECLSPEC void mpz_tdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t));
+
+#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui
+__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+
+#define mpz_tstbit __gmpz_tstbit
+__GMP_DECLSPEC int mpz_tstbit __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpz_ui_pow_ui __gmpz_ui_pow_ui
+__GMP_DECLSPEC void mpz_ui_pow_ui __GMP_PROTO ((mpz_ptr, unsigned long int, unsigned long int));
+
+#define mpz_urandomb __gmpz_urandomb
+__GMP_DECLSPEC void mpz_urandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mp_bitcnt_t));
+
+#define mpz_urandomm __gmpz_urandomm
+__GMP_DECLSPEC void mpz_urandomm __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mpz_srcptr));
+
+#define mpz_xor __gmpz_xor
+#define mpz_eor __gmpz_xor
+__GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+
+
+/**************** Rational (i.e. Q) routines.  ****************/
+
+#define mpq_abs __gmpq_abs
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)
+__GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr));
+#endif
+
+#define mpq_add __gmpq_add
+__GMP_DECLSPEC void mpq_add __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+
+#define mpq_canonicalize __gmpq_canonicalize
+__GMP_DECLSPEC void mpq_canonicalize __GMP_PROTO ((mpq_ptr));
+
+#define mpq_clear __gmpq_clear
+__GMP_DECLSPEC void mpq_clear __GMP_PROTO ((mpq_ptr));
+
+#define mpq_clears __gmpq_clears
+__GMP_DECLSPEC void mpq_clears __GMP_PROTO ((mpq_ptr, ...));
+
+#define mpq_cmp __gmpq_cmp
+__GMP_DECLSPEC int mpq_cmp __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define _mpq_cmp_si __gmpq_cmp_si
+__GMP_DECLSPEC int _mpq_cmp_si __GMP_PROTO ((mpq_srcptr, long, unsigned long)) __GMP_ATTRIBUTE_PURE;
+
+#define _mpq_cmp_ui __gmpq_cmp_ui
+__GMP_DECLSPEC int _mpq_cmp_ui __GMP_PROTO ((mpq_srcptr, unsigned long int, unsigned long int)) __GMP_ATTRIBUTE_PURE;
+
+#define mpq_div __gmpq_div
+__GMP_DECLSPEC void mpq_div __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+
+#define mpq_div_2exp __gmpq_div_2exp
+__GMP_DECLSPEC void mpq_div_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, mp_bitcnt_t));
+
+#define mpq_equal __gmpq_equal
+__GMP_DECLSPEC int mpq_equal __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpq_get_num __gmpq_get_num
+__GMP_DECLSPEC void mpq_get_num __GMP_PROTO ((mpz_ptr, mpq_srcptr));
+
+#define mpq_get_den __gmpq_get_den
+__GMP_DECLSPEC void mpq_get_den __GMP_PROTO ((mpz_ptr, mpq_srcptr));
+
+#define mpq_get_d __gmpq_get_d
+__GMP_DECLSPEC double mpq_get_d __GMP_PROTO ((mpq_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpq_get_str __gmpq_get_str
+__GMP_DECLSPEC char *mpq_get_str __GMP_PROTO ((char *, int, mpq_srcptr));
+
+#define mpq_init __gmpq_init
+__GMP_DECLSPEC void mpq_init __GMP_PROTO ((mpq_ptr));
+
+#define mpq_inits __gmpq_inits
+__GMP_DECLSPEC void mpq_inits __GMP_PROTO ((mpq_ptr, ...));
+
+#define mpq_inp_str __gmpq_inp_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpq_inp_str __GMP_PROTO ((mpq_ptr, FILE *, int));
+#endif
+
+#define mpq_inv __gmpq_inv
+__GMP_DECLSPEC void mpq_inv __GMP_PROTO ((mpq_ptr, mpq_srcptr));
+
+#define mpq_mul __gmpq_mul
+__GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+
+#define mpq_mul_2exp __gmpq_mul_2exp
+__GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, mp_bitcnt_t));
+
+#define mpq_neg __gmpq_neg
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)
+__GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr));
+#endif
+
+#define mpq_out_str __gmpq_out_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpq_out_str __GMP_PROTO ((FILE *, int, mpq_srcptr));
+#endif
+
+#define mpq_set __gmpq_set
+__GMP_DECLSPEC void mpq_set __GMP_PROTO ((mpq_ptr, mpq_srcptr));
+
+#define mpq_set_d __gmpq_set_d
+__GMP_DECLSPEC void mpq_set_d __GMP_PROTO ((mpq_ptr, double));
+
+#define mpq_set_den __gmpq_set_den
+__GMP_DECLSPEC void mpq_set_den __GMP_PROTO ((mpq_ptr, mpz_srcptr));
+
+#define mpq_set_f __gmpq_set_f
+__GMP_DECLSPEC void mpq_set_f __GMP_PROTO ((mpq_ptr, mpf_srcptr));
+
+#define mpq_set_num __gmpq_set_num
+__GMP_DECLSPEC void mpq_set_num __GMP_PROTO ((mpq_ptr, mpz_srcptr));
+
+#define mpq_set_si __gmpq_set_si
+__GMP_DECLSPEC void mpq_set_si __GMP_PROTO ((mpq_ptr, signed long int, unsigned long int));
+
+#define mpq_set_str __gmpq_set_str
+__GMP_DECLSPEC int mpq_set_str __GMP_PROTO ((mpq_ptr, __gmp_const char *, int));
+
+#define mpq_set_ui __gmpq_set_ui
+__GMP_DECLSPEC void mpq_set_ui __GMP_PROTO ((mpq_ptr, unsigned long int, unsigned long int));
+
+#define mpq_set_z __gmpq_set_z
+__GMP_DECLSPEC void mpq_set_z __GMP_PROTO ((mpq_ptr, mpz_srcptr));
+
+#define mpq_sub __gmpq_sub
+__GMP_DECLSPEC void mpq_sub __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+
+#define mpq_swap __gmpq_swap
+__GMP_DECLSPEC void mpq_swap __GMP_PROTO ((mpq_ptr, mpq_ptr)) __GMP_NOTHROW;
+
+
+/**************** Float (i.e. F) routines.  ****************/
+
+#define mpf_abs __gmpf_abs
+__GMP_DECLSPEC void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_add __gmpf_add
+__GMP_DECLSPEC void mpf_add __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+
+#define mpf_add_ui __gmpf_add_ui
+__GMP_DECLSPEC void mpf_add_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+#define mpf_ceil __gmpf_ceil
+__GMP_DECLSPEC void mpf_ceil __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_clear __gmpf_clear
+__GMP_DECLSPEC void mpf_clear __GMP_PROTO ((mpf_ptr));
+
+#define mpf_clears __gmpf_clears
+__GMP_DECLSPEC void mpf_clears __GMP_PROTO ((mpf_ptr, ...));
+
+#define mpf_cmp __gmpf_cmp
+__GMP_DECLSPEC int mpf_cmp __GMP_PROTO ((mpf_srcptr, mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_cmp_d __gmpf_cmp_d
+__GMP_DECLSPEC int mpf_cmp_d __GMP_PROTO ((mpf_srcptr, double)) __GMP_ATTRIBUTE_PURE;
+
+#define mpf_cmp_si __gmpf_cmp_si
+__GMP_DECLSPEC int mpf_cmp_si __GMP_PROTO ((mpf_srcptr, signed long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_cmp_ui __gmpf_cmp_ui
+__GMP_DECLSPEC int mpf_cmp_ui __GMP_PROTO ((mpf_srcptr, unsigned long int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_div __gmpf_div
+__GMP_DECLSPEC void mpf_div __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+
+#define mpf_div_2exp __gmpf_div_2exp
+__GMP_DECLSPEC void mpf_div_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, mp_bitcnt_t));
+
+#define mpf_div_ui __gmpf_div_ui
+__GMP_DECLSPEC void mpf_div_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+
+#define mpf_dump __gmpf_dump
+__GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr));
+
+#define mpf_eq __gmpf_eq
+__GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_sint_p __gmpf_fits_sint_p
+__GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_slong_p __gmpf_fits_slong_p
+__GMP_DECLSPEC int mpf_fits_slong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_sshort_p __gmpf_fits_sshort_p
+__GMP_DECLSPEC int mpf_fits_sshort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_uint_p __gmpf_fits_uint_p
+__GMP_DECLSPEC int mpf_fits_uint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_ulong_p __gmpf_fits_ulong_p
+__GMP_DECLSPEC int mpf_fits_ulong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_fits_ushort_p __gmpf_fits_ushort_p
+__GMP_DECLSPEC int mpf_fits_ushort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_floor __gmpf_floor
+__GMP_DECLSPEC void mpf_floor __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_get_d __gmpf_get_d
+__GMP_DECLSPEC double mpf_get_d __GMP_PROTO ((mpf_srcptr)) __GMP_ATTRIBUTE_PURE;
+
+#define mpf_get_d_2exp __gmpf_get_d_2exp
+__GMP_DECLSPEC double mpf_get_d_2exp __GMP_PROTO ((signed long int *, mpf_srcptr));
+
+#define mpf_get_default_prec __gmpf_get_default_prec
+__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec __GMP_PROTO ((void)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_get_prec __gmpf_get_prec
+__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_get_si __gmpf_get_si
+__GMP_DECLSPEC long mpf_get_si __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_get_str __gmpf_get_str
+__GMP_DECLSPEC char *mpf_get_str __GMP_PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
+
+#define mpf_get_ui __gmpf_get_ui
+__GMP_DECLSPEC unsigned long mpf_get_ui __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_init __gmpf_init
+__GMP_DECLSPEC void mpf_init __GMP_PROTO ((mpf_ptr));
+
+#define mpf_init2 __gmpf_init2
+__GMP_DECLSPEC void mpf_init2 __GMP_PROTO ((mpf_ptr, mp_bitcnt_t));
+
+#define mpf_inits __gmpf_inits
+__GMP_DECLSPEC void mpf_inits __GMP_PROTO ((mpf_ptr, ...));
+
+#define mpf_init_set __gmpf_init_set
+__GMP_DECLSPEC void mpf_init_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_init_set_d __gmpf_init_set_d
+__GMP_DECLSPEC void mpf_init_set_d __GMP_PROTO ((mpf_ptr, double));
+
+#define mpf_init_set_si __gmpf_init_set_si
+__GMP_DECLSPEC void mpf_init_set_si __GMP_PROTO ((mpf_ptr, signed long int));
+
+#define mpf_init_set_str __gmpf_init_set_str
+__GMP_DECLSPEC int mpf_init_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
+
+#define mpf_init_set_ui __gmpf_init_set_ui
+__GMP_DECLSPEC void mpf_init_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
+
+#define mpf_inp_str __gmpf_inp_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpf_inp_str __GMP_PROTO ((mpf_ptr, FILE *, int));
+#endif
+
+#define mpf_integer_p __gmpf_integer_p
+__GMP_DECLSPEC int mpf_integer_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_mul __gmpf_mul
+__GMP_DECLSPEC void mpf_mul __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+
+#define mpf_mul_2exp __gmpf_mul_2exp
+__GMP_DECLSPEC void mpf_mul_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, mp_bitcnt_t));
+
+#define mpf_mul_ui __gmpf_mul_ui
+__GMP_DECLSPEC void mpf_mul_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+
+#define mpf_neg __gmpf_neg
+__GMP_DECLSPEC void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_out_str __gmpf_out_str
+#ifdef _GMP_H_HAVE_FILE
+__GMP_DECLSPEC size_t mpf_out_str __GMP_PROTO ((FILE *, int, size_t, mpf_srcptr));
+#endif
+
+#define mpf_pow_ui __gmpf_pow_ui
+__GMP_DECLSPEC void mpf_pow_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+
+#define mpf_random2 __gmpf_random2
+__GMP_DECLSPEC void mpf_random2 __GMP_PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
+
+#define mpf_reldiff __gmpf_reldiff
+__GMP_DECLSPEC void mpf_reldiff __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+
+#define mpf_set __gmpf_set
+__GMP_DECLSPEC void mpf_set __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_set_d __gmpf_set_d
+__GMP_DECLSPEC void mpf_set_d __GMP_PROTO ((mpf_ptr, double));
+
+#define mpf_set_default_prec __gmpf_set_default_prec
+__GMP_DECLSPEC void mpf_set_default_prec __GMP_PROTO ((mp_bitcnt_t)) __GMP_NOTHROW;
+
+#define mpf_set_prec __gmpf_set_prec
+__GMP_DECLSPEC void mpf_set_prec __GMP_PROTO ((mpf_ptr, mp_bitcnt_t));
+
+#define mpf_set_prec_raw __gmpf_set_prec_raw
+__GMP_DECLSPEC void mpf_set_prec_raw __GMP_PROTO ((mpf_ptr, mp_bitcnt_t)) __GMP_NOTHROW;
+
+#define mpf_set_q __gmpf_set_q
+__GMP_DECLSPEC void mpf_set_q __GMP_PROTO ((mpf_ptr, mpq_srcptr));
+
+#define mpf_set_si __gmpf_set_si
+__GMP_DECLSPEC void mpf_set_si __GMP_PROTO ((mpf_ptr, signed long int));
+
+#define mpf_set_str __gmpf_set_str
+__GMP_DECLSPEC int mpf_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int));
+
+#define mpf_set_ui __gmpf_set_ui
+__GMP_DECLSPEC void mpf_set_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
+
+#define mpf_set_z __gmpf_set_z
+__GMP_DECLSPEC void mpf_set_z __GMP_PROTO ((mpf_ptr, mpz_srcptr));
+
+#define mpf_size __gmpf_size
+__GMP_DECLSPEC size_t mpf_size __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpf_sqrt __gmpf_sqrt
+__GMP_DECLSPEC void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_sqrt_ui __gmpf_sqrt_ui
+__GMP_DECLSPEC void mpf_sqrt_ui __GMP_PROTO ((mpf_ptr, unsigned long int));
+
+#define mpf_sub __gmpf_sub
+__GMP_DECLSPEC void mpf_sub __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+
+#define mpf_sub_ui __gmpf_sub_ui
+__GMP_DECLSPEC void mpf_sub_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+
+#define mpf_swap __gmpf_swap
+__GMP_DECLSPEC void mpf_swap __GMP_PROTO ((mpf_ptr, mpf_ptr)) __GMP_NOTHROW;
+
+#define mpf_trunc __gmpf_trunc
+__GMP_DECLSPEC void mpf_trunc __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+
+#define mpf_ui_div __gmpf_ui_div
+__GMP_DECLSPEC void mpf_ui_div __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
+
+#define mpf_ui_sub __gmpf_ui_sub
+__GMP_DECLSPEC void mpf_ui_sub __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
+
+#define mpf_urandomb __gmpf_urandomb
+__GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, mp_bitcnt_t));
+
+
+/************ Low level positive-integer (i.e. N) routines.  ************/
+
+/* This is ugly, but we need to make user calls reach the prefixed function. */
+
+#define mpn_add __MPN(add)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)
+__GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
+#endif
+
+#define mpn_add_1 __MPN(add_1)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)
+__GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
+#endif
+
+#define mpn_add_n __MPN(add_n)
+__GMP_DECLSPEC mp_limb_t mpn_add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+
+#define mpn_addmul_1 __MPN(addmul_1)
+__GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+
+#define mpn_cmp __MPN(cmp)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)
+__GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+#endif
+
+#define mpn_divexact_by3(dst,src,size) \
+  mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))
+
+#define mpn_divexact_by3c __MPN(divexact_by3c)
+__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+
+#define mpn_divmod_1(qp,np,nsize,dlimb) \
+  mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)
+
+#define mpn_divrem __MPN(divrem)
+__GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
+
+#define mpn_divrem_1 __MPN(divrem_1)
+__GMP_DECLSPEC mp_limb_t mpn_divrem_1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
+
+#define mpn_divrem_2 __MPN(divrem_2)
+__GMP_DECLSPEC mp_limb_t mpn_divrem_2 __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr));
+
+#define mpn_gcd __MPN(gcd)
+__GMP_DECLSPEC mp_size_t mpn_gcd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
+
+#define mpn_gcd_1 __MPN(gcd_1)
+__GMP_DECLSPEC mp_limb_t mpn_gcd_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_gcdext_1 __MPN(gcdext_1)
+__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 __GMP_PROTO ((mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t));
+
+#define mpn_gcdext __MPN(gcdext)
+__GMP_DECLSPEC mp_size_t mpn_gcdext __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
+
+#define mpn_get_str __MPN(get_str)
+__GMP_DECLSPEC size_t mpn_get_str __GMP_PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
+
+#define mpn_hamdist __MPN(hamdist)
+__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpn_lshift __MPN(lshift)
+__GMP_DECLSPEC mp_limb_t mpn_lshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
+
+#define mpn_mod_1 __MPN(mod_1)
+__GMP_DECLSPEC mp_limb_t mpn_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_mul __MPN(mul)
+__GMP_DECLSPEC mp_limb_t mpn_mul __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
+
+#define mpn_mul_1 __MPN(mul_1)
+__GMP_DECLSPEC mp_limb_t mpn_mul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+
+#define mpn_mul_n __MPN(mul_n)
+__GMP_DECLSPEC void mpn_mul_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+
+#define mpn_sqr __MPN(sqr)
+__GMP_DECLSPEC void mpn_sqr __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
+
+#define mpn_neg __MPN(neg)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg)
+__GMP_DECLSPEC mp_limb_t mpn_neg __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
+#endif
+
+#define mpn_com __MPN(com)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_com)
+__GMP_DECLSPEC void mpn_com __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
+#endif
+
+#define mpn_perfect_square_p __MPN(perfect_square_p)
+__GMP_DECLSPEC int mpn_perfect_square_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_perfect_power_p __MPN(perfect_power_p)
+__GMP_DECLSPEC int mpn_perfect_power_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_popcount __MPN(popcount)
+__GMP_DECLSPEC mp_bitcnt_t mpn_popcount __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
+#define mpn_pow_1 __MPN(pow_1)
+__GMP_DECLSPEC mp_size_t mpn_pow_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr));
+
+/* undocumented now, but retained here for upward compatibility */
+#define mpn_preinv_mod_1 __MPN(preinv_mod_1)
+__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_random __MPN(random)
+__GMP_DECLSPEC void mpn_random __GMP_PROTO ((mp_ptr, mp_size_t));
+
+#define mpn_random2 __MPN(random2)
+__GMP_DECLSPEC void mpn_random2 __GMP_PROTO ((mp_ptr, mp_size_t));
+
+#define mpn_rshift __MPN(rshift)
+__GMP_DECLSPEC mp_limb_t mpn_rshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
+
+#define mpn_scan0 __MPN(scan0)
+__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 __GMP_PROTO ((mp_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_scan1 __MPN(scan1)
+__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 __GMP_PROTO ((mp_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE;
+
+#define mpn_set_str __MPN(set_str)
+__GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int));
+
+#define mpn_sqrtrem __MPN(sqrtrem)
+__GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
+
+#define mpn_sub __MPN(sub)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)
+__GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
+#endif
+
+#define mpn_sub_1 __MPN(sub_1)
+#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)
+__GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW;
+#endif
+
+#define mpn_sub_n __MPN(sub_n)
+__GMP_DECLSPEC mp_limb_t mpn_sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+
+#define mpn_submul_1 __MPN(submul_1)
+__GMP_DECLSPEC mp_limb_t mpn_submul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+
+#define mpn_tdiv_qr __MPN(tdiv_qr)
+__GMP_DECLSPEC void mpn_tdiv_qr __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
+
+#define mpn_and_n __MPN(and_n)
+__GMP_DECLSPEC void mpn_and_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_andn_n __MPN(andn_n)
+__GMP_DECLSPEC void mpn_andn_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_nand_n __MPN(nand_n)
+__GMP_DECLSPEC void mpn_nand_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_ior_n __MPN(ior_n)
+__GMP_DECLSPEC void mpn_ior_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_iorn_n __MPN(iorn_n)
+__GMP_DECLSPEC void mpn_iorn_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_nior_n __MPN(nior_n)
+__GMP_DECLSPEC void mpn_nior_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_xor_n __MPN(xor_n)
+__GMP_DECLSPEC void mpn_xor_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+#define mpn_xnor_n __MPN(xnor_n)
+__GMP_DECLSPEC void mpn_xnor_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+
+#define mpn_copyi __MPN(copyi)
+__GMP_DECLSPEC void mpn_copyi __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
+#define mpn_copyd __MPN(copyd)
+__GMP_DECLSPEC void mpn_copyd __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t));
+#define mpn_zero __MPN(zero)
+__GMP_DECLSPEC void mpn_zero __GMP_PROTO ((mp_ptr, mp_size_t));
+
+/**************** mpz inlines ****************/
+
+/* The following are provided as inlines where possible, but always exist as
+   library functions too, for binary compatibility.
+
+   Within gmp itself this inlining generally isn't relied on, since it
+   doesn't get done for all compilers, whereas if something is worth
+   inlining then it's worth arranging always.
+
+   There are two styles of inlining here.  When the same bit of code is
+   wanted for the inline as for the library version, then __GMP_FORCE_foo
+   arranges for that code to be emitted and the __GMP_EXTERN_INLINE
+   directive suppressed, eg. mpz_fits_uint_p.  When a different bit of code
+   is wanted for the inline than for the library version, then
+   __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs.  */
+
+#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)
+__GMP_EXTERN_INLINE void
+mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
+{
+  if (__gmp_w != __gmp_u)
+    mpz_set (__gmp_w, __gmp_u);
+  __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);
+}
+#endif
+
+#if GMP_NAIL_BITS == 0
+#define __GMPZ_FITS_UTYPE_P(z,maxval)					\
+  mp_size_t  __gmp_n = z->_mp_size;					\
+  mp_ptr  __gmp_p = z->_mp_d;						\
+  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));
+#else
+#define __GMPZ_FITS_UTYPE_P(z,maxval)					\
+  mp_size_t  __gmp_n = z->_mp_size;					\
+  mp_ptr  __gmp_p = z->_mp_d;						\
+  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)	\
+	  || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)
+#if ! defined (__GMP_FORCE_mpz_fits_uint_p)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
+{
+  __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX);
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)
+#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
+{
+  __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX);
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)
+#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW
+{
+  __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX);
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)
+#if ! defined (__GMP_FORCE_mpz_get_ui)
+__GMP_EXTERN_INLINE
+#endif
+unsigned long
+mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW
+{
+  mp_ptr __gmp_p = __gmp_z->_mp_d;
+  mp_size_t __gmp_n = __gmp_z->_mp_size;
+  mp_limb_t __gmp_l = __gmp_p[0];
+  /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings
+     about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland
+     C++ 6.0 warnings about condition always true for something like
+     "__GMP_ULONG_MAX < GMP_NUMB_MASK".  */
+#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)
+  /* limb==long and no nails, or limb==longlong, one limb is enough */
+  return (__gmp_n != 0 ? __gmp_l : 0);
+#else
+  /* limb==long and nails, need two limbs when available */
+  __gmp_n = __GMP_ABS (__gmp_n);
+  if (__gmp_n <= 1)
+    return (__gmp_n != 0 ? __gmp_l : 0);
+  else
+    return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);
+#endif
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)
+#if ! defined (__GMP_FORCE_mpz_getlimbn)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW
+{
+  mp_limb_t  __gmp_result = 0;
+  if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))
+    __gmp_result = __gmp_z->_mp_d[__gmp_n];
+  return __gmp_result;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)
+__GMP_EXTERN_INLINE void
+mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)
+{
+  if (__gmp_w != __gmp_u)
+    mpz_set (__gmp_w, __gmp_u);
+  __gmp_w->_mp_size = - __gmp_w->_mp_size;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)
+#if ! defined (__GMP_FORCE_mpz_perfect_square_p)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpz_perfect_square_p (mpz_srcptr __gmp_a)
+{
+  mp_size_t __gmp_asize;
+  int       __gmp_result;
+
+  __gmp_asize = __gmp_a->_mp_size;
+  __gmp_result = (__gmp_asize >= 0);  /* zero is a square, negatives are not */
+  if (__GMP_LIKELY (__gmp_asize > 0))
+    __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);
+  return __gmp_result;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)
+#if ! defined (__GMP_FORCE_mpz_popcount)
+__GMP_EXTERN_INLINE
+#endif
+mp_bitcnt_t
+mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW
+{
+  mp_size_t      __gmp_usize;
+  mp_bitcnt_t    __gmp_result;
+
+  __gmp_usize = __gmp_u->_mp_size;
+  __gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0);
+  if (__GMP_LIKELY (__gmp_usize > 0))
+    __gmp_result =  mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
+  return __gmp_result;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)
+#if ! defined (__GMP_FORCE_mpz_set_q)
+__GMP_EXTERN_INLINE
+#endif
+void
+mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)
+{
+  mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)
+#if ! defined (__GMP_FORCE_mpz_size)
+__GMP_EXTERN_INLINE
+#endif
+size_t
+mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW
+{
+  return __GMP_ABS (__gmp_z->_mp_size);
+}
+#endif
+
+
+/**************** mpq inlines ****************/
+
+#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)
+__GMP_EXTERN_INLINE void
+mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
+{
+  if (__gmp_w != __gmp_u)
+    mpq_set (__gmp_w, __gmp_u);
+  __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)
+__GMP_EXTERN_INLINE void
+mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)
+{
+  if (__gmp_w != __gmp_u)
+    mpq_set (__gmp_w, __gmp_u);
+  __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;
+}
+#endif
+
+
+/**************** mpn inlines ****************/
+
+/* The comments with __GMPN_ADD_1 below apply here too.
+
+   The test for FUNCTION returning 0 should predict well.  If it's assumed
+   {yp,ysize} will usually have a random number of bits then the high limb
+   won't be full and a carry out will occur a good deal less than 50% of the
+   time.
+
+   ysize==0 isn't a documented feature, but is used internally in a few
+   places.
+
+   Producing cout last stops it using up a register during the main part of
+   the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))"
+   doesn't seem able to move the true and false legs of the conditional up
+   to the two places cout is generated.  */
+
+#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST)     \
+  do {                                                                  \
+    mp_size_t  __gmp_i;                                                 \
+    mp_limb_t  __gmp_x;                                                 \
+                                                                        \
+    /* ASSERT ((ysize) >= 0); */                                        \
+    /* ASSERT ((xsize) >= (ysize)); */                                  \
+    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */      \
+    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */      \
+                                                                        \
+    __gmp_i = (ysize);                                                  \
+    if (__gmp_i != 0)                                                   \
+      {                                                                 \
+        if (FUNCTION (wp, xp, yp, __gmp_i))                             \
+          {                                                             \
+            do                                                          \
+              {                                                         \
+                if (__gmp_i >= (xsize))                                 \
+                  {                                                     \
+                    (cout) = 1;                                         \
+                    goto __gmp_done;                                    \
+                  }                                                     \
+                __gmp_x = (xp)[__gmp_i];                                \
+              }                                                         \
+            while (TEST);                                               \
+          }                                                             \
+      }                                                                 \
+    if ((wp) != (xp))                                                   \
+      __GMPN_COPY_REST (wp, xp, xsize, __gmp_i);                        \
+    (cout) = 0;                                                         \
+  __gmp_done:                                                           \
+    ;                                                                   \
+  } while (0)
+
+#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize)              \
+  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n,       \
+               (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))
+#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize)              \
+  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n,       \
+               (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))
+
+
+/* The use of __gmp_i indexing is designed to ensure a compile time src==dst
+   remains nice and clear to the compiler, so that __GMPN_COPY_REST can
+   disappear, and the load/add/store gets a chance to become a
+   read-modify-write on CISC CPUs.
+
+   Alternatives:
+
+   Using a pair of pointers instead of indexing would be possible, but gcc
+   isn't able to recognise compile-time src==dst in that case, even when the
+   pointers are incremented more or less together.  Other compilers would
+   very likely have similar difficulty.
+
+   gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or
+   similar to detect a compile-time src==dst.  This works nicely on gcc
+   2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems
+   to be always false, for a pointer p.  But the current code form seems
+   good enough for src==dst anyway.
+
+   gcc on x86 as usual doesn't give particularly good flags handling for the
+   carry/borrow detection.  It's tempting to want some multi instruction asm
+   blocks to help it, and this was tried, but in truth there's only a few
+   instructions to save and any gain is all too easily lost by register
+   juggling setting up for the asm.  */
+
+#if GMP_NAIL_BITS == 0
+#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)		\
+  do {								\
+    mp_size_t  __gmp_i;						\
+    mp_limb_t  __gmp_x, __gmp_r;                                \
+								\
+    /* ASSERT ((n) >= 1); */					\
+    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */	\
+								\
+    __gmp_x = (src)[0];						\
+    __gmp_r = __gmp_x OP (v);                                   \
+    (dst)[0] = __gmp_r;						\
+    if (CB (__gmp_r, __gmp_x, (v)))                             \
+      {								\
+	(cout) = 1;						\
+	for (__gmp_i = 1; __gmp_i < (n);)                       \
+	  {							\
+	    __gmp_x = (src)[__gmp_i];                           \
+	    __gmp_r = __gmp_x OP 1;                             \
+	    (dst)[__gmp_i] = __gmp_r;                           \
+	    ++__gmp_i;						\
+	    if (!CB (__gmp_r, __gmp_x, 1))                      \
+	      {							\
+		if ((src) != (dst))				\
+		  __GMPN_COPY_REST (dst, src, n, __gmp_i);      \
+		(cout) = 0;					\
+		break;						\
+	      }							\
+	  }							\
+      }								\
+    else							\
+      {								\
+	if ((src) != (dst))					\
+	  __GMPN_COPY_REST (dst, src, n, 1);			\
+	(cout) = 0;						\
+      }								\
+  } while (0)
+#endif
+
+#if GMP_NAIL_BITS >= 1
+#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)		\
+  do {								\
+    mp_size_t  __gmp_i;						\
+    mp_limb_t  __gmp_x, __gmp_r;				\
+								\
+    /* ASSERT ((n) >= 1); */					\
+    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */	\
+								\
+    __gmp_x = (src)[0];						\
+    __gmp_r = __gmp_x OP (v);					\
+    (dst)[0] = __gmp_r & GMP_NUMB_MASK;				\
+    if (__gmp_r >> GMP_NUMB_BITS != 0)				\
+      {								\
+	(cout) = 1;						\
+	for (__gmp_i = 1; __gmp_i < (n);)			\
+	  {							\
+	    __gmp_x = (src)[__gmp_i];				\
+	    __gmp_r = __gmp_x OP 1;				\
+	    (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK;		\
+	    ++__gmp_i;						\
+	    if (__gmp_r >> GMP_NUMB_BITS == 0)			\
+	      {							\
+		if ((src) != (dst))				\
+		  __GMPN_COPY_REST (dst, src, n, __gmp_i);	\
+		(cout) = 0;					\
+		break;						\
+	      }							\
+	  }							\
+      }								\
+    else							\
+      {								\
+	if ((src) != (dst))					\
+	  __GMPN_COPY_REST (dst, src, n, 1);			\
+	(cout) = 0;						\
+      }								\
+  } while (0)
+#endif
+
+#define __GMPN_ADDCB(r,x,y) ((r) < (y))
+#define __GMPN_SUBCB(r,x,y) ((x) < (y))
+
+#define __GMPN_ADD_1(cout, dst, src, n, v)	     \
+  __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)
+#define __GMPN_SUB_1(cout, dst, src, n, v)	     \
+  __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)
+
+
+/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or
+   negative.  size==0 is allowed.  On random data usually only one limb will
+   need to be examined to get a result, so it's worth having it inline.  */
+#define __GMPN_CMP(result, xp, yp, size)                                \
+  do {                                                                  \
+    mp_size_t  __gmp_i;                                                 \
+    mp_limb_t  __gmp_x, __gmp_y;                                        \
+                                                                        \
+    /* ASSERT ((size) >= 0); */                                         \
+                                                                        \
+    (result) = 0;                                                       \
+    __gmp_i = (size);                                                   \
+    while (--__gmp_i >= 0)                                              \
+      {                                                                 \
+        __gmp_x = (xp)[__gmp_i];                                        \
+        __gmp_y = (yp)[__gmp_i];                                        \
+        if (__gmp_x != __gmp_y)                                         \
+          {                                                             \
+            /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */   \
+            (result) = (__gmp_x > __gmp_y ? 1 : -1);                    \
+            break;                                                      \
+          }                                                             \
+      }                                                                 \
+  } while (0)
+
+
+#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)
+#define __GMPN_COPY_REST(dst, src, size, start)                 \
+  do {                                                          \
+    /* ASSERT ((start) >= 0); */                                \
+    /* ASSERT ((start) <= (size)); */                           \
+    __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \
+  } while (0)
+#endif
+
+/* Copy {src,size} to {dst,size}, starting at "start".  This is designed to
+   keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,
+   __GMPN_ADD, etc.  */
+#if ! defined (__GMPN_COPY_REST)
+#define __GMPN_COPY_REST(dst, src, size, start)                 \
+  do {                                                          \
+    mp_size_t __gmp_j;                                          \
+    /* ASSERT ((size) >= 0); */                                 \
+    /* ASSERT ((start) >= 0); */                                \
+    /* ASSERT ((start) <= (size)); */                           \
+    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */     \
+    __GMP_CRAY_Pragma ("_CRI ivdep");                           \
+    for (__gmp_j = (start); __gmp_j < (size); __gmp_j++)        \
+      (dst)[__gmp_j] = (src)[__gmp_j];                          \
+  } while (0)
+#endif
+
+/* Enhancement: Use some of the smarter code from gmp-impl.h.  Maybe use
+   mpn_copyi if there's a native version, and if we don't mind demanding
+   binary compatibility for it (on targets which use it).  */
+
+#if ! defined (__GMPN_COPY)
+#define __GMPN_COPY(dst, src, size)   __GMPN_COPY_REST (dst, src, size, 0)
+#endif
+
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)
+#if ! defined (__GMP_FORCE_mpn_add)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
+{
+  mp_limb_t  __gmp_c;
+  __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
+  return __gmp_c;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)
+#if ! defined (__GMP_FORCE_mpn_add_1)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
+{
+  mp_limb_t  __gmp_c;
+  __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
+  return __gmp_c;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)
+#if ! defined (__GMP_FORCE_mpn_cmp)
+__GMP_EXTERN_INLINE
+#endif
+int
+mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW
+{
+  int __gmp_result;
+  __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);
+  return __gmp_result;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)
+#if ! defined (__GMP_FORCE_mpn_sub)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)
+{
+  mp_limb_t  __gmp_c;
+  __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);
+  return __gmp_c;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)
+#if ! defined (__GMP_FORCE_mpn_sub_1)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW
+{
+  mp_limb_t  __gmp_c;
+  __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);
+  return __gmp_c;
+}
+#endif
+
+#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg)
+#if ! defined (__GMP_FORCE_mpn_neg)
+__GMP_EXTERN_INLINE
+#endif
+mp_limb_t
+mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)
+{
+  mp_limb_t __gmp_ul, __gmp_cy;
+  __gmp_cy = 0;
+  do {
+      __gmp_ul = *__gmp_up++;
+      *__gmp_rp++ = -__gmp_ul - __gmp_cy;
+      __gmp_cy |= __gmp_ul != 0;
+  } while (--__gmp_n != 0);
+  return __gmp_cy;
+}
+#endif
+
+#if defined (__cplusplus)
+}
+#endif
+
+
+/* Allow faster testing for negative, zero, and positive.  */
+#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
+#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
+#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
+
+/* When using GCC, optimize certain common comparisons.  */
+#if defined (__GNUC__) && __GNUC__ >= 2
+#define mpz_cmp_ui(Z,UI) \
+  (__builtin_constant_p (UI) && (UI) == 0				\
+   ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))
+#define mpz_cmp_si(Z,SI) \
+  (__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z)			\
+   : __builtin_constant_p (SI) && (SI) > 0				\
+    ? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI))		\
+   : _mpz_cmp_si (Z,SI))
+#define mpq_cmp_ui(Q,NUI,DUI) \
+  (__builtin_constant_p (NUI) && (NUI) == 0				\
+   ? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI))
+#define mpq_cmp_si(q,n,d)                       \
+  (__builtin_constant_p ((n) >= 0) && (n) >= 0  \
+   ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \
+   : _mpq_cmp_si (q, n, d))
+#else
+#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)
+#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)
+#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)
+#define mpq_cmp_si(q,n,d)  _mpq_cmp_si(q,n,d)
+#endif
+
+
+/* Using "&" rather than "&&" means these can come out branch-free.  Every
+   mpz_t has at least one limb allocated, so fetching the low limb is always
+   allowed.  */
+#define mpz_odd_p(z)   (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))
+#define mpz_even_p(z)  (! mpz_odd_p (z))
+
+
+/**************** C++ routines ****************/
+
+#ifdef __cplusplus
+__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);
+__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);
+__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);
+__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);
+__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);
+__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);
+#endif
+
+
+/* Source-level compatibility with GMP 2 and earlier. */
+#define mpn_divmod(qp,np,nsize,dp,dsize) \
+  mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)
+
+/* Source-level compatibility with GMP 1.  */
+#define mpz_mdiv	mpz_fdiv_q
+#define mpz_mdivmod	mpz_fdiv_qr
+#define mpz_mmod	mpz_fdiv_r
+#define mpz_mdiv_ui	mpz_fdiv_q_ui
+#define mpz_mdivmod_ui(q,r,n,d) \
+  (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
+#define mpz_mmod_ui(r,n,d) \
+  (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
+
+/* Useful synonyms, but not quite compatible with GMP 1.  */
+#define mpz_div		mpz_fdiv_q
+#define mpz_divmod	mpz_fdiv_qr
+#define mpz_div_ui	mpz_fdiv_q_ui
+#define mpz_divmod_ui	mpz_fdiv_qr_ui
+#define mpz_div_2exp	mpz_fdiv_q_2exp
+#define mpz_mod_2exp	mpz_fdiv_r_2exp
+
+enum
+{
+  GMP_ERROR_NONE = 0,
+  GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,
+  GMP_ERROR_DIVISION_BY_ZERO = 2,
+  GMP_ERROR_SQRT_OF_NEGATIVE = 4,
+  GMP_ERROR_INVALID_ARGUMENT = 8
+};
+
+/* Define CC and CFLAGS which were used to build this version of GMP */
+#define __GMP_CC "/usr/local/google/home/andrewhsieh/mydroid/prebuilts/tools/gcc-sdk/gcc -std=gnu99"
+#define __GMP_CFLAGS "-O2 -pedantic -m64 -mtune=k8 -march=k8"
+
+/* Major version number is the value of __GNU_MP__ too, above and in mp.h. */
+#define __GNU_MP_VERSION 5
+#define __GNU_MP_VERSION_MINOR 0
+#define __GNU_MP_VERSION_PATCHLEVEL 5
+#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)
+
+#define __GMP_H__
+#endif /* __GMP_H__ */
diff --git a/include/isl/aff.h b/include/isl/aff.h
new file mode 100644
index 0000000..a8e16c8
--- /dev/null
+++ b/include/isl/aff.h
@@ -0,0 +1,566 @@
+#ifndef ISL_AFF_H
+#define ISL_AFF_H
+
+#include <isl/local_space.h>
+#include <isl/printer.h>
+#include <isl/set_type.h>
+#include <isl/aff_type.h>
+#include <isl/list.h>
+#include <isl/multi.h>
+#include <isl/union_set_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+__isl_give isl_aff *isl_aff_zero_on_domain(__isl_take isl_local_space *ls);
+__isl_give isl_aff *isl_aff_var_on_domain(__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+
+__isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff);
+void *isl_aff_free(__isl_take isl_aff *aff);
+
+isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff);
+
+int isl_aff_dim(__isl_keep isl_aff *aff, enum isl_dim_type type);
+int isl_aff_involves_dims(__isl_keep isl_aff *aff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_space *isl_aff_get_domain_space(__isl_keep isl_aff *aff);
+__isl_give isl_space *isl_aff_get_space(__isl_keep isl_aff *aff);
+__isl_give isl_local_space *isl_aff_get_domain_local_space(
+	__isl_keep isl_aff *aff);
+__isl_give isl_local_space *isl_aff_get_local_space(__isl_keep isl_aff *aff);
+
+const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
+	enum isl_dim_type type, unsigned pos);
+int isl_aff_get_constant(__isl_keep isl_aff *aff, isl_int *v);
+int isl_aff_get_coefficient(__isl_keep isl_aff *aff,
+	enum isl_dim_type type, int pos, isl_int *v);
+int isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v);
+__isl_give isl_aff *isl_aff_set_constant(__isl_take isl_aff *aff, isl_int v);
+__isl_give isl_aff *isl_aff_set_constant_si(__isl_take isl_aff *aff, int v);
+__isl_give isl_aff *isl_aff_set_coefficient(__isl_take isl_aff *aff,
+	enum isl_dim_type type, int pos, isl_int v);
+__isl_give isl_aff *isl_aff_set_coefficient_si(__isl_take isl_aff *aff,
+	enum isl_dim_type type, int pos, int v);
+__isl_give isl_aff *isl_aff_set_denominator(__isl_take isl_aff *aff, isl_int v);
+__isl_give isl_aff *isl_aff_add_constant(__isl_take isl_aff *aff, isl_int v);
+__isl_give isl_aff *isl_aff_add_constant_si(__isl_take isl_aff *aff, int v);
+__isl_give isl_aff *isl_aff_add_constant_num(__isl_take isl_aff *aff,
+	isl_int v);
+__isl_give isl_aff *isl_aff_add_constant_num_si(__isl_take isl_aff *aff, int v);
+__isl_give isl_aff *isl_aff_add_coefficient(__isl_take isl_aff *aff,
+	enum isl_dim_type type, int pos, isl_int v);
+__isl_give isl_aff *isl_aff_add_coefficient_si(__isl_take isl_aff *aff,
+	enum isl_dim_type type, int pos, int v);
+
+int isl_aff_is_cst(__isl_keep isl_aff *aff);
+
+__isl_give isl_aff *isl_aff_set_dim_name(__isl_take isl_aff *aff,
+	enum isl_dim_type type, unsigned pos, const char *s);
+__isl_give isl_aff *isl_aff_set_dim_id(__isl_take isl_aff *aff,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+
+int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2);
+int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
+
+__isl_give isl_aff *isl_aff_get_div(__isl_keep isl_aff *aff, int pos);
+
+__isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff);
+__isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff);
+__isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff);
+__isl_give isl_aff *isl_aff_mod(__isl_take isl_aff *aff, isl_int mod);
+
+__isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+__isl_give isl_aff *isl_aff_div(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+__isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+__isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+
+__isl_give isl_aff *isl_aff_scale(__isl_take isl_aff *aff, isl_int f);
+__isl_give isl_aff *isl_aff_scale_down(__isl_take isl_aff *aff, isl_int f);
+__isl_give isl_aff *isl_aff_scale_down_ui(__isl_take isl_aff *aff, unsigned f);
+
+__isl_give isl_aff *isl_aff_insert_dims(__isl_take isl_aff *aff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_aff *isl_aff_add_dims(__isl_take isl_aff *aff,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_aff *isl_aff_drop_dims(__isl_take isl_aff *aff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_aff *isl_aff_project_domain_on_params(__isl_take isl_aff *aff);
+
+__isl_give isl_aff *isl_aff_align_params(__isl_take isl_aff *aff,
+	__isl_take isl_space *model);
+
+__isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
+	__isl_take isl_set *context);
+__isl_give isl_aff *isl_aff_gist_params(__isl_take isl_aff *aff,
+	__isl_take isl_set *context);
+
+__isl_give isl_aff *isl_aff_pullback_multi_aff(__isl_take isl_aff *aff,
+	__isl_take isl_multi_aff *ma);
+
+__isl_give isl_basic_set *isl_aff_zero_basic_set(__isl_take isl_aff *aff);
+__isl_give isl_basic_set *isl_aff_neg_basic_set(__isl_take isl_aff *aff);
+
+__isl_give isl_basic_set *isl_aff_le_basic_set(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+__isl_give isl_basic_set *isl_aff_ge_basic_set(__isl_take isl_aff *aff1,
+	__isl_take isl_aff *aff2);
+
+__isl_give isl_aff *isl_aff_read_from_str(isl_ctx *ctx, const char *str);
+__isl_give isl_printer *isl_printer_print_aff(__isl_take isl_printer *p,
+	__isl_keep isl_aff *aff);
+void isl_aff_dump(__isl_keep isl_aff *aff);
+
+isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff);
+__isl_give isl_space *isl_pw_aff_get_domain_space(__isl_keep isl_pw_aff *pwaff);
+__isl_give isl_space *isl_pw_aff_get_space(__isl_keep isl_pw_aff *pwaff);
+
+__isl_give isl_pw_aff *isl_pw_aff_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_pw_aff *isl_pw_aff_empty(__isl_take isl_space *dim);
+__isl_give isl_pw_aff *isl_pw_aff_alloc(__isl_take isl_set *set,
+	__isl_take isl_aff *aff);
+__isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(
+	__isl_take isl_local_space *ls);
+__isl_give isl_pw_aff *isl_pw_aff_var_on_domain(__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+
+__isl_give isl_pw_aff *isl_set_indicator_function(__isl_take isl_set *set);
+
+const char *isl_pw_aff_get_dim_name(__isl_keep isl_pw_aff *pa,
+	enum isl_dim_type type, unsigned pos);
+int isl_pw_aff_has_dim_id(__isl_keep isl_pw_aff *pa,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_pw_aff_get_dim_id(__isl_keep isl_pw_aff *pa,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_pw_aff *isl_pw_aff_set_dim_id(__isl_take isl_pw_aff *pma,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+
+int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
+int isl_pw_aff_plain_is_equal(__isl_keep isl_pw_aff *pwaff1,
+	__isl_keep isl_pw_aff *pwaff2);
+
+__isl_give isl_pw_aff *isl_pw_aff_union_min(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_union_max(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_union_add(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+
+__isl_give isl_pw_aff *isl_pw_aff_copy(__isl_keep isl_pw_aff *pwaff);
+void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff);
+
+unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff, enum isl_dim_type type);
+int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
+
+__isl_give isl_pw_aff *isl_pw_aff_align_params(__isl_take isl_pw_aff *pwaff,
+	__isl_take isl_space *model);
+
+__isl_give isl_id *isl_pw_aff_get_tuple_id(__isl_keep isl_pw_aff *pa,
+	enum isl_dim_type type);
+__isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(__isl_take isl_pw_aff *pwaff,
+	enum isl_dim_type type, __isl_take isl_id *id);
+
+__isl_give isl_set *isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff);
+
+__isl_give isl_pw_aff *isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_mul(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_div(__isl_take isl_pw_aff *pa1,
+	__isl_take isl_pw_aff *pa2);
+__isl_give isl_pw_aff *isl_pw_aff_add(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_sub(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_pw_aff *isl_pw_aff_neg(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_pw_aff *isl_pw_aff_floor(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_pw_aff *isl_pw_aff_mod(__isl_take isl_pw_aff *pwaff,
+	isl_int mod);
+__isl_give isl_pw_aff *isl_pw_aff_tdiv_q(__isl_take isl_pw_aff *pa1,
+	__isl_take isl_pw_aff *pa2);
+__isl_give isl_pw_aff *isl_pw_aff_tdiv_r(__isl_take isl_pw_aff *pa1,
+	__isl_take isl_pw_aff *pa2);
+
+__isl_give isl_pw_aff *isl_pw_aff_intersect_params(__isl_take isl_pw_aff *pa,
+	__isl_take isl_set *set);
+__isl_give isl_pw_aff *isl_pw_aff_intersect_domain(__isl_take isl_pw_aff *pa,
+	__isl_take isl_set *set);
+
+__isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_pw_aff *cond,
+	__isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false);
+
+__isl_give isl_pw_aff *isl_pw_aff_scale(__isl_take isl_pw_aff *pwaff,
+	isl_int f);
+__isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff,
+	isl_int f);
+
+__isl_give isl_pw_aff *isl_pw_aff_insert_dims(__isl_take isl_pw_aff *pwaff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_pw_aff *isl_pw_aff_add_dims(__isl_take isl_pw_aff *pwaff,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_pw_aff *isl_pw_aff_drop_dims(__isl_take isl_pw_aff *pwaff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_pw_aff *isl_pw_aff_coalesce(__isl_take isl_pw_aff *pwqp);
+__isl_give isl_pw_aff *isl_pw_aff_gist(__isl_take isl_pw_aff *pwaff,
+	__isl_take isl_set *context);
+__isl_give isl_pw_aff *isl_pw_aff_gist_params(__isl_take isl_pw_aff *pwaff,
+	__isl_take isl_set *context);
+
+__isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
+	__isl_take isl_pw_aff *pa, __isl_take isl_multi_aff *ma);
+__isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
+	__isl_take isl_pw_aff *pa, __isl_take isl_pw_multi_aff *pma);
+
+int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff);
+int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_aff *aff,
+		    void *user), void *user);
+
+__isl_give isl_set *isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff);
+
+__isl_give isl_set *isl_pw_aff_nonneg_set(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_set *isl_pw_aff_zero_set(__isl_take isl_pw_aff *pwaff);
+__isl_give isl_set *isl_pw_aff_non_zero_set(__isl_take isl_pw_aff *pwaff);
+
+__isl_give isl_set *isl_pw_aff_eq_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_set *isl_pw_aff_ne_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_set *isl_pw_aff_le_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_set *isl_pw_aff_ge_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+__isl_give isl_set *isl_pw_aff_gt_set(__isl_take isl_pw_aff *pwaff1,
+	__isl_take isl_pw_aff *pwaff2);
+
+__isl_give isl_pw_aff *isl_pw_aff_read_from_str(isl_ctx *ctx, const char *str);
+__isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p,
+	__isl_keep isl_pw_aff *pwaff);
+void isl_pw_aff_dump(__isl_keep isl_pw_aff *pwaff);
+
+__isl_give isl_pw_aff *isl_pw_aff_list_min(__isl_take isl_pw_aff_list *list);
+__isl_give isl_pw_aff *isl_pw_aff_list_max(__isl_take isl_pw_aff_list *list);
+
+__isl_give isl_set *isl_pw_aff_list_eq_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+__isl_give isl_set *isl_pw_aff_list_ne_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+__isl_give isl_set *isl_pw_aff_list_le_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+__isl_give isl_set *isl_pw_aff_list_lt_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+__isl_give isl_set *isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+__isl_give isl_set *isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1,
+	__isl_take isl_pw_aff_list *list2);
+
+__isl_give isl_multi_aff *isl_multi_aff_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_multi_aff *isl_multi_aff_zero(__isl_take isl_space *space);
+__isl_give isl_multi_aff *isl_multi_aff_identity(__isl_take isl_space *space);
+
+isl_ctx *isl_multi_aff_get_ctx(__isl_keep isl_multi_aff *maff);
+__isl_give isl_space *isl_multi_aff_get_space(__isl_keep isl_multi_aff *maff);
+__isl_give isl_space *isl_multi_aff_get_domain_space(
+	__isl_keep isl_multi_aff *maff);
+__isl_give isl_multi_aff *isl_multi_aff_set_tuple_name(
+	__isl_take isl_multi_aff *maff,
+	enum isl_dim_type type, const char *s);
+__isl_give isl_multi_aff *isl_multi_aff_set_tuple_id(
+	__isl_take isl_multi_aff *maff,
+	enum isl_dim_type type, __isl_take isl_id *id);
+__isl_give isl_multi_aff *isl_multi_aff_copy(__isl_keep isl_multi_aff *maff);
+void *isl_multi_aff_free(__isl_take isl_multi_aff *maff);
+
+unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff,
+	enum isl_dim_type type);
+__isl_give isl_aff *isl_multi_aff_get_aff(__isl_keep isl_multi_aff *multi,
+	int pos);
+
+__isl_give isl_multi_aff *isl_multi_aff_insert_dims(
+	__isl_take isl_multi_aff *ma,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_multi_aff *isl_multi_aff_add_dims(__isl_take isl_multi_aff *ma,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_multi_aff *isl_multi_aff_drop_dims(
+	__isl_take isl_multi_aff *maff,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_multi_aff *isl_multi_aff_set_dim_name(
+	__isl_take isl_multi_aff *maff,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+int isl_multi_aff_plain_is_equal(__isl_keep isl_multi_aff *maff1,
+	__isl_keep isl_multi_aff *maff2);
+
+__isl_give isl_multi_aff *isl_multi_aff_add(__isl_take isl_multi_aff *maff1,
+	__isl_take isl_multi_aff *maff2);
+
+__isl_give isl_multi_aff *isl_multi_aff_scale(__isl_take isl_multi_aff *maff,
+	isl_int f);
+
+__isl_give isl_multi_aff *isl_multi_aff_range_splice(
+	__isl_take isl_multi_aff *ma1, unsigned pos,
+	__isl_take isl_multi_aff *ma2);
+__isl_give isl_multi_aff *isl_multi_aff_splice(
+	__isl_take isl_multi_aff *ma1, unsigned in_pos, unsigned out_pos,
+	__isl_take isl_multi_aff *ma2);
+__isl_give isl_multi_aff *isl_multi_aff_range_product(
+	__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
+__isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
+	__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
+__isl_give isl_multi_aff *isl_multi_aff_product(
+	__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
+
+__isl_give isl_multi_aff *isl_multi_aff_align_params(
+	__isl_take isl_multi_aff *multi, __isl_take isl_space *model);
+
+__isl_give isl_multi_aff *isl_multi_aff_gist_params(
+	__isl_take isl_multi_aff *maff, __isl_take isl_set *context);
+__isl_give isl_multi_aff *isl_multi_aff_gist(__isl_take isl_multi_aff *maff,
+	__isl_take isl_set *context);
+
+__isl_give isl_multi_aff *isl_multi_aff_lift(__isl_take isl_multi_aff *maff,
+	__isl_give isl_local_space **ls);
+
+__isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
+	__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2);
+
+__isl_give isl_set *isl_multi_aff_lex_le_set(__isl_take isl_multi_aff *ma1,
+	__isl_take isl_multi_aff *ma2);
+__isl_give isl_set *isl_multi_aff_lex_ge_set(__isl_take isl_multi_aff *ma1,
+	__isl_take isl_multi_aff *ma2);
+
+__isl_give isl_printer *isl_printer_print_multi_aff(__isl_take isl_printer *p,
+	__isl_keep isl_multi_aff *maff);
+
+__isl_give isl_multi_aff *isl_multi_aff_read_from_str(isl_ctx *ctx,
+		const char *str);
+void isl_multi_aff_dump(__isl_keep isl_multi_aff *maff);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity(
+	__isl_take isl_space *space);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_multi_aff(
+	__isl_take isl_multi_aff *ma);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(__isl_take isl_set *set,
+	__isl_take isl_multi_aff *maff);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy(
+	__isl_keep isl_pw_multi_aff *pma);
+void *isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma);
+
+unsigned isl_pw_multi_aff_dim(__isl_keep isl_pw_multi_aff *pma,
+	enum isl_dim_type type);
+__isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
+	__isl_keep isl_pw_multi_aff *pma, int pos);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff(
+	__isl_take isl_pw_multi_aff *pma, unsigned pos,
+	__isl_take isl_pw_aff *pa);
+
+isl_ctx *isl_pw_multi_aff_get_ctx(__isl_keep isl_pw_multi_aff *pma);
+__isl_give isl_space *isl_pw_multi_aff_get_domain_space(
+	__isl_keep isl_pw_multi_aff *pma);
+__isl_give isl_space *isl_pw_multi_aff_get_space(
+	__isl_keep isl_pw_multi_aff *pma);
+int isl_pw_multi_aff_has_tuple_name(__isl_keep isl_pw_multi_aff *pma,
+	enum isl_dim_type type);
+const char *isl_pw_multi_aff_get_tuple_name(__isl_keep isl_pw_multi_aff *pma,
+	enum isl_dim_type type);
+__isl_give isl_id *isl_pw_multi_aff_get_tuple_id(
+	__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type);
+int isl_pw_multi_aff_has_tuple_id(__isl_keep isl_pw_multi_aff *pma,
+	enum isl_dim_type type);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_tuple_id(
+	__isl_take isl_pw_multi_aff *pma,
+	enum isl_dim_type type, __isl_take isl_id *id);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
+	__isl_take isl_pw_multi_aff *pma,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_set *isl_pw_multi_aff_domain(__isl_take isl_pw_multi_aff *pma);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty(__isl_take isl_space *space);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
+	__isl_take isl_set *set);
+
+const char *isl_pw_multi_aff_get_dim_name(__isl_keep isl_pw_multi_aff *pma,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_pw_multi_aff_get_dim_id(
+	__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type,
+	unsigned pos);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_dim_id(
+	__isl_take isl_pw_multi_aff *pma,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+
+int isl_pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma1,
+	__isl_keep isl_pw_multi_aff *pma2);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
+	__isl_take isl_pw_multi_aff *pma1,
+	__isl_take isl_pw_multi_aff *pma2);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
+	__isl_take isl_pw_multi_aff *pma1,
+	__isl_take isl_pw_multi_aff *pma2);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_range_product(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_flat_range_product(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_project_domain_on_params(
+	__isl_take isl_pw_multi_aff *pma);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_space *model);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
+	__isl_take isl_pw_multi_aff *pma);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_pullback_multi_aff(
+	__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_aff *ma);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_pullback_pw_multi_aff(
+	__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2);
+
+int isl_pw_multi_aff_foreach_piece(__isl_keep isl_pw_multi_aff *pma,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_multi_aff *maff,
+		    void *user), void *user);
+
+__isl_give isl_map *isl_map_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma);
+__isl_give isl_set *isl_set_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma);
+
+__isl_give isl_printer *isl_printer_print_pw_multi_aff(__isl_take isl_printer *p,
+	__isl_keep isl_pw_multi_aff *pma);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(__isl_take isl_set *set);
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(__isl_take isl_map *map);
+
+__isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(isl_ctx *ctx,
+	const char *str);
+void isl_pw_multi_aff_dump(__isl_keep isl_pw_multi_aff *pma);
+
+
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_empty(
+	__isl_take isl_space *space);
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_domain(
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_copy(
+	__isl_keep isl_union_pw_multi_aff *upma);
+void *isl_union_pw_multi_aff_free(__isl_take isl_union_pw_multi_aff *upma);
+
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add_pw_multi_aff(
+	__isl_take isl_union_pw_multi_aff *upma,
+	__isl_take isl_pw_multi_aff *pma);
+
+isl_ctx *isl_union_pw_multi_aff_get_ctx(
+	__isl_keep isl_union_pw_multi_aff *upma);
+__isl_give isl_space *isl_union_pw_multi_aff_get_space(
+	__isl_keep isl_union_pw_multi_aff *upma);
+
+int isl_union_pw_multi_aff_foreach_pw_multi_aff(
+	__isl_keep isl_union_pw_multi_aff *upma,
+	int (*fn)(__isl_take isl_pw_multi_aff *pma, void *user), void *user);
+
+__isl_give isl_union_set *isl_union_pw_multi_aff_domain(
+	__isl_take isl_union_pw_multi_aff *upma);
+
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
+	__isl_take isl_union_pw_multi_aff *upma1,
+	__isl_take isl_union_pw_multi_aff *upma2);
+
+__isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_flat_range_product(
+	__isl_take isl_union_pw_multi_aff *upma1,
+	__isl_take isl_union_pw_multi_aff *upma2);
+
+__isl_give isl_union_map *isl_union_map_from_union_pw_multi_aff(
+	__isl_take isl_union_pw_multi_aff *upma);
+
+__isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
+	__isl_take isl_printer *p, __isl_keep isl_union_pw_multi_aff *upma);
+
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(__isl_take isl_space *space);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity(
+	__isl_take isl_space *space);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff(
+	__isl_take isl_pw_aff *pa);
+
+isl_ctx *isl_multi_pw_aff_get_ctx(__isl_keep isl_multi_pw_aff *mpa);
+__isl_give isl_space *isl_multi_pw_aff_get_space(
+	__isl_keep isl_multi_pw_aff *mpa);
+__isl_give isl_space *isl_multi_pw_aff_get_domain_space(
+	__isl_keep isl_multi_pw_aff *mpa);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_set_tuple_name(
+	__isl_take isl_multi_pw_aff *mpa,
+	enum isl_dim_type type, const char *s);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy(
+	__isl_keep isl_multi_pw_aff *mpa);
+void *isl_multi_pw_aff_free(__isl_take isl_multi_pw_aff *mpa);
+
+unsigned isl_multi_pw_aff_dim(__isl_keep isl_multi_pw_aff *mpa,
+	enum isl_dim_type type);
+__isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff(
+	__isl_keep isl_multi_pw_aff *mpa, int pos);
+
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
+	__isl_take isl_multi_pw_aff *mpa,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
+	__isl_take isl_multi_pw_aff *mpa, enum isl_dim_type type, unsigned n);
+
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_set_dim_name(
+	__isl_take isl_multi_pw_aff *mpa,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_range_splice(
+	__isl_take isl_multi_pw_aff *mpa1, unsigned pos,
+	__isl_take isl_multi_pw_aff *mpa2);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
+	__isl_take isl_multi_pw_aff *mpa1, unsigned in_pos, unsigned out_pos,
+	__isl_take isl_multi_pw_aff *mpa2);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_flat_range_product(
+	__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2);
+__isl_give isl_multi_pw_aff *isl_multi_pw_aff_range_product(
+	__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2);
+
+__isl_give isl_printer *isl_printer_print_multi_pw_aff(
+	__isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa);
+void isl_multi_pw_aff_dump(__isl_keep isl_multi_pw_aff *mpa);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/aff_type.h b/include/isl/aff_type.h
new file mode 100644
index 0000000..e5308c7
--- /dev/null
+++ b/include/isl/aff_type.h
@@ -0,0 +1,22 @@
+#ifndef ISL_AFF_TYPE_H
+#define ISL_AFF_TYPE_H
+
+struct isl_aff;
+typedef struct isl_aff isl_aff;
+
+struct isl_pw_aff;
+typedef struct isl_pw_aff isl_pw_aff;
+
+struct isl_multi_aff;
+typedef struct isl_multi_aff isl_multi_aff;
+
+struct isl_pw_multi_aff;
+typedef struct isl_pw_multi_aff isl_pw_multi_aff;
+
+struct isl_union_pw_multi_aff;
+typedef struct isl_union_pw_multi_aff isl_union_pw_multi_aff;
+
+struct isl_multi_pw_aff;
+typedef struct isl_multi_pw_aff isl_multi_pw_aff;
+
+#endif
diff --git a/include/isl/arg.h b/include/isl/arg.h
new file mode 100644
index 0000000..07ee44c
--- /dev/null
+++ b/include/isl/arg.h
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_ARG_H
+#define ISL_ARG_H
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_arg_choice {
+	const char	*name;
+	unsigned	 value;
+};
+
+struct isl_arg_flags {
+	const char	*name;
+	unsigned	 mask;
+	unsigned	 value;
+};
+
+enum isl_arg_type {
+	isl_arg_end,
+	isl_arg_alias,
+	isl_arg_arg,
+	isl_arg_bool,
+	isl_arg_child,
+	isl_arg_choice,
+	isl_arg_flags,
+	isl_arg_footer,
+	isl_arg_int,
+	isl_arg_user,
+	isl_arg_long,
+	isl_arg_ulong,
+	isl_arg_str,
+	isl_arg_str_list,
+	isl_arg_version
+};
+
+struct isl_args;
+
+struct isl_arg {
+	enum isl_arg_type	 type;
+	char			 short_name;
+	const char		*long_name;
+	const char		*argument_name;
+	size_t			 offset;
+	const char		*help_msg;
+#define ISL_ARG_SINGLE_DASH	(1 << 0)
+#define ISL_ARG_BOOL_ARG	(1 << 1)
+#define ISL_ARG_HIDDEN		(1 << 2)
+	unsigned		 flags;
+	union {
+	struct {
+		struct isl_arg_choice	*choice;
+		unsigned	 	 default_value;
+		unsigned	 	 default_selected;
+		int (*set)(void *opt, unsigned val);
+	} choice;
+	struct {
+		struct isl_arg_flags	*flags;
+		unsigned	 	 default_value;
+	} flags;
+	struct {
+		unsigned		 default_value;
+		int (*set)(void *opt, unsigned val);
+	} b;
+	struct {
+		int			default_value;
+	} i;
+	struct {
+		long		 	default_value;
+		long		 	default_selected;
+		int (*set)(void *opt, long val);
+	} l;
+	struct {
+		unsigned long		default_value;
+	} ul;
+	struct {
+		const char		*default_value;
+	} str;
+	struct {
+		size_t			 offset_n;
+	} str_list;
+	struct {
+		struct isl_args		*child;
+	} child;
+	struct {
+		void (*print_version)(void);
+	} version;
+	struct {
+		int (*init)(void*);
+		void (*clear)(void*);
+	} user;
+	} u;
+};
+
+struct isl_args {
+	size_t			 options_size;
+	struct isl_arg		*args;
+};
+
+#define ISL_ARGS_START(s,name)						\
+	struct isl_arg name ## LIST[];					\
+	struct isl_args name = { sizeof(s), name ## LIST };		\
+	struct isl_arg name ## LIST[] = {
+#define ISL_ARGS_END							\
+	{ isl_arg_end } };
+
+#define ISL_ARG_ALIAS(l)	{					\
+	.type = isl_arg_alias,						\
+	.long_name = l,							\
+},
+#define ISL_ARG_ARG(st,f,a,d)	{					\
+	.type = isl_arg_arg,						\
+	.argument_name = a,						\
+	.offset = offsetof(st, f),					\
+	.u = { .str = { .default_value = d } }				\
+},
+#define ISL_ARG_FOOTER(h)	{					\
+	.type = isl_arg_footer,						\
+	.help_msg = h,							\
+},
+#define ISL_ARG_CHOICE(st,f,s,l,c,d,h)	{				\
+	.type = isl_arg_choice,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .choice = { .choice = c, .default_value = d,		\
+			    .default_selected = d, .set = NULL } }	\
+},
+#define ISL_ARG_OPT_CHOICE(st,f,s,l,c,d,ds,h)	{			\
+	.type = isl_arg_choice,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .choice = { .choice = c, .default_value = d,		\
+			    .default_selected = ds, .set = NULL } }	\
+},
+#define ISL_ARG_USER_OPT_CHOICE(st,f,s,l,c,setter,d,ds,h)	{	\
+	.type = isl_arg_choice,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .choice = { .choice = c, .default_value = d,		\
+			    .default_selected = ds, .set = setter } }	\
+},
+#define _ISL_ARG_BOOL_F(o,s,l,setter,d,h,fl)	{			\
+	.type = isl_arg_bool,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = o,							\
+	.help_msg = h,							\
+	.flags = fl,							\
+	.u = { .b = { .default_value = d, .set = setter } }		\
+},
+#define ISL_ARG_BOOL_F(st,f,s,l,d,h,fl)					\
+	_ISL_ARG_BOOL_F(offsetof(st, f),s,l,NULL,d,h,fl)
+#define ISL_ARG_BOOL(st,f,s,l,d,h)					\
+	ISL_ARG_BOOL_F(st,f,s,l,d,h,0)
+#define ISL_ARG_PHANTOM_BOOL_F(s,l,setter,h,fl)				\
+	_ISL_ARG_BOOL_F(-1,s,l,setter,0,h,fl)
+#define ISL_ARG_PHANTOM_BOOL(s,l,setter,h)				\
+	ISL_ARG_PHANTOM_BOOL_F(s,l,setter,h,0)
+#define ISL_ARG_INT_F(st,f,s,l,a,d,h,fl)	{			\
+	.type = isl_arg_int,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.argument_name = a,						\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.flags = fl,							\
+	.u = { .ul = { .default_value = d } }				\
+},
+#define ISL_ARG_INT(st,f,s,l,a,d,h)					\
+	ISL_ARG_INT_F(st,f,s,l,a,d,h,0)
+#define ISL_ARG_LONG(st,f,s,lo,d,h)	{				\
+	.type = isl_arg_long,						\
+	.short_name = s,						\
+	.long_name = lo,						\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .l = { .default_value = d, .default_selected = d,	\
+		      .set = NULL } }					\
+},
+#define ISL_ARG_USER_LONG(st,f,s,lo,setter,d,h)	{			\
+	.type = isl_arg_long,						\
+	.short_name = s,						\
+	.long_name = lo,						\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .l = { .default_value = d, .default_selected = d,	\
+		      .set = setter } }					\
+},
+#define ISL_ARG_OPT_LONG(st,f,s,lo,d,ds,h)	{			\
+	.type = isl_arg_long,						\
+	.short_name = s,						\
+	.long_name = lo,						\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .l = { .default_value = d, .default_selected = ds,	\
+		      .set = NULL } }					\
+},
+#define ISL_ARG_ULONG(st,f,s,l,d,h)	{				\
+	.type = isl_arg_ulong,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .ul = { .default_value = d } }				\
+},
+#define ISL_ARG_STR_F(st,f,s,l,a,d,h,fl)	{			\
+	.type = isl_arg_str,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.argument_name = a,						\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.flags = fl,							\
+	.u = { .str = { .default_value = d } }				\
+},
+#define ISL_ARG_STR(st,f,s,l,a,d,h)					\
+	ISL_ARG_STR_F(st,f,s,l,a,d,h,0)
+#define ISL_ARG_STR_LIST(st,f_n,f_l,s,l,a,h)	{			\
+	.type = isl_arg_str_list,					\
+	.short_name = s,						\
+	.long_name = l,							\
+	.argument_name = a,						\
+	.offset = offsetof(st, f_l),					\
+	.help_msg = h,							\
+	.u = { .str_list = { .offset_n = offsetof(st, f_n) } }		\
+},
+#define _ISL_ARG_CHILD(o,l,c,h,fl)	{				\
+	.type = isl_arg_child,						\
+	.long_name = l,							\
+	.offset = o,							\
+	.help_msg = h,							\
+	.flags = fl,							\
+	.u = { .child = { .child = c } }				\
+},
+#define ISL_ARG_CHILD(st,f,l,c,h)					\
+	_ISL_ARG_CHILD(offsetof(st, f),l,c,h,0)
+#define ISL_ARG_GROUP_F(c,h,fl)						\
+	_ISL_ARG_CHILD(-1,NULL,c,h,fl)
+#define ISL_ARG_GROUP(c,h)						\
+	ISL_ARG_GROUP_F(c,h,0)
+#define ISL_ARG_FLAGS(st,f,s,l,c,d,h)	{				\
+	.type = isl_arg_flags,						\
+	.short_name = s,						\
+	.long_name = l,							\
+	.offset = offsetof(st, f),					\
+	.help_msg = h,							\
+	.u = { .flags = { .flags = c, .default_value = d } }		\
+},
+#define ISL_ARG_USER(st,f,i,c) {					\
+	.type = isl_arg_user,						\
+	.offset = offsetof(st, f),					\
+	.u = { .user = { .init = i, .clear = c} }			\
+},
+#define ISL_ARG_VERSION(print) {					\
+	.type = isl_arg_version,					\
+	.u = { .version = { .print_version = print } }			\
+},
+
+#define ISL_ARG_ALL		(1 << 0)
+#define ISL_ARG_SKIP_HELP	(1 << 1)
+
+void isl_args_set_defaults(struct isl_args *args, void *opt);
+void isl_args_free(struct isl_args *args, void *opt);
+int isl_args_parse(struct isl_args *args, int argc, char **argv, void *opt,
+	unsigned flags);
+
+#define ISL_ARG_DECL(prefix,st,args)					\
+extern struct isl_args args;						\
+st *prefix ## _new_with_defaults(void);					\
+void prefix ## _free(st *opt);						\
+int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags);
+
+#define ISL_ARG_DEF(prefix,st,args)					\
+st *prefix ## _new_with_defaults()					\
+{									\
+	st *opt = (st *)calloc(1, sizeof(st));				\
+	if (opt)							\
+		isl_args_set_defaults(&(args), opt);			\
+	return opt;							\
+}									\
+									\
+void prefix ## _free(st *opt)						\
+{									\
+	isl_args_free(&(args), opt);					\
+}									\
+									\
+int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags)	\
+{									\
+	return isl_args_parse(&(args), argc, argv, opt, flags);		\
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/ast.h b/include/isl/ast.h
new file mode 100644
index 0000000..76fe450
--- /dev/null
+++ b/include/isl/ast.h
@@ -0,0 +1,183 @@
+#ifndef ISL_AST_H
+#define ISL_AST_H
+
+#include <isl/ctx.h>
+#include <isl/id.h>
+#include <isl/list.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_ast_expr;
+typedef struct isl_ast_expr isl_ast_expr;
+
+struct isl_ast_node;
+typedef struct isl_ast_node isl_ast_node;
+
+enum isl_ast_op_type {
+	isl_ast_op_error = -1,
+	isl_ast_op_and,
+	isl_ast_op_and_then,
+	isl_ast_op_or,
+	isl_ast_op_or_else,
+	isl_ast_op_max,
+	isl_ast_op_min,
+	isl_ast_op_minus,
+	isl_ast_op_add,
+	isl_ast_op_sub,
+	isl_ast_op_mul,
+	isl_ast_op_div,
+	isl_ast_op_fdiv_q,	/* Round towards -infty */
+	isl_ast_op_pdiv_q,	/* Dividend is non-negative */
+	isl_ast_op_pdiv_r,	/* Dividend is non-negative */
+	isl_ast_op_cond,
+	isl_ast_op_select,
+	isl_ast_op_eq,
+	isl_ast_op_le,
+	isl_ast_op_lt,
+	isl_ast_op_ge,
+	isl_ast_op_gt,
+	isl_ast_op_call
+};
+
+enum isl_ast_expr_type {
+	isl_ast_expr_error = -1,
+	isl_ast_expr_op,
+	isl_ast_expr_id,
+	isl_ast_expr_int
+};
+
+enum isl_ast_node_type {
+	isl_ast_node_error = -1,
+	isl_ast_node_for = 1,
+	isl_ast_node_if,
+	isl_ast_node_block,
+	isl_ast_node_user
+};
+
+struct isl_ast_print_options;
+typedef struct isl_ast_print_options isl_ast_print_options;
+
+ISL_DECLARE_LIST(ast_expr)
+ISL_DECLARE_LIST(ast_node)
+
+int isl_options_set_ast_iterator_type(isl_ctx *ctx, const char *val);
+const char *isl_options_get_ast_iterator_type(isl_ctx *ctx);
+
+__isl_give isl_ast_expr *isl_ast_expr_from_id(__isl_take isl_id *id);
+__isl_give isl_ast_expr *isl_ast_expr_neg(__isl_take isl_ast_expr *expr);
+__isl_give isl_ast_expr *isl_ast_expr_add(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+__isl_give isl_ast_expr *isl_ast_expr_sub(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+__isl_give isl_ast_expr *isl_ast_expr_mul(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+__isl_give isl_ast_expr *isl_ast_expr_div(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+__isl_give isl_ast_expr *isl_ast_expr_and(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+__isl_give isl_ast_expr *isl_ast_expr_or(__isl_take isl_ast_expr *expr1,
+	__isl_take isl_ast_expr *expr2);
+
+__isl_give isl_ast_expr *isl_ast_expr_copy(__isl_keep isl_ast_expr *expr);
+void *isl_ast_expr_free(__isl_take isl_ast_expr *expr);
+
+isl_ctx *isl_ast_expr_get_ctx(__isl_keep isl_ast_expr *expr);
+enum isl_ast_expr_type isl_ast_expr_get_type(__isl_keep isl_ast_expr *expr);
+int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr, isl_int *v);
+__isl_give isl_id *isl_ast_expr_get_id(__isl_keep isl_ast_expr *expr);
+
+enum isl_ast_op_type isl_ast_expr_get_op_type(__isl_keep isl_ast_expr *expr);
+int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
+__isl_give isl_ast_expr *isl_ast_expr_get_op_arg(__isl_keep isl_ast_expr *expr,
+	int pos);
+
+__isl_give isl_printer *isl_printer_print_ast_expr(__isl_take isl_printer *p,
+	__isl_keep isl_ast_expr *expr);
+void isl_ast_expr_dump(__isl_keep isl_ast_expr *expr);
+__isl_give char *isl_ast_expr_to_str(__isl_keep isl_ast_expr *expr);
+
+__isl_give isl_ast_node *isl_ast_node_alloc_user(__isl_take isl_ast_expr *expr);
+__isl_give isl_ast_node *isl_ast_node_copy(__isl_keep isl_ast_node *node);
+void *isl_ast_node_free(__isl_take isl_ast_node *node);
+
+isl_ctx *isl_ast_node_get_ctx(__isl_keep isl_ast_node *node);
+enum isl_ast_node_type isl_ast_node_get_type(__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_node *isl_ast_node_set_annotation(
+	__isl_take isl_ast_node *node, __isl_take isl_id *annotation);
+__isl_give isl_id *isl_ast_node_get_annotation(__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
+	__isl_keep isl_ast_node *node);
+__isl_give isl_ast_expr *isl_ast_node_for_get_init(
+	__isl_keep isl_ast_node *node);
+__isl_give isl_ast_expr *isl_ast_node_for_get_cond(
+	__isl_keep isl_ast_node *node);
+__isl_give isl_ast_expr *isl_ast_node_for_get_inc(
+	__isl_keep isl_ast_node *node);
+__isl_give isl_ast_node *isl_ast_node_for_get_body(
+	__isl_keep isl_ast_node *node);
+int isl_ast_node_for_is_degenerate(__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_expr *isl_ast_node_if_get_cond(
+	__isl_keep isl_ast_node *node);
+__isl_give isl_ast_node *isl_ast_node_if_get_then(
+	__isl_keep isl_ast_node *node);
+int isl_ast_node_if_has_else(__isl_keep isl_ast_node *node);
+__isl_give isl_ast_node *isl_ast_node_if_get_else(
+	__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_node_list *isl_ast_node_block_get_children(
+	__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_expr *isl_ast_node_user_get_expr(
+	__isl_keep isl_ast_node *node);
+
+__isl_give isl_printer *isl_printer_print_ast_node(__isl_take isl_printer *p,
+	__isl_keep isl_ast_node *node);
+void isl_ast_node_dump(__isl_keep isl_ast_node *node);
+
+__isl_give isl_ast_print_options *isl_ast_print_options_alloc(isl_ctx *ctx);
+__isl_give isl_ast_print_options *isl_ast_print_options_copy(
+	__isl_keep isl_ast_print_options *options);
+void *isl_ast_print_options_free(__isl_take isl_ast_print_options *options);
+isl_ctx *isl_ast_print_options_get_ctx(
+	__isl_keep isl_ast_print_options *options);
+
+__isl_give isl_ast_print_options *isl_ast_print_options_set_print_user(
+	__isl_take isl_ast_print_options *options,
+	__isl_give isl_printer *(*print_user)(__isl_take isl_printer *p,
+		__isl_take isl_ast_print_options *options,
+		__isl_keep isl_ast_node *node, void *user),
+	void *user);
+__isl_give isl_ast_print_options *isl_ast_print_options_set_print_for(
+	__isl_take isl_ast_print_options *options,
+	__isl_give isl_printer *(*print_for)(__isl_take isl_printer *p,
+		__isl_take isl_ast_print_options *options,
+		__isl_keep isl_ast_node *node, void *user),
+	void *user);
+
+int isl_ast_node_foreach_ast_op_type(__isl_keep isl_ast_node *node,
+	int (*fn)(enum isl_ast_op_type type, void *user), void *user);
+__isl_give isl_printer *isl_ast_op_type_print_macro(
+	enum isl_ast_op_type type, __isl_take isl_printer *p);
+__isl_give isl_printer *isl_ast_node_print_macros(
+	__isl_keep isl_ast_node *node, __isl_take isl_printer *p);
+__isl_give isl_printer *isl_ast_node_print(__isl_keep isl_ast_node *node,
+	__isl_take isl_printer *p,
+	__isl_take isl_ast_print_options *options);
+__isl_give isl_printer *isl_ast_node_for_print(__isl_keep isl_ast_node *node,
+	__isl_take isl_printer *p,
+	__isl_take isl_ast_print_options *options);
+__isl_give isl_printer *isl_ast_node_if_print(__isl_keep isl_ast_node *node,
+	__isl_take isl_printer *p,
+	__isl_take isl_ast_print_options *options);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/ast_build.h b/include/isl/ast_build.h
new file mode 100644
index 0000000..7294ed7
--- /dev/null
+++ b/include/isl/ast_build.h
@@ -0,0 +1,90 @@
+#ifndef ISL_AST_CONTEXT_H
+#define ISL_AST_CONTEXT_H
+
+#include <isl/ctx.h>
+#include <isl/set.h>
+#include <isl/ast.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_ast_build;
+typedef struct isl_ast_build isl_ast_build;
+
+
+int isl_options_set_ast_build_atomic_upper_bound(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_atomic_upper_bound(isl_ctx *ctx);
+
+int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
+
+int isl_options_set_ast_build_exploit_nested_bounds(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_exploit_nested_bounds(isl_ctx *ctx);
+
+int isl_options_set_ast_build_group_coscheduled(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_group_coscheduled(isl_ctx *ctx);
+
+#define ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT		0
+#define ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT		1
+int isl_options_set_ast_build_separation_bounds(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_separation_bounds(isl_ctx *ctx);
+
+int isl_options_set_ast_build_scale_strides(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_scale_strides(isl_ctx *ctx);
+
+int isl_options_set_ast_build_allow_else(isl_ctx *ctx, int val);
+int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
+
+isl_ctx *isl_ast_build_get_ctx(__isl_keep isl_ast_build *build);
+
+__isl_give isl_ast_build *isl_ast_build_from_context(__isl_take isl_set *set);
+
+__isl_give isl_space *isl_ast_build_get_schedule_space(
+	__isl_keep isl_ast_build *build);
+__isl_give isl_union_map *isl_ast_build_get_schedule(
+	__isl_keep isl_ast_build *build);
+
+__isl_give isl_ast_build *isl_ast_build_restrict(
+	__isl_take isl_ast_build *build, __isl_take isl_set *set);
+
+__isl_give isl_ast_build *isl_ast_build_copy(
+	__isl_keep isl_ast_build *build);
+void *isl_ast_build_free(__isl_take isl_ast_build *build);
+
+__isl_give isl_ast_build *isl_ast_build_set_options(
+	__isl_take isl_ast_build *build,
+	__isl_take isl_union_map *options);
+__isl_give isl_ast_build *isl_ast_build_set_iterators(
+	__isl_take isl_ast_build *build,
+	__isl_take isl_id_list *iterators);
+__isl_give isl_ast_build *isl_ast_build_set_at_each_domain(
+	__isl_take isl_ast_build *build,
+	__isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node,
+		__isl_keep isl_ast_build *build, void *user), void *user);
+__isl_give isl_ast_build *isl_ast_build_set_before_each_for(
+	__isl_take isl_ast_build *build,
+	__isl_give isl_id *(*fn)(__isl_keep isl_ast_build *build,
+		void *user), void *user);
+__isl_give isl_ast_build *isl_ast_build_set_after_each_for(
+	__isl_take isl_ast_build *build,
+	__isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node,
+		__isl_keep isl_ast_build *build, void *user), void *user);
+__isl_give isl_ast_build *isl_ast_build_set_create_leaf(
+	__isl_take isl_ast_build *build,
+	__isl_give isl_ast_node *(*fn)(__isl_take isl_ast_build *build,
+		void *user), void *user);
+
+__isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
+	__isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa);
+__isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff(
+	__isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma);
+
+__isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
+	__isl_keep isl_ast_build *build, __isl_take isl_union_map *schedule);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/band.h b/include/isl/band.h
new file mode 100644
index 0000000..e7bf51c
--- /dev/null
+++ b/include/isl/band.h
@@ -0,0 +1,51 @@
+#ifndef ISL_BAND_H
+#define ISL_BAND_H
+
+#include <isl/printer.h>
+#include <isl/list.h>
+#include <isl/union_map_type.h>
+#include <isl/vec.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_band;
+typedef struct isl_band isl_band;
+
+__isl_give isl_band *isl_band_copy(__isl_keep isl_band *band);
+void *isl_band_free(__isl_take isl_band *band);
+
+isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band);
+
+int isl_band_has_children(__isl_keep isl_band *band);
+__isl_give isl_band_list *isl_band_get_children(
+	__isl_keep isl_band *band);
+
+__isl_give isl_union_map *isl_band_get_prefix_schedule(
+	__isl_keep isl_band *band);
+__isl_give isl_union_map *isl_band_get_partial_schedule(
+	__isl_keep isl_band *band);
+__isl_give isl_union_map *isl_band_get_suffix_schedule(
+	__isl_keep isl_band *band);
+
+int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx, int val);
+int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
+
+int isl_band_tile(__isl_keep isl_band *band, __isl_take isl_vec *sizes);
+
+int isl_band_n_member(__isl_keep isl_band *band);
+int isl_band_member_is_zero_distance(__isl_keep isl_band *band, int pos);
+
+int isl_band_list_foreach_band(__isl_keep isl_band_list *list,
+	int (*fn)(__isl_keep isl_band *band, void *user), void *user);
+
+__isl_give isl_printer *isl_printer_print_band(__isl_take isl_printer *p,
+	__isl_keep isl_band *band);
+void isl_band_dump(__isl_keep isl_band *band);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/blk.h b/include/isl/blk.h
new file mode 100644
index 0000000..dcd8cf6
--- /dev/null
+++ b/include/isl/blk.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_BLK_H
+#define ISL_BLK_H
+
+#include <isl/int.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_blk {
+	size_t size;
+	isl_int *data;
+};
+
+#define ISL_BLK_CACHE_SIZE	20
+
+struct isl_ctx;
+
+struct isl_blk isl_blk_alloc(struct isl_ctx *ctx, size_t n);
+struct isl_blk isl_blk_empty(void);
+int isl_blk_is_error(struct isl_blk block);
+struct isl_blk isl_blk_extend(struct isl_ctx *ctx, struct isl_blk block,
+				size_t new_n);
+void isl_blk_free(struct isl_ctx *ctx, struct isl_blk block);
+void isl_blk_clear_cache(struct isl_ctx *ctx);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/config.h b/include/isl/config.h
new file mode 100644
index 0000000..2d69c26
--- /dev/null
+++ b/include/isl/config.h
@@ -0,0 +1,4 @@
+/* include/isl/config.h.  Generated from config.h.in by configure.  */
+#define GCC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+
+/* #undef ISL_PIPLIB */
diff --git a/include/isl/constraint.h b/include/isl/constraint.h
new file mode 100644
index 0000000..224e44d
--- /dev/null
+++ b/include/isl/constraint.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_CONSTRAINT_H
+#define ISL_CONSTRAINT_H
+
+#include <isl/local_space.h>
+#include <isl/space.h>
+#include <isl/aff_type.h>
+#include <isl/set_type.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_constraint;
+typedef struct isl_constraint isl_constraint;
+
+isl_ctx *isl_constraint_get_ctx(__isl_keep isl_constraint *c);
+
+__isl_give isl_constraint *isl_equality_alloc(__isl_take isl_local_space *ls);
+__isl_give isl_constraint *isl_inequality_alloc(__isl_take isl_local_space *ls);
+
+struct isl_constraint *isl_constraint_cow(struct isl_constraint *c);
+struct isl_constraint *isl_constraint_copy(struct isl_constraint *c);
+void *isl_constraint_free(__isl_take isl_constraint *c);
+
+int isl_basic_set_n_constraint(__isl_keep isl_basic_set *bset);
+int isl_basic_map_foreach_constraint(__isl_keep isl_basic_map *bmap,
+	int (*fn)(__isl_take isl_constraint *c, void *user), void *user);
+int isl_basic_set_foreach_constraint(__isl_keep isl_basic_set *bset,
+	int (*fn)(__isl_take isl_constraint *c, void *user), void *user);
+int isl_constraint_is_equal(struct isl_constraint *constraint1,
+			    struct isl_constraint *constraint2);
+
+int isl_basic_set_foreach_bound_pair(__isl_keep isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos,
+	int (*fn)(__isl_take isl_constraint *lower,
+		  __isl_take isl_constraint *upper,
+		  __isl_take isl_basic_set *bset, void *user), void *user);
+
+__isl_give isl_basic_map *isl_basic_map_add_constraint(
+	__isl_take isl_basic_map *bmap, __isl_take isl_constraint *constraint);
+__isl_give isl_basic_set *isl_basic_set_add_constraint(
+	__isl_take isl_basic_set *bset, __isl_take isl_constraint *constraint);
+__isl_give isl_map *isl_map_add_constraint(__isl_take isl_map *map,
+	__isl_take isl_constraint *constraint);
+__isl_give isl_set *isl_set_add_constraint(__isl_take isl_set *set,
+	__isl_take isl_constraint *constraint);
+
+int isl_basic_map_has_defining_equality(
+	__isl_keep isl_basic_map *bmap, enum isl_dim_type type, int pos,
+	__isl_give isl_constraint **c);
+int isl_basic_set_has_defining_equality(
+	struct isl_basic_set *bset, enum isl_dim_type type, int pos,
+	struct isl_constraint **constraint);
+int isl_basic_set_has_defining_inequalities(
+	struct isl_basic_set *bset, enum isl_dim_type type, int pos,
+	struct isl_constraint **lower,
+	struct isl_constraint **upper);
+
+__isl_give isl_space *isl_constraint_get_space(
+	__isl_keep isl_constraint *constraint);
+__isl_give isl_local_space *isl_constraint_get_local_space(
+	__isl_keep isl_constraint *constraint);
+int isl_constraint_dim(struct isl_constraint *constraint,
+	enum isl_dim_type type);
+
+int isl_constraint_involves_dims(__isl_keep isl_constraint *constraint,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+const char *isl_constraint_get_dim_name(__isl_keep isl_constraint *constraint,
+	enum isl_dim_type type, unsigned pos);
+void isl_constraint_get_constant(__isl_keep isl_constraint *constraint,
+	isl_int *v);
+void isl_constraint_get_coefficient(__isl_keep isl_constraint *constraint,
+	enum isl_dim_type type, int pos, isl_int *v);
+__isl_give isl_constraint *isl_constraint_set_constant(
+	__isl_take isl_constraint *constraint, isl_int v);
+__isl_give isl_constraint *isl_constraint_set_constant_si(
+	__isl_take isl_constraint *constraint, int v);
+__isl_give isl_constraint *isl_constraint_set_coefficient(
+	__isl_take isl_constraint *constraint,
+	enum isl_dim_type type, int pos, isl_int v);
+__isl_give isl_constraint *isl_constraint_set_coefficient_si(
+	__isl_take isl_constraint *constraint,
+	enum isl_dim_type type, int pos, int v);
+
+__isl_give isl_aff *isl_constraint_get_div(__isl_keep isl_constraint *constraint,
+	int pos);
+
+struct isl_constraint *isl_constraint_negate(struct isl_constraint *constraint);
+
+int isl_constraint_is_equality(__isl_keep isl_constraint *constraint);
+int isl_constraint_is_div_constraint(__isl_keep isl_constraint *constraint);
+
+int isl_constraint_is_lower_bound(__isl_keep isl_constraint *constraint,
+	enum isl_dim_type type, unsigned pos);
+int isl_constraint_is_upper_bound(__isl_keep isl_constraint *constraint,
+	enum isl_dim_type type, unsigned pos);
+
+__isl_give isl_basic_map *isl_basic_map_from_constraint(
+	__isl_take isl_constraint *constraint);
+struct isl_basic_set *isl_basic_set_from_constraint(
+	struct isl_constraint *constraint);
+
+__isl_give isl_aff *isl_constraint_get_bound(
+	__isl_keep isl_constraint *constraint, enum isl_dim_type type, int pos);
+__isl_give isl_aff *isl_constraint_get_aff(
+	__isl_keep isl_constraint *constraint);
+__isl_give isl_constraint *isl_equality_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_constraint *isl_inequality_from_aff(__isl_take isl_aff *aff);
+
+__isl_give isl_basic_set *isl_basic_set_drop_constraint(
+	__isl_take isl_basic_set *bset, __isl_take isl_constraint *constraint);
+
+__isl_give isl_printer *isl_printer_print_constraint(__isl_take isl_printer *p,
+	__isl_keep isl_constraint *c);
+void isl_constraint_dump(__isl_keep isl_constraint *c);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/ctx.h b/include/isl/ctx.h
new file mode 100644
index 0000000..3d88697
--- /dev/null
+++ b/include/isl/ctx.h
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_CTX_H
+#define ISL_CTX_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <isl/int.h>
+#include <isl/blk.h>
+#include <isl/arg.h>
+#include <isl/hash.h>
+#include <isl/config.h>
+
+#ifndef __isl_give
+#define __isl_give
+#endif
+#ifndef __isl_take
+#define __isl_take
+#endif
+#ifndef __isl_keep
+#define __isl_keep
+#endif
+#ifndef __isl_export
+#define __isl_export
+#endif
+#ifndef __isl_constructor
+#define __isl_constructor
+#endif
+#ifndef __isl_subclass
+#define __isl_subclass(super)
+#endif
+
+#ifdef GCC_WARN_UNUSED_RESULT
+#define	WARN_UNUSED	GCC_WARN_UNUSED_RESULT
+#else
+#define WARN_UNUSED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Nearly all isa functions require a struct isl_ctx allocated using
+ * isl_ctx_alloc.  This ctx contains (or will contain) options that
+ * control the behavior of the library and some caches.
+ *
+ * An object allocated within a given ctx should never be used inside
+ * another ctx.  Functions for moving objects from one ctx to another
+ * will be added as the need arises.
+ *
+ * A given context should only be used inside a single thread.
+ * A global context for synchronization between different threads
+ * as well as functions for moving a context to a different thread
+ * will be added as the need arises.
+ *
+ * If anything goes wrong (out of memory, failed assertion), then
+ * the library will currently simply abort.  This will be made
+ * configurable in the future.
+ * Users of the library should expect functions that return
+ * a pointer to a structure, to return NULL, indicating failure.
+ * Any function accepting a pointer to a structure will treat
+ * a NULL argument as a failure, resulting in the function freeing
+ * the remaining structures (if any) and returning NULL itself
+ * (in case of pointer return type).
+ * The only exception is the isl_ctx argument, which should never be NULL.
+ */
+struct isl_stats {
+	long	gbr_solved_lps;
+};
+enum isl_error {
+	isl_error_none = 0,
+	isl_error_abort,
+	isl_error_unknown,
+	isl_error_internal,
+	isl_error_invalid,
+	isl_error_unsupported
+};
+struct isl_ctx;
+typedef struct isl_ctx isl_ctx;
+
+/* Some helper macros */
+
+#define ISL_FL_INIT(l, f)   (l) = (f)               /* Specific flags location. */
+#define ISL_FL_SET(l, f)    ((l) |= (f))
+#define ISL_FL_CLR(l, f)    ((l) &= ~(f))
+#define ISL_FL_ISSET(l, f)  (!!((l) & (f)))
+
+#define ISL_F_INIT(p, f)    ISL_FL_INIT((p)->flags, f)  /* Structure element flags. */
+#define ISL_F_SET(p, f)     ISL_FL_SET((p)->flags, f)
+#define ISL_F_CLR(p, f)     ISL_FL_CLR((p)->flags, f)
+#define ISL_F_ISSET(p, f)   ISL_FL_ISSET((p)->flags, f)
+
+/* isl_check_ctx() checks at compile time if 'ctx' is of type 'isl_ctx *' and
+ * returns the value of 'expr'. It is used to ensure, that always an isl_ctx is
+ * passed to the following macros, even if they currently do not use it.
+ */
+#define isl_check_ctx(ctx, expr)	((ctx != (isl_ctx *) 0) ? expr : expr)
+
+#define isl_alloc(ctx,type,size)	((type *)isl_check_ctx(ctx,\
+							malloc(size)))
+#define isl_calloc(ctx,type,size)	((type *)isl_check_ctx(ctx,\
+							calloc(1, size)))
+#define isl_realloc(ctx,ptr,type,size)	((type *)isl_check_ctx(ctx,\
+							realloc(ptr,size)))
+#define isl_alloc_type(ctx,type)	isl_alloc(ctx,type,sizeof(type))
+#define isl_calloc_type(ctx,type)	isl_calloc(ctx,type,sizeof(type))
+#define isl_realloc_type(ctx,ptr,type)	isl_realloc(ctx,ptr,type,sizeof(type))
+#define isl_alloc_array(ctx,type,n)	isl_alloc(ctx,type,(n)*sizeof(type))
+#define isl_calloc_array(ctx,type,n)	((type *)isl_check_ctx(ctx,\
+						calloc(n, sizeof(type))))
+#define isl_realloc_array(ctx,ptr,type,n) \
+				    isl_realloc(ctx,ptr,type,(n)*sizeof(type))
+
+#define isl_die(ctx,errno,msg,code)					\
+	do {								\
+		isl_handle_error(ctx, errno, msg, __FILE__, __LINE__);	\
+		code;							\
+	} while (0)
+
+void isl_handle_error(isl_ctx *ctx, enum isl_error error, const char *msg,
+	const char *file, int line);
+
+#define isl_assert4(ctx,test,code,errno)				\
+	do {								\
+		if (test)						\
+			break;						\
+		isl_die(ctx, errno, "Assertion \"" #test "\" failed", code);	\
+	} while (0)
+#define isl_assert(ctx,test,code)					\
+	isl_assert4(ctx,test,code,isl_error_unknown)
+
+#define isl_min(a,b)			((a < b) ? (a) : (b))
+
+/* struct isl_ctx functions */
+
+struct isl_options *isl_ctx_options(isl_ctx *ctx);
+
+isl_ctx *isl_ctx_alloc_with_options(struct isl_args *args,
+	__isl_take void *opt);
+isl_ctx *isl_ctx_alloc(void);
+void *isl_ctx_peek_options(isl_ctx *ctx, struct isl_args *args);
+int isl_ctx_parse_options(isl_ctx *ctx, int argc, char **argv, unsigned flags);
+void isl_ctx_ref(struct isl_ctx *ctx);
+void isl_ctx_deref(struct isl_ctx *ctx);
+void isl_ctx_free(isl_ctx *ctx);
+
+void isl_ctx_abort(isl_ctx *ctx);
+void isl_ctx_resume(isl_ctx *ctx);
+int isl_ctx_aborted(isl_ctx *ctx);
+
+#define ISL_ARG_CTX_DECL(prefix,st,args)				\
+st *isl_ctx_peek_ ## prefix(isl_ctx *ctx);
+
+#define ISL_ARG_CTX_DEF(prefix,st,args)					\
+st *isl_ctx_peek_ ## prefix(isl_ctx *ctx)				\
+{									\
+	return (st *)isl_ctx_peek_options(ctx, &(args));		\
+}
+
+#define ISL_CTX_GET_INT_DEF(prefix,st,args,field)			\
+int prefix ## _get_ ## field(isl_ctx *ctx)				\
+{									\
+	st *options;							\
+	options = isl_ctx_peek_ ## prefix(ctx);				\
+	if (!options)							\
+		isl_die(ctx, isl_error_invalid,				\
+			"isl_ctx does not reference " #prefix,		\
+			return -1);					\
+	return options->field;						\
+}
+
+#define ISL_CTX_SET_INT_DEF(prefix,st,args,field)			\
+int prefix ## _set_ ## field(isl_ctx *ctx, int val)			\
+{									\
+	st *options;							\
+	options = isl_ctx_peek_ ## prefix(ctx);				\
+	if (!options)							\
+		isl_die(ctx, isl_error_invalid,				\
+			"isl_ctx does not reference " #prefix,		\
+			return -1);					\
+	options->field = val;						\
+	return 0;							\
+}
+
+#define ISL_CTX_GET_STR_DEF(prefix,st,args,field)			\
+const char *prefix ## _get_ ## field(isl_ctx *ctx)			\
+{									\
+	st *options;							\
+	options = isl_ctx_peek_ ## prefix(ctx);				\
+	if (!options)							\
+		isl_die(ctx, isl_error_invalid,				\
+			"isl_ctx does not reference " #prefix,		\
+			return NULL);					\
+	return options->field;						\
+}
+
+#define ISL_CTX_SET_STR_DEF(prefix,st,args,field)			\
+int prefix ## _set_ ## field(isl_ctx *ctx, const char *val)		\
+{									\
+	st *options;							\
+	options = isl_ctx_peek_ ## prefix(ctx);				\
+	if (!options)							\
+		isl_die(ctx, isl_error_invalid,				\
+			"isl_ctx does not reference " #prefix,		\
+			return -1);					\
+	if (!val)							\
+		return -1;						\
+	free(options->field);						\
+	options->field = strdup(val);					\
+	if (!options->field)						\
+		return -1;						\
+	return 0;							\
+}
+
+#define ISL_CTX_GET_BOOL_DEF(prefix,st,args,field)			\
+	ISL_CTX_GET_INT_DEF(prefix,st,args,field)
+
+#define ISL_CTX_SET_BOOL_DEF(prefix,st,args,field)			\
+	ISL_CTX_SET_INT_DEF(prefix,st,args,field)
+
+#define ISL_CTX_GET_CHOICE_DEF(prefix,st,args,field)			\
+	ISL_CTX_GET_INT_DEF(prefix,st,args,field)
+
+#define ISL_CTX_SET_CHOICE_DEF(prefix,st,args,field)			\
+	ISL_CTX_SET_INT_DEF(prefix,st,args,field)
+
+enum isl_error isl_ctx_last_error(isl_ctx *ctx);
+void isl_ctx_reset_error(isl_ctx *ctx);
+void isl_ctx_set_error(isl_ctx *ctx, enum isl_error error);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/dim.h b/include/isl/dim.h
new file mode 100644
index 0000000..7c31c02
--- /dev/null
+++ b/include/isl/dim.h
@@ -0,0 +1,122 @@
+#ifndef ISL_DIM_H
+#define ISL_DIM_H
+
+#include <isl/space.h>
+#include <isl/local_space.h>
+#include <isl/aff_type.h>
+#include <isl/constraint.h>
+#include <isl/map_type.h>
+#include <isl/set_type.h>
+#include <isl/point.h>
+#include <isl/union_map.h>
+#include <isl/union_set.h>
+#include <isl/polynomial_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define isl_dim isl_space
+
+isl_ctx *isl_dim_get_ctx(__isl_keep isl_space *dim);
+__isl_give isl_space *isl_dim_alloc(isl_ctx *ctx,
+			unsigned nparam, unsigned n_in, unsigned n_out);
+__isl_give isl_space *isl_dim_set_alloc(isl_ctx *ctx,
+			unsigned nparam, unsigned dim);
+__isl_give isl_space *isl_dim_copy(__isl_keep isl_space *dim);
+void isl_dim_free(__isl_take isl_space *dim);
+
+unsigned isl_dim_size(__isl_keep isl_space *dim, enum isl_dim_type type);
+
+__isl_give isl_space *isl_dim_set_dim_id(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+int isl_dim_has_dim_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_dim_get_dim_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+
+int isl_dim_find_dim_by_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type, __isl_keep isl_id *id);
+
+__isl_give isl_space *isl_dim_set_tuple_id(__isl_take isl_space *dim,
+	enum isl_dim_type type, __isl_take isl_id *id);
+__isl_give isl_space *isl_dim_reset_tuple_id(__isl_take isl_space *dim,
+	enum isl_dim_type type);
+int isl_dim_has_tuple_id(__isl_keep isl_space *dim, enum isl_dim_type type);
+__isl_give isl_id *isl_dim_get_tuple_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type);
+
+__isl_give isl_space *isl_dim_set_name(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos, __isl_keep const char *name);
+__isl_keep const char *isl_dim_get_name(__isl_keep isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+
+__isl_give isl_space *isl_dim_set_tuple_name(__isl_take isl_space *dim,
+	enum isl_dim_type type, const char *s);
+const char *isl_dim_get_tuple_name(__isl_keep isl_space *dim,
+				 enum isl_dim_type type);
+
+int isl_dim_is_wrapping(__isl_keep isl_space *dim);
+__isl_give isl_space *isl_dim_wrap(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_unwrap(__isl_take isl_space *dim);
+
+__isl_give isl_space *isl_dim_domain(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_from_domain(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_range(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_from_range(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_reverse(__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_join(__isl_take isl_space *left,
+	__isl_take isl_space *right);
+__isl_give isl_space *isl_dim_align_params(__isl_take isl_space *dim1,
+	__isl_take isl_space *dim2);
+__isl_give isl_space *isl_dim_insert(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos, unsigned n);
+__isl_give isl_space *isl_dim_add(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_space *isl_dim_drop(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_space *isl_dim_move(__isl_take isl_space *dim,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_space *isl_dim_map_from_set(
+	__isl_take isl_space *dim);
+__isl_give isl_space *isl_dim_zip(__isl_take isl_space *dim);
+
+__isl_give isl_local_space *isl_local_space_from_dim(
+	__isl_take isl_space *dim);
+__isl_give isl_space *isl_local_space_get_dim(
+	__isl_keep isl_local_space *ls);
+
+__isl_give isl_space *isl_aff_get_dim(__isl_keep isl_aff *aff);
+__isl_give isl_space *isl_pw_aff_get_dim(__isl_keep isl_pw_aff *pwaff);
+
+__isl_give isl_space *isl_constraint_get_dim(
+	__isl_keep isl_constraint *constraint);
+
+__isl_give isl_space *isl_basic_map_get_dim(__isl_keep isl_basic_map *bmap);
+__isl_give isl_space *isl_map_get_dim(__isl_keep isl_map *map);
+__isl_give isl_space *isl_union_map_get_dim(__isl_keep isl_union_map *umap);
+
+__isl_give isl_space *isl_basic_set_get_dim(__isl_keep isl_basic_set *bset);
+__isl_give isl_space *isl_set_get_dim(__isl_keep isl_set *set);
+__isl_give isl_space *isl_union_set_get_dim(__isl_keep isl_union_set *uset);
+
+__isl_give isl_space *isl_point_get_dim(__isl_keep isl_point *pnt);
+
+__isl_give isl_space *isl_qpolynomial_get_dim(__isl_keep isl_qpolynomial *qp);
+__isl_give isl_space *isl_pw_qpolynomial_get_dim(
+	__isl_keep isl_pw_qpolynomial *pwqp);
+__isl_give isl_space *isl_qpolynomial_fold_get_dim(
+	__isl_keep isl_qpolynomial_fold *fold);
+__isl_give isl_space *isl_pw_qpolynomial_fold_get_dim(
+	__isl_keep isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_space *isl_union_pw_qpolynomial_get_dim(
+	__isl_keep isl_union_pw_qpolynomial *upwqp);
+__isl_give isl_space *isl_union_pw_qpolynomial_fold_get_dim(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/flow.h b/include/isl/flow.h
new file mode 100644
index 0000000..ddaa941
--- /dev/null
+++ b/include/isl/flow.h
@@ -0,0 +1,75 @@
+#ifndef ISL_FLOW_H
+#define ISL_FLOW_H
+
+#include <isl/set_type.h>
+#include <isl/map_type.h>
+#include <isl/union_set_type.h>
+#include <isl/union_map_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Let n (>= 0) be the number of iterators shared by first and second.
+ * If first precedes second textually return 2 * n + 1,
+ * otherwise return 2 * n.
+ */
+typedef int (*isl_access_level_before)(void *first, void *second);
+
+struct isl_restriction;
+typedef struct isl_restriction isl_restriction;
+
+void *isl_restriction_free(__isl_take isl_restriction *restr);
+__isl_give isl_restriction *isl_restriction_empty(
+	__isl_take isl_map *source_map);
+__isl_give isl_restriction *isl_restriction_none(
+	__isl_take isl_map *source_map);
+__isl_give isl_restriction *isl_restriction_input(
+	__isl_take isl_set *source_restr, __isl_take isl_set *sink_restr);
+__isl_give isl_restriction *isl_restriction_output(
+	__isl_take isl_set *source_restr);
+
+isl_ctx *isl_restriction_get_ctx(__isl_keep isl_restriction *restr);
+
+typedef __isl_give isl_restriction *(*isl_access_restrict)(
+	__isl_keep isl_map *source_map, __isl_keep isl_set *sink,
+	void *source_user, void *user);
+
+struct isl_access_info;
+typedef struct isl_access_info isl_access_info;
+struct isl_flow;
+typedef struct isl_flow isl_flow;
+
+__isl_give isl_access_info *isl_access_info_alloc(__isl_take isl_map *sink,
+	void *sink_user, isl_access_level_before fn, int max_source);
+__isl_give isl_access_info *isl_access_info_set_restrict(
+	__isl_take isl_access_info *acc, isl_access_restrict fn, void *user);
+__isl_give isl_access_info *isl_access_info_add_source(
+	__isl_take isl_access_info *acc, __isl_take isl_map *source,
+	int must, void *source_user);
+void *isl_access_info_free(__isl_take isl_access_info *acc);
+
+isl_ctx *isl_access_info_get_ctx(__isl_keep isl_access_info *acc);
+
+__isl_give isl_flow *isl_access_info_compute_flow(__isl_take isl_access_info *acc);
+int isl_flow_foreach(__isl_keep isl_flow *deps,
+	int (*fn)(__isl_take isl_map *dep, int must, void *dep_user, void *user),
+	void *user);
+__isl_give isl_map *isl_flow_get_no_source(__isl_keep isl_flow *deps, int must);
+void isl_flow_free(__isl_take isl_flow *deps);
+
+isl_ctx *isl_flow_get_ctx(__isl_keep isl_flow *deps);
+
+int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
+	__isl_take isl_union_map *must_source,
+	__isl_take isl_union_map *may_source,
+	__isl_take isl_union_map *schedule,
+	__isl_give isl_union_map **must_dep, __isl_give isl_union_map **may_dep,
+	__isl_give isl_union_map **must_no_source,
+	__isl_give isl_union_map **may_no_source);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/hash.h b/include/isl/hash.h
new file mode 100644
index 0000000..7764a9b
--- /dev/null
+++ b/include/isl/hash.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_HASH_H
+#define ISL_HASH_H
+
+#include <stdlib.h>
+#include <isl/stdint.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define isl_hash_init()		(2166136261u)
+#define isl_hash_byte(h,b)	do {					\
+					h *= 16777619;			\
+					h ^= b;				\
+				} while(0)
+#define isl_hash_hash(h,h2)						\
+	do {								\
+		isl_hash_byte(h, (h2) & 0xFF);				\
+		isl_hash_byte(h, ((h2) >> 8) & 0xFF);			\
+		isl_hash_byte(h, ((h2) >> 16) & 0xFF);			\
+		isl_hash_byte(h, ((h2) >> 24) & 0xFF);			\
+	} while(0)
+#define isl_hash_bits(h,bits)						\
+	((bits) == 32) ? (h) :						\
+	((bits) >= 16) ?						\
+	      ((h) >> (bits)) ^ ((h) & (((uint32_t)1 << (bits)) - 1)) :	\
+	      (((h) >> (bits)) ^ (h)) & (((uint32_t)1 << (bits)) - 1)
+
+uint32_t isl_hash_string(uint32_t hash, const char *s);
+uint32_t isl_hash_mem(uint32_t hash, const void *p, size_t len);
+
+#define isl_hash_builtin(h,l)	isl_hash_mem(h, &l, sizeof(l))
+
+struct isl_hash_table_entry
+{
+	uint32_t  hash;
+	void     *data;
+};
+
+struct isl_hash_table {
+	int    bits;
+	int    n;
+	struct isl_hash_table_entry *entries;
+};
+
+struct isl_ctx;
+
+struct isl_hash_table *isl_hash_table_alloc(struct isl_ctx *ctx, int min_size);
+void isl_hash_table_free(struct isl_ctx *ctx, struct isl_hash_table *table);
+
+int isl_hash_table_init(struct isl_ctx *ctx, struct isl_hash_table *table,
+			int min_size);
+void isl_hash_table_clear(struct isl_hash_table *table);
+struct isl_hash_table_entry *isl_hash_table_find(struct isl_ctx *ctx,
+				struct isl_hash_table *table,
+				uint32_t key_hash,
+				int (*eq)(const void *entry, const void *val),
+				const void *val, int reserve);
+int isl_hash_table_foreach(struct isl_ctx *ctx,
+			    struct isl_hash_table *table,
+			    int (*fn)(void **entry, void *user), void *user);
+void isl_hash_table_remove(struct isl_ctx *ctx,
+				struct isl_hash_table *table,
+				struct isl_hash_table_entry *entry);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/id.h b/include/isl/id.h
new file mode 100644
index 0000000..d237b23
--- /dev/null
+++ b/include/isl/id.h
@@ -0,0 +1,35 @@
+#ifndef ISL_ID_H
+#define ISL_ID_H
+
+#include <isl/ctx.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_id;
+typedef struct isl_id isl_id;
+
+isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id);
+
+__isl_give isl_id *isl_id_alloc(isl_ctx *ctx,
+	__isl_keep const char *name, void *user);
+__isl_give isl_id *isl_id_copy(isl_id *id);
+void *isl_id_free(__isl_take isl_id *id);
+
+void *isl_id_get_user(__isl_keep isl_id *id);
+__isl_keep const char *isl_id_get_name(__isl_keep isl_id *id);
+
+__isl_give isl_id *isl_id_set_free_user(__isl_take isl_id *id,
+	__isl_give void (*free_user)(void *user));
+
+__isl_give isl_printer *isl_printer_print_id(__isl_take isl_printer *p,
+	__isl_keep isl_id *id);
+void isl_id_dump(__isl_keep isl_id *id);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/ilp.h b/include/isl/ilp.h
new file mode 100644
index 0000000..5b7c3bc
--- /dev/null
+++ b/include/isl/ilp.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_ILP_H
+#define ISL_ILP_H
+
+#include <isl/aff_type.h>
+#include <isl/lp.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+enum isl_lp_result isl_basic_set_solve_ilp(struct isl_basic_set *bset, int max,
+				      isl_int *f, isl_int *opt,
+				      struct isl_vec **sol_p);
+enum isl_lp_result isl_basic_set_max(__isl_keep isl_basic_set *bset,
+	__isl_keep isl_aff *obj, isl_int *opt);
+enum isl_lp_result isl_set_min(__isl_keep isl_set *set,
+	__isl_keep isl_aff *obj, isl_int *opt);
+enum isl_lp_result isl_set_max(__isl_keep isl_set *set,
+	__isl_keep isl_aff *obj, isl_int *opt);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/int.h b/include/isl/int.h
new file mode 100644
index 0000000..9391df9
--- /dev/null
+++ b/include/isl/int.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_INT_H
+#define ISL_INT_H
+
+#include <isl/hash.h>
+#include <string.h>
+#include <gmp.h>
+#if defined(__cplusplus)
+#include <iostream>
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#ifndef mp_get_memory_functions
+void mp_get_memory_functions(
+		void *(**alloc_func_ptr) (size_t),
+		void *(**realloc_func_ptr) (void *, size_t, size_t),
+		void (**free_func_ptr) (void *, size_t));
+#endif
+
+/* isl_int is the basic integer type.  It currently always corresponds
+ * to a gmp mpz_t, but in the future, different types such as long long
+ * or cln::cl_I will be supported.
+ */
+typedef mpz_t	isl_int;
+
+#define isl_int_init(i)		mpz_init(i)
+#define isl_int_clear(i)	mpz_clear(i)
+
+#define isl_int_set(r,i)	mpz_set(r,i)
+#define isl_int_set_gmp(r,i)	mpz_set(r,i)
+#define isl_int_set_si(r,i)	mpz_set_si(r,i)
+#define isl_int_set_ui(r,i)	mpz_set_ui(r,i)
+#define isl_int_get_gmp(i,g)	mpz_set(g,i)
+#define isl_int_get_si(r)	mpz_get_si(r)
+#define isl_int_get_ui(r)	mpz_get_ui(r)
+#define isl_int_get_d(r)	mpz_get_d(r)
+#define isl_int_get_str(r)	mpz_get_str(0, 10, r)
+typedef void (*isl_int_print_gmp_free_t)(void *, size_t);
+#define isl_int_free_str(s)					\
+	do {								\
+		isl_int_print_gmp_free_t gmp_free;			\
+		mp_get_memory_functions(NULL, NULL, &gmp_free);		\
+		(*gmp_free)(s, strlen(s) + 1);				\
+	} while (0)
+#define isl_int_abs(r,i)	mpz_abs(r,i)
+#define isl_int_neg(r,i)	mpz_neg(r,i)
+#define isl_int_swap(i,j)	mpz_swap(i,j)
+#define isl_int_swap_or_set(i,j)	mpz_swap(i,j)
+#define isl_int_add_ui(r,i,j)	mpz_add_ui(r,i,j)
+#define isl_int_sub_ui(r,i,j)	mpz_sub_ui(r,i,j)
+
+#define isl_int_add(r,i,j)	mpz_add(r,i,j)
+#define isl_int_sub(r,i,j)	mpz_sub(r,i,j)
+#define isl_int_mul(r,i,j)	mpz_mul(r,i,j)
+#define isl_int_mul_2exp(r,i,j)	mpz_mul_2exp(r,i,j)
+#define isl_int_mul_ui(r,i,j)	mpz_mul_ui(r,i,j)
+#define isl_int_pow_ui(r,i,j)	mpz_pow_ui(r,i,j)
+#define isl_int_addmul(r,i,j)	mpz_addmul(r,i,j)
+#define isl_int_submul(r,i,j)	mpz_submul(r,i,j)
+
+#define isl_int_gcd(r,i,j)	mpz_gcd(r,i,j)
+#define isl_int_lcm(r,i,j)	mpz_lcm(r,i,j)
+#define isl_int_divexact(r,i,j)	mpz_divexact(r,i,j)
+#define isl_int_divexact_ui(r,i,j)	mpz_divexact_ui(r,i,j)
+#define isl_int_tdiv_q(r,i,j)	mpz_tdiv_q(r,i,j)
+#define isl_int_cdiv_q(r,i,j)	mpz_cdiv_q(r,i,j)
+#define isl_int_fdiv_q(r,i,j)	mpz_fdiv_q(r,i,j)
+#define isl_int_fdiv_r(r,i,j)	mpz_fdiv_r(r,i,j)
+#define isl_int_fdiv_q_ui(r,i,j)	mpz_fdiv_q_ui(r,i,j)
+
+#define isl_int_read(r,s)	mpz_set_str(r,s,10)
+#define isl_int_print(out,i,width)					\
+	do {								\
+		char *s;						\
+		s = mpz_get_str(0, 10, i);				\
+		fprintf(out, "%*s", width, s);				\
+		isl_int_free_str(s);                                        \
+	} while (0)
+
+#define isl_int_sgn(i)		mpz_sgn(i)
+#define isl_int_cmp(i,j)	mpz_cmp(i,j)
+#define isl_int_cmp_si(i,si)	mpz_cmp_si(i,si)
+#define isl_int_eq(i,j)		(mpz_cmp(i,j) == 0)
+#define isl_int_ne(i,j)		(mpz_cmp(i,j) != 0)
+#define isl_int_lt(i,j)		(mpz_cmp(i,j) < 0)
+#define isl_int_le(i,j)		(mpz_cmp(i,j) <= 0)
+#define isl_int_gt(i,j)		(mpz_cmp(i,j) > 0)
+#define isl_int_ge(i,j)		(mpz_cmp(i,j) >= 0)
+#define isl_int_abs_eq(i,j)	(mpz_cmpabs(i,j) == 0)
+#define isl_int_abs_ne(i,j)	(mpz_cmpabs(i,j) != 0)
+#define isl_int_abs_lt(i,j)	(mpz_cmpabs(i,j) < 0)
+#define isl_int_abs_gt(i,j)	(mpz_cmpabs(i,j) > 0)
+#define isl_int_abs_ge(i,j)	(mpz_cmpabs(i,j) >= 0)
+
+
+#define isl_int_is_zero(i)	(isl_int_sgn(i) == 0)
+#define isl_int_is_one(i)	(isl_int_cmp_si(i,1) == 0)
+#define isl_int_is_negone(i)	(isl_int_cmp_si(i,-1) == 0)
+#define isl_int_is_pos(i)	(isl_int_sgn(i) > 0)
+#define isl_int_is_neg(i)	(isl_int_sgn(i) < 0)
+#define isl_int_is_nonpos(i)	(isl_int_sgn(i) <= 0)
+#define isl_int_is_nonneg(i)	(isl_int_sgn(i) >= 0)
+#define isl_int_is_divisible_by(i,j)	mpz_divisible_p(i,j)
+
+uint32_t isl_gmp_hash(mpz_t v, uint32_t hash);
+#define isl_int_hash(v,h)	isl_gmp_hash(v,h)
+
+#if defined(__cplusplus)
+}
+#endif
+
+#if defined(__cplusplus)
+extern "C" { typedef void (*isl_gmp_free_t)(void *, size_t); }
+
+static inline std::ostream &operator<<(std::ostream &os, isl_int i)
+{
+	char *s;
+	s = mpz_get_str(0, 10, i);
+	os << s;
+	isl_int_free_str(s);
+	return os;
+}
+#endif
+
+#endif
diff --git a/include/isl/list.h b/include/isl/list.h
new file mode 100644
index 0000000..0de7d1c
--- /dev/null
+++ b/include/isl/list.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_LIST_H
+#define ISL_LIST_H
+
+#include <isl/ctx.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define ISL_DECLARE_LIST(EL)						\
+struct isl_##EL;							\
+struct isl_##EL##_list;							\
+typedef struct isl_##EL##_list isl_##EL##_list;				\
+isl_ctx *isl_##EL##_list_get_ctx(__isl_keep isl_##EL##_list *list);	\
+__isl_give isl_##EL##_list *isl_##EL##_list_from_##EL(			\
+	__isl_take struct isl_##EL *el);				\
+__isl_give isl_##EL##_list *isl_##EL##_list_alloc(isl_ctx *ctx, int n);	\
+__isl_give isl_##EL##_list *isl_##EL##_list_copy(			\
+	__isl_keep isl_##EL##_list *list);				\
+void *isl_##EL##_list_free(__isl_take isl_##EL##_list *list);		\
+__isl_give isl_##EL##_list *isl_##EL##_list_add(			\
+	__isl_take isl_##EL##_list *list,				\
+	__isl_take struct isl_##EL *el);				\
+__isl_give isl_##EL##_list *isl_##EL##_list_insert(			\
+	__isl_take isl_##EL##_list *list, unsigned pos,			\
+	__isl_take struct isl_##EL *el);				\
+__isl_give isl_##EL##_list *isl_##EL##_list_drop(			\
+	__isl_take isl_##EL##_list *list, unsigned first, unsigned n);	\
+__isl_give isl_##EL##_list *isl_##EL##_list_concat(			\
+	__isl_take isl_##EL##_list *list1,				\
+	__isl_take isl_##EL##_list *list2);				\
+int isl_##EL##_list_n_##EL(__isl_keep isl_##EL##_list *list);		\
+__isl_give struct isl_##EL *isl_##EL##_list_get_##EL(			\
+	__isl_keep isl_##EL##_list *list, int index);			\
+__isl_give struct isl_##EL##_list *isl_##EL##_list_set_##EL(		\
+	__isl_take struct isl_##EL##_list *list, int index,		\
+	__isl_take struct isl_##EL *el);				\
+int isl_##EL##_list_foreach(__isl_keep isl_##EL##_list *list,		\
+	int (*fn)(__isl_take struct isl_##EL *el, void *user),		\
+	void *user);							\
+__isl_give isl_printer *isl_printer_print_##EL##_list(			\
+	__isl_take isl_printer *p, __isl_keep isl_##EL##_list *list);	\
+void isl_##EL##_list_dump(__isl_keep isl_##EL##_list *list);
+
+ISL_DECLARE_LIST(id)
+ISL_DECLARE_LIST(constraint)
+ISL_DECLARE_LIST(basic_set)
+ISL_DECLARE_LIST(set)
+ISL_DECLARE_LIST(aff)
+ISL_DECLARE_LIST(pw_aff)
+ISL_DECLARE_LIST(band)
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/local_space.h b/include/isl/local_space.h
new file mode 100644
index 0000000..5955260
--- /dev/null
+++ b/include/isl/local_space.h
@@ -0,0 +1,78 @@
+#ifndef ISL_LOCAL_SPACE_H
+#define ISL_LOCAL_SPACE_H
+
+#include <isl/aff_type.h>
+#include <isl/space.h>
+#include <isl/printer.h>
+#include <isl/map_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_local_space;
+typedef struct isl_local_space isl_local_space;
+
+isl_ctx *isl_local_space_get_ctx(__isl_keep isl_local_space *ls);
+
+__isl_give isl_local_space *isl_local_space_from_space(__isl_take isl_space *dim);
+
+__isl_give isl_local_space *isl_local_space_copy(
+	__isl_keep isl_local_space *ls);
+void *isl_local_space_free(__isl_take isl_local_space *ls);
+
+int isl_local_space_is_set(__isl_keep isl_local_space *ls);
+
+int isl_local_space_dim(__isl_keep isl_local_space *ls,
+	enum isl_dim_type type);
+int isl_local_space_has_dim_name(__isl_keep isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+const char *isl_local_space_get_dim_name(__isl_keep isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_local_space *isl_local_space_set_dim_name(
+	__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos, const char *s);
+int isl_local_space_has_dim_id(__isl_keep isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_local_space_get_dim_id(__isl_keep isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_local_space *isl_local_space_set_dim_id(
+	__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+__isl_give isl_space *isl_local_space_get_space(__isl_keep isl_local_space *ls);
+__isl_give isl_aff *isl_local_space_get_div(__isl_keep isl_local_space *ls,
+	int pos);
+
+__isl_give isl_local_space *isl_local_space_domain(
+	__isl_take isl_local_space *ls);
+__isl_give isl_local_space *isl_local_space_range(
+	__isl_take isl_local_space *ls);
+__isl_give isl_local_space *isl_local_space_from_domain(
+	__isl_take isl_local_space *ls);
+__isl_give isl_local_space *isl_local_space_add_dims(
+	__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned n);
+__isl_give isl_local_space *isl_local_space_drop_dims(
+	__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_local_space *isl_local_space_insert_dims(
+	__isl_take isl_local_space *ls,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_local_space *isl_local_space_intersect(
+	__isl_take isl_local_space *ls1, __isl_take isl_local_space *ls2);
+
+int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
+	__isl_keep isl_local_space *ls2);
+
+__isl_give isl_basic_map *isl_local_space_lifting(
+	__isl_take isl_local_space *ls);
+
+__isl_give isl_printer *isl_printer_print_local_space(__isl_take isl_printer *p,
+	__isl_keep isl_local_space *ls);
+void isl_local_space_dump(__isl_keep isl_local_space *ls);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/lp.h b/include/isl/lp.h
new file mode 100644
index 0000000..6550372
--- /dev/null
+++ b/include/isl/lp.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_LP_H
+#define ISL_LP_H
+
+#include <isl/int.h>
+#include <isl/vec.h>
+#include <isl/map_type.h>
+#include <isl/set_type.h>
+
+enum isl_lp_result {
+	isl_lp_error = -1,
+	isl_lp_ok = 0,
+	isl_lp_unbounded,
+	isl_lp_empty
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+enum isl_lp_result isl_basic_map_solve_lp(struct isl_basic_map *bmap, int max,
+				      isl_int *f, isl_int denom, isl_int *opt,
+				      isl_int *opt_denom,
+				      struct isl_vec **sol);
+enum isl_lp_result isl_basic_set_solve_lp(struct isl_basic_set *bset, int max,
+				      isl_int *f, isl_int denom, isl_int *opt,
+				      isl_int *opt_denom,
+				      struct isl_vec **sol);
+enum isl_lp_result isl_map_solve_lp(__isl_keep isl_map *map, int max,
+				      isl_int *f, isl_int denom, isl_int *opt,
+				      isl_int *opt_denom,
+				      struct isl_vec **sol);
+enum isl_lp_result isl_set_solve_lp(__isl_keep isl_set *set, int max,
+				      isl_int *f, isl_int denom, isl_int *opt,
+				      isl_int *opt_denom,
+				      struct isl_vec **sol);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/map.h b/include/isl/map.h
new file mode 100644
index 0000000..1386e34
--- /dev/null
+++ b/include/isl/map.h
@@ -0,0 +1,654 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_MAP_H
+#define ISL_MAP_H
+
+#include <stdio.h>
+
+#include <isl/int.h>
+#include <isl/ctx.h>
+#include <isl/blk.h>
+#include <isl/space.h>
+#include <isl/vec.h>
+#include <isl/mat.h>
+#include <isl/printer.h>
+#include <isl/local_space.h>
+#include <isl/aff_type.h>
+#include <isl/list.h>
+#include <isl/map_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* General notes:
+ *
+ * All structures are reference counted to allow reuse without duplication.
+ * A *_copy operation will increase the reference count, while a *_free
+ * operation will decrease the reference count and only actually release
+ * the structures when the reference count drops to zero.
+ *
+ * Functions that return an isa structure will in general _destroy_
+ * all argument isa structures (the obvious execption begin the _copy
+ * functions).  A pointer passed to such a function may therefore
+ * never be used after the function call.  If you want to keep a
+ * reference to the old structure(s), use the appropriate _copy function.
+ */
+
+unsigned isl_basic_map_n_in(const struct isl_basic_map *bmap);
+unsigned isl_basic_map_n_out(const struct isl_basic_map *bmap);
+unsigned isl_basic_map_n_param(const struct isl_basic_map *bmap);
+unsigned isl_basic_map_n_div(const struct isl_basic_map *bmap);
+unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
+unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
+				enum isl_dim_type type);
+
+unsigned isl_map_n_in(const struct isl_map *map);
+unsigned isl_map_n_out(const struct isl_map *map);
+unsigned isl_map_n_param(const struct isl_map *map);
+unsigned isl_map_dim(__isl_keep isl_map *map, enum isl_dim_type type);
+
+isl_ctx *isl_basic_map_get_ctx(__isl_keep isl_basic_map *bmap);
+isl_ctx *isl_map_get_ctx(__isl_keep isl_map *map);
+__isl_give isl_space *isl_basic_map_get_space(__isl_keep isl_basic_map *bmap);
+__isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);
+
+__isl_give isl_aff *isl_basic_map_get_div(__isl_keep isl_basic_map *bmap,
+	int pos);
+
+__isl_give isl_local_space *isl_basic_map_get_local_space(
+	__isl_keep isl_basic_map *bmap);
+
+__isl_give isl_basic_map *isl_basic_map_set_tuple_name(
+	__isl_take isl_basic_map *bmap, enum isl_dim_type type, const char *s);
+const char *isl_basic_map_get_tuple_name(__isl_keep isl_basic_map *bmap,
+	enum isl_dim_type type);
+int isl_map_has_tuple_name(__isl_keep isl_map *map, enum isl_dim_type type);
+const char *isl_map_get_tuple_name(__isl_keep isl_map *map,
+	enum isl_dim_type type);
+__isl_give isl_map *isl_map_set_tuple_name(__isl_take isl_map *map,
+	enum isl_dim_type type, const char *s);
+const char *isl_basic_map_get_dim_name(__isl_keep isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned pos);
+int isl_map_has_dim_name(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos);
+const char *isl_map_get_dim_name(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_basic_map *isl_basic_map_set_dim_name(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned pos, const char *s);
+__isl_give isl_map *isl_map_set_dim_name(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_map *isl_map_set_dim_id(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+int isl_basic_map_has_dim_id(__isl_keep isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned pos);
+int isl_map_has_dim_id(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_map_get_dim_id(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_map *isl_map_set_tuple_id(__isl_take isl_map *map,
+	enum isl_dim_type type, __isl_take isl_id *id);
+__isl_give isl_map *isl_map_reset_tuple_id(__isl_take isl_map *map,
+	enum isl_dim_type type);
+int isl_map_has_tuple_id(__isl_keep isl_map *map, enum isl_dim_type type);
+__isl_give isl_id *isl_map_get_tuple_id(__isl_keep isl_map *map,
+	enum isl_dim_type type);
+
+int isl_map_find_dim_by_id(__isl_keep isl_map *map, enum isl_dim_type type,
+	__isl_keep isl_id *id);
+int isl_map_find_dim_by_name(__isl_keep isl_map *map, enum isl_dim_type type,
+	const char *name);
+
+int isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap);
+
+struct isl_basic_map *isl_basic_map_alloc(struct isl_ctx *ctx,
+		unsigned nparam, unsigned in, unsigned out, unsigned extra,
+		unsigned n_eq, unsigned n_ineq);
+__isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_space *dim);
+struct isl_basic_map *isl_basic_map_identity_like(struct isl_basic_map *model);
+struct isl_basic_map *isl_basic_map_finalize(struct isl_basic_map *bmap);
+void *isl_basic_map_free(__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_copy(__isl_keep isl_basic_map *bmap);
+struct isl_basic_map *isl_basic_map_extend(struct isl_basic_map *base,
+		unsigned nparam, unsigned n_in, unsigned n_out, unsigned extra,
+		unsigned n_eq, unsigned n_ineq);
+struct isl_basic_map *isl_basic_map_extend_constraints(
+		struct isl_basic_map *base, unsigned n_eq, unsigned n_ineq);
+__isl_give isl_basic_map *isl_basic_map_equal(
+	__isl_take isl_space *dim, unsigned n_equal);
+__isl_give isl_basic_map *isl_basic_map_less_at(__isl_take isl_space *dim,
+	unsigned pos);
+__isl_give isl_basic_map *isl_basic_map_more_at(__isl_take isl_space *dim,
+	unsigned pos);
+__isl_give isl_basic_map *isl_basic_map_empty(__isl_take isl_space *dim);
+struct isl_basic_map *isl_basic_map_empty_like(struct isl_basic_map *model);
+struct isl_basic_map *isl_basic_map_empty_like_map(struct isl_map *model);
+__isl_give isl_basic_map *isl_basic_map_universe(__isl_take isl_space *dim);
+__isl_give isl_basic_map *isl_basic_map_nat_universe(__isl_take isl_space *dim);
+__isl_give isl_basic_map *isl_basic_map_universe_like(
+		__isl_keep isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_remove_redundancies(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_remove_redundancies(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_map_simple_hull(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_map_unshifted_simple_hull(
+	__isl_take isl_map *map);
+
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_intersect_domain(
+		__isl_take isl_basic_map *bmap,
+		__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_intersect_range(
+		__isl_take isl_basic_map *bmap,
+		__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_intersect(
+		__isl_take isl_basic_map *bmap1,
+		__isl_take isl_basic_map *bmap2);
+__isl_export
+__isl_give isl_map *isl_basic_map_union(
+		__isl_take isl_basic_map *bmap1,
+		__isl_take isl_basic_map *bmap2);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_apply_domain(
+		__isl_take isl_basic_map *bmap1,
+		__isl_take isl_basic_map *bmap2);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_apply_range(
+		__isl_take isl_basic_map *bmap1,
+		__isl_take isl_basic_map *bmap2);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_affine_hull(
+		__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_reverse(__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_set *isl_basic_map_domain(__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_set *isl_basic_map_range(__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_domain_map(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_range_map(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_remove_dims(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_eliminate(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_from_basic_set(
+	__isl_take isl_basic_set *bset, __isl_take isl_space *dim);
+struct isl_basic_set *isl_basic_set_from_basic_map(struct isl_basic_map *bmap);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_sample(__isl_take isl_basic_map *bmap);
+struct isl_basic_map *isl_basic_map_simplify(struct isl_basic_map *bmap);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_detect_equalities(
+						__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
+	FILE *input);
+__isl_constructor
+__isl_give isl_basic_map *isl_basic_map_read_from_str(isl_ctx *ctx,
+	const char *str);
+__isl_give isl_map *isl_map_read_from_file(isl_ctx *ctx, FILE *input);
+__isl_constructor
+__isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx, const char *str);
+void isl_basic_map_dump(__isl_keep isl_basic_map *bmap);
+void isl_basic_map_print(__isl_keep isl_basic_map *bmap, FILE *out, int indent,
+	const char *prefix, const char *suffix, unsigned output_format);
+void isl_map_dump(__isl_keep isl_map *map);
+void isl_map_print(__isl_keep isl_map *map, FILE *out, int indent,
+	unsigned output_format);
+__isl_give isl_printer *isl_printer_print_basic_map(
+	__isl_take isl_printer *printer, __isl_keep isl_basic_map *bmap);
+__isl_give isl_printer *isl_printer_print_map(__isl_take isl_printer *printer,
+	__isl_keep isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_fix_si(__isl_take isl_basic_map *bmap,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_basic_map *isl_basic_map_lower_bound_si(
+		__isl_take isl_basic_map *bmap,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_basic_map *isl_basic_map_upper_bound_si(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned pos, int value);
+
+struct isl_basic_map *isl_basic_map_sum(
+		struct isl_basic_map *bmap1, struct isl_basic_map *bmap2);
+struct isl_basic_map *isl_basic_map_neg(struct isl_basic_map *bmap);
+struct isl_basic_map *isl_basic_map_floordiv(struct isl_basic_map *bmap,
+		isl_int d);
+
+struct isl_map *isl_map_sum(struct isl_map *map1, struct isl_map *map2);
+struct isl_map *isl_map_neg(struct isl_map *map);
+struct isl_map *isl_map_floordiv(struct isl_map *map, isl_int d);
+
+__isl_export
+int isl_basic_map_is_equal(
+		__isl_keep isl_basic_map *bmap1,
+		__isl_keep isl_basic_map *bmap2);
+
+__isl_give isl_map *isl_basic_map_partial_lexmax(
+		__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_map *isl_basic_map_partial_lexmin(
+		__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_map *isl_map_partial_lexmax(
+		__isl_take isl_map *map, __isl_take isl_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_map *isl_map_partial_lexmin(
+		__isl_take isl_map *map, __isl_take isl_set *dom,
+		__isl_give isl_set **empty);
+__isl_export
+__isl_give isl_map *isl_basic_map_lexmin(__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_map *isl_basic_map_lexmax(__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_map *isl_map_lexmin(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_map *isl_map_lexmax(__isl_take isl_map *map);
+__isl_give isl_pw_multi_aff *isl_basic_map_partial_lexmin_pw_multi_aff(
+	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
+	__isl_give isl_set **empty);
+__isl_give isl_pw_multi_aff *isl_basic_map_partial_lexmax_pw_multi_aff(
+	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
+	__isl_give isl_set **empty);
+__isl_give isl_pw_multi_aff *isl_basic_map_lexmin_pw_multi_aff(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
+	__isl_take isl_map *map);
+__isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
+	__isl_take isl_map *map);
+
+void isl_basic_map_print_internal(__isl_keep isl_basic_map *bmap,
+	FILE *out, int indent);
+
+struct isl_basic_map *isl_map_copy_basic_map(struct isl_map *map);
+__isl_give isl_map *isl_map_drop_basic_map(__isl_take isl_map *map,
+						__isl_keep isl_basic_map *bmap);
+
+int isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned pos, isl_int *val);
+
+int isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap);
+int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
+int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
+int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map *bmap);
+__isl_export
+int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
+__isl_export
+int isl_basic_map_is_subset(__isl_keep isl_basic_map *bmap1,
+		__isl_keep isl_basic_map *bmap2);
+int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map *bmap1,
+		__isl_keep isl_basic_map *bmap2);
+
+struct isl_map *isl_map_alloc(struct isl_ctx *ctx,
+		unsigned nparam, unsigned in, unsigned out, int n,
+		unsigned flags);
+__isl_give isl_map *isl_map_universe(__isl_take isl_space *dim);
+__isl_give isl_map *isl_map_nat_universe(__isl_take isl_space *dim);
+__isl_give isl_map *isl_map_empty(__isl_take isl_space *dim);
+struct isl_map *isl_map_empty_like(struct isl_map *model);
+struct isl_map *isl_map_empty_like_basic_map(struct isl_basic_map *model);
+struct isl_map *isl_map_dup(struct isl_map *map);
+__isl_give isl_map *isl_map_add_basic_map(__isl_take isl_map *map,
+						__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_identity(__isl_take isl_space *dim);
+struct isl_map *isl_map_identity_like(struct isl_map *model);
+struct isl_map *isl_map_identity_like_basic_map(struct isl_basic_map *model);
+__isl_give isl_map *isl_map_lex_lt_first(__isl_take isl_space *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_le_first(__isl_take isl_space *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_lt(__isl_take isl_space *set_dim);
+__isl_give isl_map *isl_map_lex_le(__isl_take isl_space *set_dim);
+__isl_give isl_map *isl_map_lex_gt_first(__isl_take isl_space *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_space *dim, unsigned n);
+__isl_give isl_map *isl_map_lex_gt(__isl_take isl_space *set_dim);
+__isl_give isl_map *isl_map_lex_ge(__isl_take isl_space *set_dim);
+struct isl_map *isl_map_finalize(struct isl_map *map);
+void *isl_map_free(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
+struct isl_map *isl_map_extend(struct isl_map *base,
+		unsigned nparam, unsigned n_in, unsigned n_out);
+__isl_export
+__isl_give isl_map *isl_map_reverse(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_map *isl_map_union(
+		__isl_take isl_map *map1,
+		__isl_take isl_map *map2);
+struct isl_map *isl_map_union_disjoint(
+			struct isl_map *map1, struct isl_map *map2);
+__isl_export
+__isl_give isl_map *isl_map_intersect_domain(
+		__isl_take isl_map *map,
+		__isl_take isl_set *set);
+__isl_export
+__isl_give isl_map *isl_map_intersect_range(
+		__isl_take isl_map *map,
+		__isl_take isl_set *set);
+__isl_export
+__isl_give isl_map *isl_map_apply_domain(
+		__isl_take isl_map *map1,
+		__isl_take isl_map *map2);
+__isl_export
+__isl_give isl_map *isl_map_apply_range(
+		__isl_take isl_map *map1,
+		__isl_take isl_map *map2);
+__isl_give isl_basic_map *isl_basic_map_product(
+	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
+__isl_give isl_map *isl_map_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_basic_map *isl_basic_map_domain_product(
+	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
+__isl_give isl_basic_map *isl_basic_map_range_product(
+	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
+__isl_give isl_map *isl_map_domain_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_range_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_basic_map *isl_basic_map_flat_product(
+	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
+__isl_give isl_map *isl_map_flat_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_basic_map *isl_basic_map_flat_range_product(
+	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2);
+__isl_give isl_map *isl_map_flat_domain_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_flat_range_product(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_export
+__isl_give isl_map *isl_map_intersect(__isl_take isl_map *map1,
+				      __isl_take isl_map *map2);
+__isl_export
+__isl_give isl_map *isl_map_intersect_params(__isl_take isl_map *map,
+		__isl_take isl_set *params);
+__isl_export
+__isl_give isl_map *isl_map_subtract(
+		__isl_take isl_map *map1,
+		__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_subtract_domain(__isl_take isl_map *map,
+	__isl_take isl_set *dom);
+__isl_give isl_map *isl_map_subtract_range(__isl_take isl_map *map,
+	__isl_take isl_set *dom);
+__isl_export
+__isl_give isl_map *isl_map_complement(__isl_take isl_map *map);
+struct isl_map *isl_map_fix_input_si(struct isl_map *map,
+		unsigned input, int value);
+__isl_give isl_map *isl_map_fix(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned pos, isl_int value);
+__isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_map *isl_map_lower_bound_si(__isl_take isl_map *map,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_map *isl_map_upper_bound_si(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned pos, int value);
+__isl_export
+__isl_give isl_basic_set *isl_basic_map_deltas(__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_deltas_map(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_deltas_map(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_map *isl_map_detect_equalities(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_basic_map *isl_map_affine_hull(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_map_convex_hull(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_basic_map *isl_map_polyhedral_hull(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_add(__isl_take isl_basic_map *bmap,
+		enum isl_dim_type type, unsigned n);
+__isl_give isl_map *isl_map_add_dims(__isl_take isl_map *map,
+		enum isl_dim_type type, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_insert_dims(
+	__isl_take isl_basic_map *bmap, enum isl_dim_type type,
+	unsigned pos, unsigned n);
+__isl_give isl_map *isl_map_insert_dims(__isl_take isl_map *map,
+		enum isl_dim_type type, unsigned pos, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_move_dims(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_map *isl_map_move_dims(__isl_take isl_map *map,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_project_out(
+		__isl_take isl_basic_map *bmap,
+		enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
+		enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_remove_divs(
+	__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_remove_unknown_divs(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_remove_divs(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_map *isl_map_remove_dims(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_map *isl_basic_map_remove_divs_involving_dims(
+	__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_map *isl_map_remove_divs_involving_dims(__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned first, unsigned n);
+struct isl_map *isl_map_remove_inputs(struct isl_map *map,
+	unsigned first, unsigned n);
+
+__isl_give isl_basic_map *isl_basic_map_equate(__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_basic_map *isl_basic_map_order_ge(__isl_take isl_basic_map *bmap,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+
+__isl_export
+__isl_give isl_map *isl_set_identity(__isl_take isl_set *set);
+
+__isl_export
+int isl_basic_set_is_wrapping(__isl_keep isl_basic_set *bset);
+__isl_export
+int isl_set_is_wrapping(__isl_keep isl_set *set);
+__isl_give isl_basic_set *isl_basic_map_wrap(__isl_take isl_basic_map *bmap);
+__isl_give isl_set *isl_map_wrap(__isl_take isl_map *map);
+__isl_give isl_basic_map *isl_basic_set_unwrap(__isl_take isl_basic_set *bset);
+__isl_give isl_map *isl_set_unwrap(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_flatten(__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_map *isl_map_flatten(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_flatten_domain(
+	__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_flatten_range(
+	__isl_take isl_basic_map *bmap);
+__isl_export
+__isl_give isl_map *isl_map_flatten_domain(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_map *isl_map_flatten_range(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_flatten(__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_set *isl_set_flatten(__isl_take isl_set *set);
+__isl_give isl_map *isl_set_flatten_map(__isl_take isl_set *set);
+__isl_give isl_set *isl_map_params(__isl_take isl_map *map);
+__isl_give isl_set *isl_map_domain(__isl_take isl_map *bmap);
+__isl_give isl_set *isl_map_range(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
+__isl_constructor
+__isl_give isl_map *isl_map_from_basic_map(__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_from_domain(__isl_take isl_set *set);
+__isl_give isl_basic_map *isl_basic_map_from_domain(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_basic_map *isl_basic_map_from_range(
+	__isl_take isl_basic_set *bset);
+struct isl_map *isl_map_from_range(struct isl_set *set);
+__isl_give isl_basic_map *isl_basic_map_from_domain_and_range(
+	__isl_take isl_basic_set *domain, __isl_take isl_basic_set *range);
+__isl_give isl_map *isl_map_from_domain_and_range(__isl_take isl_set *domain,
+	__isl_take isl_set *range);
+__isl_give isl_map *isl_map_from_set(__isl_take isl_set *set,
+	__isl_take isl_space *dim);
+struct isl_set *isl_set_from_map(struct isl_map *map);
+__isl_export
+__isl_give isl_basic_map *isl_map_sample(__isl_take isl_map *map);
+
+int isl_map_plain_is_empty(__isl_keep isl_map *map);
+int isl_map_fast_is_empty(__isl_keep isl_map *map);
+int isl_map_plain_is_universe(__isl_keep isl_map *map);
+__isl_export
+int isl_map_is_empty(__isl_keep isl_map *map);
+__isl_export
+int isl_map_is_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+__isl_export
+int isl_map_is_strict_subset(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+__isl_export
+int isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+__isl_export
+int isl_map_is_disjoint(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+int isl_basic_map_is_single_valued(__isl_keep isl_basic_map *bmap);
+int isl_map_plain_is_single_valued(__isl_keep isl_map *map);
+__isl_export
+int isl_map_is_single_valued(__isl_keep isl_map *map);
+int isl_map_plain_is_injective(__isl_keep isl_map *map);
+__isl_export
+int isl_map_is_injective(__isl_keep isl_map *map);
+__isl_export
+int isl_map_is_bijective(__isl_keep isl_map *map);
+int isl_map_is_translation(__isl_keep isl_map *map);
+int isl_map_has_equal_space(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+
+int isl_basic_map_can_zip(__isl_keep isl_basic_map *bmap);
+int isl_map_can_zip(__isl_keep isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_zip(__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_zip(__isl_take isl_map *map);
+
+int isl_basic_map_can_curry(__isl_keep isl_basic_map *bmap);
+int isl_map_can_curry(__isl_keep isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_curry(__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_curry(__isl_take isl_map *map);
+
+int isl_basic_map_can_uncurry(__isl_keep isl_basic_map *bmap);
+int isl_map_can_uncurry(__isl_keep isl_map *map);
+__isl_give isl_basic_map *isl_basic_map_uncurry(__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_uncurry(__isl_take isl_map *map);
+
+__isl_give isl_map *isl_map_make_disjoint(__isl_take isl_map *map);
+__isl_give isl_map *isl_basic_map_compute_divs(__isl_take isl_basic_map *bmap);
+__isl_give isl_map *isl_map_compute_divs(__isl_take isl_map *map);
+__isl_give isl_map *isl_map_align_divs(__isl_take isl_map *map);
+
+__isl_give isl_map *isl_map_drop_constraints_involving_dims(
+	__isl_take isl_map *map,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+int isl_basic_map_involves_dims(__isl_keep isl_basic_map *bmap,
+	enum isl_dim_type type, unsigned first, unsigned n);
+int isl_map_involves_dims(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+void isl_map_print_internal(__isl_keep isl_map *map, FILE *out, int indent);
+
+int isl_map_plain_input_is_fixed(__isl_keep isl_map *map,
+		unsigned in, isl_int *val);
+int isl_map_plain_is_fixed(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos, isl_int *val);
+int isl_map_fast_is_fixed(__isl_keep isl_map *map,
+	enum isl_dim_type type, unsigned pos, isl_int *val);
+
+__isl_export
+__isl_give isl_basic_map *isl_basic_map_gist(__isl_take isl_basic_map *bmap,
+	__isl_take isl_basic_map *context);
+__isl_export
+__isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
+	__isl_take isl_map *context);
+__isl_export
+__isl_give isl_map *isl_map_gist_domain(__isl_take isl_map *map,
+	__isl_take isl_set *context);
+__isl_give isl_map *isl_map_gist_range(__isl_take isl_map *map,
+	__isl_take isl_set *context);
+__isl_give isl_map *isl_map_gist_params(__isl_take isl_map *map,
+	__isl_take isl_set *context);
+__isl_give isl_map *isl_map_gist_basic_map(__isl_take isl_map *map,
+	__isl_take isl_basic_map *context);
+
+__isl_export
+__isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
+
+int isl_map_plain_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+int isl_map_fast_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+
+uint32_t isl_map_get_hash(__isl_keep isl_map *map);
+
+__isl_export
+int isl_map_foreach_basic_map(__isl_keep isl_map *map,
+	int (*fn)(__isl_take isl_basic_map *bmap, void *user), void *user);
+
+__isl_give isl_map *isl_set_lifting(__isl_take isl_set *set);
+
+__isl_give isl_map *isl_map_fixed_power(__isl_take isl_map *map, isl_int exp);
+__isl_give isl_map *isl_map_power(__isl_take isl_map *map, int *exact);
+__isl_give isl_map *isl_map_reaching_path_lengths(__isl_take isl_map *map,
+	int *exact);
+__isl_give isl_map *isl_map_transitive_closure(__isl_take isl_map *map,
+	int *exact);
+
+__isl_give isl_map *isl_map_lex_le_map(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_lex_lt_map(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_lex_ge_map(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+__isl_give isl_map *isl_map_lex_gt_map(__isl_take isl_map *map1,
+	__isl_take isl_map *map2);
+
+__isl_give isl_basic_map *isl_basic_map_align_params(
+	__isl_take isl_basic_map *bmap, __isl_take isl_space *model);
+__isl_give isl_map *isl_map_align_params(__isl_take isl_map *map,
+	__isl_take isl_space *model);
+
+__isl_give isl_mat *isl_basic_map_equalities_matrix(
+		__isl_keep isl_basic_map *bmap, enum isl_dim_type c1,
+		enum isl_dim_type c2, enum isl_dim_type c3,
+		enum isl_dim_type c4, enum isl_dim_type c5);
+__isl_give isl_mat *isl_basic_map_inequalities_matrix(
+		__isl_keep isl_basic_map *bmap, enum isl_dim_type c1,
+		enum isl_dim_type c2, enum isl_dim_type c3,
+		enum isl_dim_type c4, enum isl_dim_type c5);
+__isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
+	__isl_take isl_space *dim,
+	__isl_take isl_mat *eq, __isl_take isl_mat *ineq, enum isl_dim_type c1,
+	enum isl_dim_type c2, enum isl_dim_type c3,
+	enum isl_dim_type c4, enum isl_dim_type c5);
+
+__isl_give isl_basic_map *isl_basic_map_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_basic_map *isl_basic_map_from_multi_aff(
+	__isl_take isl_multi_aff *maff);
+__isl_give isl_basic_map *isl_basic_map_from_aff_list(
+	__isl_take isl_space *domain_dim, __isl_take isl_aff_list *list);
+
+__isl_give isl_map *isl_map_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_map *isl_map_from_multi_aff(__isl_take isl_multi_aff *maff);
+
+__isl_give isl_pw_aff *isl_map_dim_max(__isl_take isl_map *map, int pos);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/map_type.h b/include/isl/map_type.h
new file mode 100644
index 0000000..67057e7
--- /dev/null
+++ b/include/isl/map_type.h
@@ -0,0 +1,28 @@
+#ifndef ISL_MAP_TYPE_H
+#define ISL_MAP_TYPE_H
+
+#include <isl/ctx.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct __isl_subclass(isl_map) isl_basic_map;
+typedef struct isl_basic_map isl_basic_map;
+struct __isl_subclass(isl_union_map) isl_map;
+typedef struct isl_map isl_map;
+
+#ifndef isl_basic_set
+struct __isl_subclass(isl_set) isl_basic_set;
+typedef struct isl_basic_set isl_basic_set;
+#endif
+#ifndef isl_set
+struct __isl_subclass(isl_union_set) isl_set;
+typedef struct isl_set isl_set;
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/mat.h b/include/isl/mat.h
new file mode 100644
index 0000000..997b07e
--- /dev/null
+++ b/include/isl/mat.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_MAT_H
+#define ISL_MAT_H
+
+#include <stdio.h>
+
+#include <isl/int.h>
+#include <isl/ctx.h>
+#include <isl/blk.h>
+#include <isl/vec.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_mat;
+typedef struct isl_mat	isl_mat;
+
+isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat);
+
+__isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
+	unsigned n_row, unsigned n_col);
+struct isl_mat *isl_mat_dup(struct isl_mat *mat);
+struct isl_mat *isl_mat_extend(struct isl_mat *mat,
+	unsigned n_row, unsigned n_col);
+struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row);
+__isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
+struct isl_mat *isl_mat_cow(struct isl_mat *mat);
+void isl_mat_free(__isl_take isl_mat *mat);
+
+int isl_mat_rows(__isl_keep isl_mat *mat);
+int isl_mat_cols(__isl_keep isl_mat *mat);
+int isl_mat_get_element(__isl_keep isl_mat *mat, int row, int col, isl_int *v);
+__isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
+	int row, int col, isl_int v);
+__isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
+	int row, int col, int v);
+
+struct isl_mat *isl_mat_swap_cols(struct isl_mat *mat, unsigned i, unsigned j);
+struct isl_mat *isl_mat_swap_rows(struct isl_mat *mat, unsigned i, unsigned j);
+
+struct isl_vec *isl_mat_vec_product(struct isl_mat *mat, struct isl_vec *vec);
+struct isl_vec *isl_vec_mat_product(struct isl_vec *vec, struct isl_mat *mat);
+__isl_give isl_vec *isl_mat_vec_inverse_product(__isl_take isl_mat *mat,
+						__isl_take isl_vec *vec);
+struct isl_mat *isl_mat_aff_direct_sum(struct isl_mat *left,
+					struct isl_mat *right);
+__isl_give isl_mat *isl_mat_diagonal(__isl_take isl_mat *mat1,
+	__isl_take isl_mat *mat2);
+struct isl_mat *isl_mat_left_hermite(struct isl_mat *M,
+	int neg, struct isl_mat **U, struct isl_mat **Q);
+struct isl_mat *isl_mat_lin_to_aff(struct isl_mat *mat);
+struct isl_mat *isl_mat_inverse_product(struct isl_mat *left,
+	struct isl_mat *right);
+struct isl_mat *isl_mat_product(struct isl_mat *left, struct isl_mat *right);
+struct isl_mat *isl_mat_transpose(struct isl_mat *mat);
+__isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
+__isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
+
+__isl_give isl_mat *isl_mat_scale_down_row(__isl_take isl_mat *mat, int row,
+	isl_int m);
+
+__isl_give isl_mat *isl_mat_normalize(__isl_take isl_mat *mat);
+__isl_give isl_mat *isl_mat_normalize_row(__isl_take isl_mat *mat, int row);
+
+struct isl_mat *isl_mat_drop_cols(struct isl_mat *mat,
+				unsigned col, unsigned n);
+struct isl_mat *isl_mat_drop_rows(struct isl_mat *mat,
+				unsigned row, unsigned n);
+__isl_give isl_mat *isl_mat_insert_cols(__isl_take isl_mat *mat,
+				unsigned col, unsigned n);
+__isl_give isl_mat *isl_mat_insert_rows(__isl_take isl_mat *mat,
+				unsigned row, unsigned n);
+__isl_give isl_mat *isl_mat_move_cols(__isl_take isl_mat *mat,
+	unsigned dst_col, unsigned src_col, unsigned n);
+__isl_give isl_mat *isl_mat_add_rows(__isl_take isl_mat *mat, unsigned n);
+__isl_give isl_mat *isl_mat_insert_zero_cols(__isl_take isl_mat *mat,
+	unsigned first, unsigned n);
+__isl_give isl_mat *isl_mat_add_zero_cols(__isl_take isl_mat *mat, unsigned n);
+__isl_give isl_mat *isl_mat_insert_zero_rows(__isl_take isl_mat *mat,
+	unsigned row, unsigned n);
+__isl_give isl_mat *isl_mat_add_zero_rows(__isl_take isl_mat *mat, unsigned n);
+
+void isl_mat_col_add(__isl_keep isl_mat *mat, int dst_col, int src_col);
+void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col);
+void isl_mat_col_submul(struct isl_mat *mat,
+			int dst_col, isl_int f, int src_col);
+
+struct isl_mat *isl_mat_unimodular_complete(struct isl_mat *M, int row);
+
+__isl_give isl_mat *isl_mat_from_row_vec(__isl_take isl_vec *vec);
+__isl_give isl_mat *isl_mat_concat(__isl_take isl_mat *top,
+	__isl_take isl_mat *bot);
+__isl_give isl_mat *isl_mat_vec_concat(__isl_take isl_mat *top,
+	__isl_take isl_vec *bot);
+
+int isl_mat_is_equal(__isl_keep isl_mat *mat1, __isl_keep isl_mat *mat2);
+
+int isl_mat_initial_non_zero_cols(__isl_keep isl_mat *mat);
+
+void isl_mat_print_internal(__isl_keep isl_mat *mat, FILE *out, int indent);
+void isl_mat_dump(__isl_keep isl_mat *mat);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/multi.h b/include/isl/multi.h
new file mode 100644
index 0000000..31b7aca
--- /dev/null
+++ b/include/isl/multi.h
@@ -0,0 +1,26 @@
+#ifndef ISL_MULTI_H
+#define ISL_MULTI_H
+
+#include <isl/list.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define ISL_DECLARE_MULTI(BASE)						\
+__isl_give isl_multi_##BASE *isl_multi_##BASE##_from_##BASE##_list(	\
+	__isl_take isl_space *space, __isl_take isl_##BASE##_list *list); \
+const char *isl_multi_##BASE##_get_tuple_name(				\
+	__isl_keep isl_multi_##BASE *multi, enum isl_dim_type type);	\
+__isl_give isl_multi_##BASE *isl_multi_##BASE##_set_##BASE(		\
+	__isl_take isl_multi_##BASE *multi, int pos,			\
+	__isl_take isl_##BASE *el);
+
+ISL_DECLARE_MULTI(aff)
+ISL_DECLARE_MULTI(pw_aff)
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/obj.h b/include/isl/obj.h
new file mode 100644
index 0000000..3f26c0a
--- /dev/null
+++ b/include/isl/obj.h
@@ -0,0 +1,64 @@
+#ifndef ISL_OBJ_H
+#define ISL_OBJ_H
+
+#include <isl/set_type.h>
+#include <isl/map_type.h>
+#include <isl/union_set_type.h>
+#include <isl/union_map_type.h>
+#include <isl/polynomial_type.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_obj_vtable {
+	void *(*copy)(void *v1);
+	void *(*add)(void *v1, void *v2);
+	__isl_give isl_printer *(*print)(__isl_take isl_printer *p, void *v);
+	void (*free)(void *v);
+};
+typedef struct isl_obj_vtable *isl_obj_type;
+extern struct isl_obj_vtable isl_obj_none_vtable;
+#define isl_obj_none		(&isl_obj_none_vtable)
+extern struct isl_obj_vtable isl_obj_int_vtable;
+#define isl_obj_int		(&isl_obj_int_vtable)
+extern struct isl_obj_vtable isl_obj_set_vtable;
+#define isl_obj_set		(&isl_obj_set_vtable)
+extern struct isl_obj_vtable isl_obj_union_set_vtable;
+#define isl_obj_union_set	(&isl_obj_union_set_vtable)
+extern struct isl_obj_vtable isl_obj_map_vtable;
+#define isl_obj_map		(&isl_obj_map_vtable)
+extern struct isl_obj_vtable isl_obj_union_map_vtable;
+#define isl_obj_union_map	(&isl_obj_union_map_vtable)
+extern struct isl_obj_vtable isl_obj_pw_qpolynomial_vtable;
+#define isl_obj_pw_qpolynomial	(&isl_obj_pw_qpolynomial_vtable)
+extern struct isl_obj_vtable isl_obj_union_pw_qpolynomial_vtable;
+#define isl_obj_union_pw_qpolynomial	(&isl_obj_union_pw_qpolynomial_vtable)
+extern struct isl_obj_vtable isl_obj_pw_qpolynomial_fold_vtable;
+#define isl_obj_pw_qpolynomial_fold	(&isl_obj_pw_qpolynomial_fold_vtable)
+extern struct isl_obj_vtable isl_obj_union_pw_qpolynomial_fold_vtable;
+#define isl_obj_union_pw_qpolynomial_fold	(&isl_obj_union_pw_qpolynomial_fold_vtable)
+struct isl_obj {
+	isl_obj_type	type;
+	void		*v;
+};
+
+struct isl_int_obj;
+typedef struct isl_int_obj isl_int_obj;
+
+__isl_give isl_int_obj *isl_int_obj_alloc(isl_ctx *ctx, isl_int v);
+void isl_int_obj_free(__isl_take isl_int_obj *i);
+__isl_give isl_int_obj *isl_int_obj_add(__isl_take isl_int_obj *i1,
+	__isl_take isl_int_obj *i2);
+__isl_give isl_int_obj *isl_int_obj_sub(__isl_take isl_int_obj *i1,
+	__isl_take isl_int_obj *i2);
+__isl_give isl_int_obj *isl_int_obj_mul(__isl_take isl_int_obj *i1,
+	__isl_take isl_int_obj *i2);
+void isl_int_obj_get_int(__isl_keep isl_int_obj *i, isl_int *v);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/options.h b/include/isl/options.h
new file mode 100644
index 0000000..b0c9a43
--- /dev/null
+++ b/include/isl/options.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_OPTIONS_H
+#define ISL_OPTIONS_H
+
+#include <isl/arg.h>
+#include <isl/ctx.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_options;
+
+ISL_ARG_DECL(isl_options, struct isl_options, isl_options_args)
+
+#define			ISL_BOUND_BERNSTEIN	0
+#define			ISL_BOUND_RANGE		1
+int isl_options_set_bound(isl_ctx *ctx, int val);
+int isl_options_get_bound(isl_ctx *ctx);
+
+#define			ISL_ON_ERROR_WARN	0
+#define			ISL_ON_ERROR_CONTINUE	1
+#define			ISL_ON_ERROR_ABORT	2
+int isl_options_set_on_error(isl_ctx *ctx, int val);
+int isl_options_get_on_error(isl_ctx *ctx);
+
+int isl_options_set_gbr_only_first(isl_ctx *ctx, int val);
+int isl_options_get_gbr_only_first(isl_ctx *ctx);
+
+#define		ISL_SCHEDULE_ALGORITHM_ISL		0
+#define		ISL_SCHEDULE_ALGORITHM_FEAUTRIER	1
+int isl_options_set_schedule_algorithm(isl_ctx *ctx, int val);
+int isl_options_get_schedule_algorithm(isl_ctx *ctx);
+
+int isl_options_set_coalesce_bounded_wrapping(isl_ctx *ctx, int val);
+int isl_options_get_coalesce_bounded_wrapping(isl_ctx *ctx);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/point.h b/include/isl/point.h
new file mode 100644
index 0000000..c17e605
--- /dev/null
+++ b/include/isl/point.h
@@ -0,0 +1,44 @@
+#ifndef ISL_POINT_H
+#define ISL_POINT_H
+
+#include <stdio.h>
+#include <isl/space.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_point;
+typedef struct isl_point isl_point;
+
+isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt);
+__isl_give isl_space *isl_point_get_space(__isl_keep isl_point *pnt);
+
+__isl_give isl_point *isl_point_zero(__isl_take isl_space *dim);
+__isl_give isl_point *isl_point_copy(__isl_keep isl_point *pnt);
+void isl_point_free(__isl_take isl_point *pnt);
+
+int isl_point_get_coordinate(__isl_keep isl_point *pnt,
+	enum isl_dim_type type, int pos, isl_int *v);
+__isl_give isl_point *isl_point_set_coordinate(__isl_take isl_point *pnt,
+	enum isl_dim_type type, int pos, isl_int v);
+
+__isl_give isl_point *isl_point_add_ui(__isl_take isl_point *pnt,
+	enum isl_dim_type type, int pos, unsigned val);
+__isl_give isl_point *isl_point_sub_ui(__isl_take isl_point *pnt,
+	enum isl_dim_type type, int pos, unsigned val);
+
+__isl_give isl_point *isl_point_void(__isl_take isl_space *dim);
+int isl_point_is_void(__isl_keep isl_point *pnt);
+
+__isl_give isl_printer *isl_printer_print_point(
+	__isl_take isl_printer *printer, __isl_keep isl_point *pnt);
+void isl_point_dump(__isl_keep isl_point *pnt);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/polynomial.h b/include/isl/polynomial.h
new file mode 100644
index 0000000..6354c60
--- /dev/null
+++ b/include/isl/polynomial.h
@@ -0,0 +1,593 @@
+#ifndef ISL_POLYNOMIAL_H
+#define ISL_POLYNOMIAL_H
+
+#include <isl/ctx.h>
+#include <isl/constraint.h>
+#include <isl/space.h>
+#include <isl/set_type.h>
+#include <isl/point.h>
+#include <isl/printer.h>
+#include <isl/union_set_type.h>
+#include <isl/aff_type.h>
+#include <isl/polynomial_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+isl_ctx *isl_qpolynomial_get_ctx(__isl_keep isl_qpolynomial *qp);
+__isl_give isl_space *isl_qpolynomial_get_domain_space(
+	__isl_keep isl_qpolynomial *qp);
+__isl_give isl_space *isl_qpolynomial_get_space(__isl_keep isl_qpolynomial *qp);
+unsigned isl_qpolynomial_dim(__isl_keep isl_qpolynomial *qp,
+	enum isl_dim_type type);
+int isl_qpolynomial_involves_dims(__isl_keep isl_qpolynomial *qp,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name(
+	__isl_take isl_qpolynomial *qp,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(__isl_take isl_space *dim);
+__isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(__isl_take isl_space *dim);
+__isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(__isl_take isl_space *dim);
+__isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(__isl_take isl_space *dim);
+__isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(__isl_take isl_space *dim);
+__isl_give isl_qpolynomial *isl_qpolynomial_rat_cst_on_domain(__isl_take isl_space *dim,
+	const isl_int n, const isl_int d);
+__isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_qpolynomial *isl_qpolynomial_copy(__isl_keep isl_qpolynomial *qp);
+void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp);
+
+int isl_qpolynomial_plain_is_equal(__isl_keep isl_qpolynomial *qp1,
+	__isl_keep isl_qpolynomial *qp2);
+int isl_qpolynomial_is_zero(__isl_keep isl_qpolynomial *qp);
+int isl_qpolynomial_is_nan(__isl_keep isl_qpolynomial *qp);
+int isl_qpolynomial_is_infty(__isl_keep isl_qpolynomial *qp);
+int isl_qpolynomial_is_neginfty(__isl_keep isl_qpolynomial *qp);
+int isl_qpolynomial_sgn(__isl_keep isl_qpolynomial *qp);
+int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp,
+	isl_int *n, isl_int *d);
+void isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp, isl_int *d);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_neg(__isl_take isl_qpolynomial *qp);
+__isl_give isl_qpolynomial *isl_qpolynomial_add(__isl_take isl_qpolynomial *qp1,
+	__isl_take isl_qpolynomial *qp2);
+__isl_give isl_qpolynomial *isl_qpolynomial_sub(__isl_take isl_qpolynomial *qp1,
+	__isl_take isl_qpolynomial *qp2);
+__isl_give isl_qpolynomial *isl_qpolynomial_mul(__isl_take isl_qpolynomial *qp1,
+	__isl_take isl_qpolynomial *qp2);
+__isl_give isl_qpolynomial *isl_qpolynomial_pow(__isl_take isl_qpolynomial *qp,
+	unsigned power);
+__isl_give isl_qpolynomial *isl_qpolynomial_add_isl_int(
+	__isl_take isl_qpolynomial *qp, isl_int v);
+__isl_give isl_qpolynomial *isl_qpolynomial_mul_isl_int(
+	__isl_take isl_qpolynomial *qp, isl_int v);
+__isl_give isl_qpolynomial *isl_qpolynomial_scale(
+	__isl_take isl_qpolynomial *qp, isl_int v);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_insert_dims(
+	__isl_take isl_qpolynomial *qp, enum isl_dim_type type,
+	unsigned first, unsigned n);
+__isl_give isl_qpolynomial *isl_qpolynomial_add_dims(
+	__isl_take isl_qpolynomial *qp, enum isl_dim_type type, unsigned n);
+__isl_give isl_qpolynomial *isl_qpolynomial_move_dims(
+	__isl_take isl_qpolynomial *qp,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_qpolynomial *isl_qpolynomial_project_domain_on_params(
+	__isl_take isl_qpolynomial *qp);
+__isl_give isl_qpolynomial *isl_qpolynomial_drop_dims(
+	__isl_take isl_qpolynomial *qp,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_substitute(
+	__isl_take isl_qpolynomial *qp,
+	enum isl_dim_type type, unsigned first, unsigned n,
+	__isl_keep isl_qpolynomial **subs);
+
+int isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp,
+	__isl_keep isl_basic_set *bset,
+	int (*fn)(__isl_take isl_basic_set *bset,
+		  __isl_take isl_qpolynomial *poly, void *user), void *user);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_homogenize(
+	__isl_take isl_qpolynomial *poly);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_align_params(
+	__isl_take isl_qpolynomial *qp, __isl_take isl_space *model);
+
+isl_ctx *isl_term_get_ctx(__isl_keep isl_term *term);
+
+__isl_give isl_term *isl_term_copy(__isl_keep isl_term *term);
+void isl_term_free(__isl_take isl_term *term);
+
+unsigned isl_term_dim(__isl_keep isl_term *term, enum isl_dim_type type);
+void isl_term_get_num(__isl_keep isl_term *term, isl_int *n);
+void isl_term_get_den(__isl_keep isl_term *term, isl_int *d);
+int isl_term_get_exp(__isl_keep isl_term *term,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_aff *isl_term_get_div(__isl_keep isl_term *term, unsigned pos);
+
+int isl_qpolynomial_foreach_term(__isl_keep isl_qpolynomial *qp,
+	int (*fn)(__isl_take isl_term *term, void *user), void *user);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_eval(
+	__isl_take isl_qpolynomial *qp, __isl_take isl_point *pnt);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
+	__isl_take isl_qpolynomial *qp, __isl_take isl_set *context);
+__isl_give isl_qpolynomial *isl_qpolynomial_gist(
+	__isl_take isl_qpolynomial *qp, __isl_take isl_set *context);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_from_constraint(
+	__isl_take isl_constraint *c, enum isl_dim_type type, unsigned pos);
+__isl_give isl_qpolynomial *isl_qpolynomial_from_term(__isl_take isl_term *term);
+__isl_give isl_qpolynomial *isl_qpolynomial_from_aff(__isl_take isl_aff *aff);
+__isl_give isl_basic_map *isl_basic_map_from_qpolynomial(
+	__isl_take isl_qpolynomial *qp);
+
+__isl_give isl_printer *isl_printer_print_qpolynomial(
+	__isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp);
+void isl_qpolynomial_print(__isl_keep isl_qpolynomial *qp, FILE *out,
+	unsigned output_format);
+void isl_qpolynomial_dump(__isl_keep isl_qpolynomial *qp);
+
+isl_ctx *isl_pw_qpolynomial_get_ctx(__isl_keep isl_pw_qpolynomial *pwqp);
+
+int isl_pw_qpolynomial_plain_is_equal(__isl_keep isl_pw_qpolynomial *pwqp1,
+	__isl_keep isl_pw_qpolynomial *pwqp2);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(__isl_take isl_space *dim);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(__isl_take isl_set *set,
+	__isl_take isl_qpolynomial *qp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial(
+	__isl_take isl_qpolynomial *qp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
+	__isl_keep isl_pw_qpolynomial *pwqp);
+void *isl_pw_qpolynomial_free(__isl_take isl_pw_qpolynomial *pwqp);
+
+int isl_pw_qpolynomial_is_zero(__isl_keep isl_pw_qpolynomial *pwqp);
+
+__isl_give isl_space *isl_pw_qpolynomial_get_domain_space(
+	__isl_keep isl_pw_qpolynomial *pwqp);
+__isl_give isl_space *isl_pw_qpolynomial_get_space(
+	__isl_keep isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_reset_domain_space(
+	__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_space *dim);
+unsigned isl_pw_qpolynomial_dim(__isl_keep isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type);
+int isl_pw_qpolynomial_involves_dims(__isl_keep isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned first, unsigned n);
+int isl_pw_qpolynomial_has_equal_space(__isl_keep isl_pw_qpolynomial *pwqp1,
+	__isl_keep isl_pw_qpolynomial *pwqp2);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_set_dim_name(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_set *isl_pw_qpolynomial_domain(__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
+	__isl_take isl_pw_qpolynomial *pwpq, __isl_take isl_set *set);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_params(
+	__isl_take isl_pw_qpolynomial *pwpq, __isl_take isl_set *set);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_domain_on_params(
+	__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_drop_dims(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_split_dims(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
+	__isl_take isl_pw_qpolynomial *pwqp1,
+	__isl_take isl_pw_qpolynomial *pwqp2);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
+	__isl_take isl_pw_qpolynomial *pwqp1,
+	__isl_take isl_pw_qpolynomial *pwqp2);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
+	__isl_take isl_pw_qpolynomial *pwqp1,
+	__isl_take isl_pw_qpolynomial *pwqp2);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
+	__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
+	__isl_take isl_pw_qpolynomial *pwqp1,
+	__isl_take isl_pw_qpolynomial *pwqp2);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul_isl_int(
+	__isl_take isl_pw_qpolynomial *pwqp, isl_int v);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
+	__isl_take isl_pw_qpolynomial *pwqp, unsigned exponent);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_insert_dims(
+	__isl_take isl_pw_qpolynomial *pwqp, enum isl_dim_type type,
+	unsigned first, unsigned n);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_dims(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_move_dims(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_dim(
+	__isl_take isl_pw_qpolynomial *pwqp,
+	enum isl_dim_type type, unsigned n, isl_int v);
+
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
+	__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_point *pnt);
+
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_max(
+	__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_min(
+	__isl_take isl_pw_qpolynomial *pwqp);
+
+int isl_pw_qpolynomial_foreach_piece(__isl_keep isl_pw_qpolynomial *pwqp,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial *qp,
+		    void *user), void *user);
+int isl_pw_qpolynomial_foreach_lifted_piece(__isl_keep isl_pw_qpolynomial *pwqp,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial *qp,
+		    void *user), void *user);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff(
+	__isl_take isl_pw_aff *pwaff);
+
+__isl_constructor
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_str(isl_ctx *ctx,
+		const char *str);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_file(isl_ctx *ctx,
+		FILE *input);
+__isl_give isl_printer *isl_printer_print_pw_qpolynomial(
+	__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp);
+void isl_pw_qpolynomial_print(__isl_keep isl_pw_qpolynomial *pwqp, FILE *out,
+	unsigned output_format);
+void isl_pw_qpolynomial_dump(__isl_keep isl_pw_qpolynomial *pwqp);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_coalesce(
+	__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
+	__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_set *context);
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
+	__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_set *context);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_split_periods(
+	__isl_take isl_pw_qpolynomial *pwqp, int max_periods);
+
+__isl_give isl_pw_qpolynomial *isl_basic_set_multiplicative_call(
+	__isl_take isl_basic_set *bset,
+	__isl_give isl_pw_qpolynomial *(*fn)(__isl_take isl_basic_set *bset));
+
+isl_ctx *isl_qpolynomial_fold_get_ctx(__isl_keep isl_qpolynomial_fold *fold);
+enum isl_fold isl_qpolynomial_fold_get_type(__isl_keep isl_qpolynomial_fold *fold);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_empty(enum isl_fold type,
+	__isl_take isl_space *dim);
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_alloc(
+	enum isl_fold type, __isl_take isl_qpolynomial *qp);
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
+	__isl_keep isl_qpolynomial_fold *fold);
+void isl_qpolynomial_fold_free(__isl_take isl_qpolynomial_fold *fold);
+
+int isl_qpolynomial_fold_is_empty(__isl_keep isl_qpolynomial_fold *fold);
+int isl_qpolynomial_fold_plain_is_equal(__isl_keep isl_qpolynomial_fold *fold1,
+	__isl_keep isl_qpolynomial_fold *fold2);
+
+__isl_give isl_space *isl_qpolynomial_fold_get_space(
+	__isl_keep isl_qpolynomial_fold *fold);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_fold(
+	__isl_take isl_qpolynomial_fold *fold1,
+	__isl_take isl_qpolynomial_fold *fold2);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_mul_isl_int(
+	__isl_take isl_qpolynomial_fold *fold, isl_int v);
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale(
+	__isl_take isl_qpolynomial_fold *fold, isl_int v);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_move_dims(
+	__isl_take isl_qpolynomial_fold *fold,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_substitute(
+	__isl_take isl_qpolynomial_fold *fold,
+	enum isl_dim_type type, unsigned first, unsigned n,
+	__isl_keep isl_qpolynomial **subs);
+
+__isl_give isl_qpolynomial *isl_qpolynomial_fold_eval(
+	__isl_take isl_qpolynomial_fold *fold, __isl_take isl_point *pnt);
+
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params(
+	__isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *context);
+__isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
+	__isl_take isl_qpolynomial_fold *fold, __isl_take isl_set *context);
+
+int isl_qpolynomial_fold_foreach_qpolynomial(
+	__isl_keep isl_qpolynomial_fold *fold,
+	int (*fn)(__isl_take isl_qpolynomial *qp, void *user), void *user);
+
+__isl_give isl_printer *isl_printer_print_qpolynomial_fold(
+	__isl_take isl_printer *p, __isl_keep isl_qpolynomial_fold *fold);
+void isl_qpolynomial_fold_print(__isl_keep isl_qpolynomial_fold *fold, FILE *out,
+	unsigned output_format);
+void isl_qpolynomial_fold_dump(__isl_keep isl_qpolynomial_fold *fold);
+
+isl_ctx *isl_pw_qpolynomial_fold_get_ctx(__isl_keep isl_pw_qpolynomial_fold *pwf);
+
+int isl_pw_qpolynomial_fold_plain_is_equal(
+	__isl_keep isl_pw_qpolynomial_fold *pwf1,
+	__isl_keep isl_pw_qpolynomial_fold *pwf2);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_from_pw_qpolynomial(
+	enum isl_fold type, __isl_take isl_pw_qpolynomial *pwqp);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_alloc(
+	enum isl_fold type,
+	__isl_take isl_set *set, __isl_take isl_qpolynomial_fold *fold);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
+	__isl_keep isl_pw_qpolynomial_fold *pwf);
+void *isl_pw_qpolynomial_fold_free(__isl_take isl_pw_qpolynomial_fold *pwf);
+
+int isl_pw_qpolynomial_fold_is_zero(__isl_keep isl_pw_qpolynomial_fold *pwf);
+
+__isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space(
+	__isl_keep isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_space *isl_pw_qpolynomial_fold_get_space(
+	__isl_keep isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_reset_space(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_space *dim);
+unsigned isl_pw_qpolynomial_fold_dim(__isl_keep isl_pw_qpolynomial_fold *pwf,
+	enum isl_dim_type type);
+int isl_pw_qpolynomial_fold_has_equal_space(
+	__isl_keep isl_pw_qpolynomial_fold *pwf1,
+	__isl_keep isl_pw_qpolynomial_fold *pwf2);
+
+size_t isl_pw_qpolynomial_fold_size(__isl_keep isl_pw_qpolynomial_fold *pwf);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_zero(
+	__isl_take isl_space *dim, enum isl_fold type);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_set_dim_name(
+	__isl_take isl_pw_qpolynomial_fold *pwf,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_set *isl_pw_qpolynomial_fold_domain(
+	__isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_intersect_domain(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *set);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_intersect_params(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *set);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
+	__isl_take isl_pw_qpolynomial_fold *pwf1,
+	__isl_take isl_pw_qpolynomial_fold *pwf2);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
+	__isl_take isl_pw_qpolynomial_fold *pwf1,
+	__isl_take isl_pw_qpolynomial_fold *pwf2);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add_disjoint(
+	__isl_take isl_pw_qpolynomial_fold *pwf1,
+	__isl_take isl_pw_qpolynomial_fold *pwf2);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_mul_isl_int(
+	__isl_take isl_pw_qpolynomial_fold *pwf, isl_int v);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_project_domain_on_params(
+	__isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_drop_dims(
+	__isl_take isl_pw_qpolynomial_fold *pwf,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_move_dims(
+	__isl_take isl_pw_qpolynomial_fold *pwf,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fix_dim(
+	__isl_take isl_pw_qpolynomial_fold *pwf,
+	enum isl_dim_type type, unsigned n, isl_int v);
+
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_point *pnt);
+
+int isl_pw_qpolynomial_fold_foreach_piece(
+	__isl_keep isl_pw_qpolynomial_fold *pwf,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial_fold *fold,
+		    void *user), void *user);
+int isl_pw_qpolynomial_fold_foreach_lifted_piece(
+	__isl_keep isl_pw_qpolynomial_fold *pwf,
+	int (*fn)(__isl_take isl_set *set, __isl_take isl_qpolynomial_fold *fold,
+		    void *user), void *user);
+
+__isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
+	__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf);
+void isl_pw_qpolynomial_fold_print(__isl_keep isl_pw_qpolynomial_fold *pwf,
+	FILE *out, unsigned output_format);
+void isl_pw_qpolynomial_fold_dump(__isl_keep isl_pw_qpolynomial_fold *pwf);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
+	__isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *context);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist_params(
+	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_set *context);
+
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_max(
+	__isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_min(
+	__isl_take isl_pw_qpolynomial_fold *pwf);
+
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
+	__isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, int *tight);
+__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_bound(
+	__isl_take isl_pw_qpolynomial_fold *pwf, int *tight);
+__isl_give isl_pw_qpolynomial_fold *isl_set_apply_pw_qpolynomial_fold(
+	__isl_take isl_set *set, __isl_take isl_pw_qpolynomial_fold *pwf,
+	int *tight);
+__isl_give isl_pw_qpolynomial_fold *isl_map_apply_pw_qpolynomial_fold(
+	__isl_take isl_map *map, __isl_take isl_pw_qpolynomial_fold *pwf,
+	int *tight);
+
+__isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
+	__isl_take isl_pw_qpolynomial *pwqp, int sign);
+
+isl_ctx *isl_union_pw_qpolynomial_get_ctx(
+	__isl_keep isl_union_pw_qpolynomial *upwqp);
+
+int isl_union_pw_qpolynomial_plain_is_equal(
+	__isl_keep isl_union_pw_qpolynomial *upwqp1,
+	__isl_keep isl_union_pw_qpolynomial *upwqp2);
+
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
+	__isl_take isl_space *dim);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
+	__isl_take isl_union_pw_qpolynomial *upwqp,
+	__isl_take isl_pw_qpolynomial *pwqp);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
+	__isl_keep isl_union_pw_qpolynomial *upwqp);
+void *isl_union_pw_qpolynomial_free(__isl_take isl_union_pw_qpolynomial *upwqp);
+
+__isl_constructor
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_read_from_str(
+	isl_ctx *ctx, const char *str);
+
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
+	__isl_take isl_union_pw_qpolynomial *upwqp1,
+	__isl_take isl_union_pw_qpolynomial *upwqp2);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
+	__isl_take isl_union_pw_qpolynomial *upwqp1,
+	__isl_take isl_union_pw_qpolynomial *upwqp2);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
+	__isl_take isl_union_pw_qpolynomial *upwqp1,
+	__isl_take isl_union_pw_qpolynomial *upwqp2);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul_isl_int(
+	__isl_take isl_union_pw_qpolynomial *upwqp, isl_int v);
+
+__isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
+	__isl_take isl_union_pw_qpolynomial *upwqp);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
+	__isl_take isl_union_pw_qpolynomial *upwpq,
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_params(
+	__isl_take isl_union_pw_qpolynomial *upwpq,
+	__isl_take isl_set *set);
+
+__isl_give isl_space *isl_union_pw_qpolynomial_get_space(
+	__isl_keep isl_union_pw_qpolynomial *upwqp);
+
+__isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
+	__isl_take isl_union_pw_qpolynomial *upwqp, __isl_take isl_point *pnt);
+
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
+	__isl_take isl_union_pw_qpolynomial *upwqp);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
+	__isl_take isl_union_pw_qpolynomial *upwqp,
+	__isl_take isl_union_set *context);
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist_params(
+	__isl_take isl_union_pw_qpolynomial *upwqp,
+	__isl_take isl_set *context);
+
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_align_params(
+	__isl_take isl_union_pw_qpolynomial *upwqp,
+	__isl_take isl_space *model);
+
+int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
+	__isl_keep isl_union_pw_qpolynomial *upwqp,
+	int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user), void *user);
+__isl_give isl_pw_qpolynomial *isl_union_pw_qpolynomial_extract_pw_qpolynomial(
+	__isl_keep isl_union_pw_qpolynomial *upwqp, __isl_take isl_space *dim);
+
+__isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
+	__isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial *upwqp);
+
+isl_ctx *isl_union_pw_qpolynomial_fold_get_ctx(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+
+int isl_union_pw_qpolynomial_fold_plain_is_equal(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf1,
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf2);
+
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_from_pw_qpolynomial_fold(__isl_take isl_pw_qpolynomial_fold *pwf);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_zero(
+	__isl_take isl_space *dim, enum isl_fold type);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold_pw_qpolynomial_fold(
+	__isl_take isl_union_pw_qpolynomial_fold *upwqp,
+	__isl_take isl_pw_qpolynomial_fold *pwqp);
+void *isl_union_pw_qpolynomial_fold_free(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf1,
+	__isl_take isl_union_pw_qpolynomial_fold *upwf2);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_add_union_pw_qpolynomial(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_union_pw_qpolynomial *upwqp);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_mul_isl_int(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf, isl_int v);
+
+__isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_pw_qpolynomial_fold *
+isl_union_pw_qpolynomial_fold_intersect_params(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_set *set);
+
+enum isl_fold isl_union_pw_qpolynomial_fold_get_type(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+__isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+
+__isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_point *pnt);
+
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_union_set *context);
+__isl_give isl_union_pw_qpolynomial_fold *
+isl_union_pw_qpolynomial_fold_gist_params(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_set *context);
+
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_align_params(
+	__isl_take isl_union_pw_qpolynomial_fold *upwf,
+	__isl_take isl_space *model);
+
+int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf,
+	int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
+		    void *user), void *user);
+__isl_give isl_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_extract_pw_qpolynomial_fold(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf, __isl_take isl_space *dim);
+
+__isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
+	__isl_take isl_printer *p,
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
+
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
+	__isl_take isl_union_pw_qpolynomial *upwqp,
+	enum isl_fold type, int *tight);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_set_apply_union_pw_qpolynomial_fold(
+	__isl_take isl_union_set *uset,
+	__isl_take isl_union_pw_qpolynomial_fold *upwf, int *tight);
+__isl_give isl_union_pw_qpolynomial_fold *isl_union_map_apply_union_pw_qpolynomial_fold(
+	__isl_take isl_union_map *umap,
+	__isl_take isl_union_pw_qpolynomial_fold *upwf, int *tight);
+
+__isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_to_polynomial(
+	__isl_take isl_union_pw_qpolynomial *upwqp, int sign);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/polynomial_type.h b/include/isl/polynomial_type.h
new file mode 100644
index 0000000..df432bd
--- /dev/null
+++ b/include/isl/polynomial_type.h
@@ -0,0 +1,31 @@
+#ifndef ISL_POLYNOMIAL_TYPE_H
+#define ISL_POLYNOMIAL_TYPE_H
+
+struct isl_qpolynomial;
+typedef struct isl_qpolynomial isl_qpolynomial;
+
+struct isl_term;
+typedef struct isl_term isl_term;
+
+struct __isl_export isl_pw_qpolynomial;
+typedef struct isl_pw_qpolynomial isl_pw_qpolynomial;
+
+enum isl_fold {
+	isl_fold_min,
+	isl_fold_max,
+	isl_fold_list
+};
+
+struct isl_qpolynomial_fold;
+typedef struct isl_qpolynomial_fold isl_qpolynomial_fold;
+
+struct isl_pw_qpolynomial_fold;
+typedef struct isl_pw_qpolynomial_fold isl_pw_qpolynomial_fold;
+
+struct __isl_export isl_union_pw_qpolynomial;
+typedef struct isl_union_pw_qpolynomial isl_union_pw_qpolynomial;
+
+struct isl_union_pw_qpolynomial_fold;
+typedef struct isl_union_pw_qpolynomial_fold isl_union_pw_qpolynomial_fold;
+
+#endif
diff --git a/include/isl/printer.h b/include/isl/printer.h
new file mode 100644
index 0000000..0979fc2
--- /dev/null
+++ b/include/isl/printer.h
@@ -0,0 +1,62 @@
+#ifndef ISL_PRINTER_H
+#define ISL_PRINTER_H
+
+#include <stdio.h>
+#include <isl/ctx.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_printer;
+typedef struct isl_printer isl_printer;
+
+__isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx, FILE *file);
+__isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
+void *isl_printer_free(__isl_take isl_printer *printer);
+
+isl_ctx *isl_printer_get_ctx(__isl_keep isl_printer *printer);
+FILE *isl_printer_get_file(__isl_keep isl_printer *printer);
+
+__isl_give char *isl_printer_get_str(__isl_keep isl_printer *printer);
+
+__isl_give isl_printer *isl_printer_set_indent(__isl_take isl_printer *p,
+	int indent);
+__isl_give isl_printer *isl_printer_indent(__isl_take isl_printer *p,
+	int indent);
+
+#define ISL_FORMAT_ISL			0
+#define ISL_FORMAT_POLYLIB		1
+#define ISL_FORMAT_POLYLIB_CONSTRAINTS	2
+#define ISL_FORMAT_OMEGA		3
+#define ISL_FORMAT_C			4
+#define ISL_FORMAT_LATEX		5
+#define ISL_FORMAT_EXT_POLYLIB		6
+__isl_give isl_printer *isl_printer_set_output_format(__isl_take isl_printer *p,
+	int output_format);
+int isl_printer_get_output_format(__isl_keep isl_printer *p);
+
+__isl_give isl_printer *isl_printer_set_prefix(__isl_take isl_printer *p,
+	const char *prefix);
+__isl_give isl_printer *isl_printer_set_suffix(__isl_take isl_printer *p,
+	const char *suffix);
+__isl_give isl_printer *isl_printer_set_isl_int_width(__isl_take isl_printer *p,
+	int width);
+
+__isl_give isl_printer *isl_printer_start_line(__isl_take isl_printer *p);
+__isl_give isl_printer *isl_printer_end_line(__isl_take isl_printer *p);
+__isl_give isl_printer *isl_printer_print_double(__isl_take isl_printer *p,
+	double d);
+__isl_give isl_printer *isl_printer_print_int(__isl_take isl_printer *p, int i);
+__isl_give isl_printer *isl_printer_print_isl_int(__isl_take isl_printer *p,
+	isl_int i);
+__isl_give isl_printer *isl_printer_print_str(__isl_take isl_printer *p,
+	const char *s);
+
+__isl_give isl_printer *isl_printer_flush(__isl_take isl_printer *p);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/schedule.h b/include/isl/schedule.h
new file mode 100644
index 0000000..385c6c4
--- /dev/null
+++ b/include/isl/schedule.h
@@ -0,0 +1,62 @@
+#ifndef ISL_SCHEDULE_H
+#define ISL_SCHEDULE_H
+
+#include <isl/union_set_type.h>
+#include <isl/union_map_type.h>
+#include <isl/band.h>
+#include <isl/list.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_schedule;
+typedef struct isl_schedule isl_schedule;
+
+int isl_options_set_schedule_max_coefficient(isl_ctx *ctx, int val);
+int isl_options_get_schedule_max_coefficient(isl_ctx *ctx);
+
+int isl_options_set_schedule_max_constant_term(isl_ctx *ctx, int val);
+int isl_options_get_schedule_max_constant_term(isl_ctx *ctx);
+
+int isl_options_set_schedule_maximize_band_depth(isl_ctx *ctx, int val);
+int isl_options_get_schedule_maximize_band_depth(isl_ctx *ctx);
+
+int isl_options_set_schedule_outer_zero_distance(isl_ctx *ctx, int val);
+int isl_options_get_schedule_outer_zero_distance(isl_ctx *ctx);
+
+int isl_options_set_schedule_split_scaled(isl_ctx *ctx, int val);
+int isl_options_get_schedule_split_scaled(isl_ctx *ctx);
+
+int isl_options_set_schedule_separate_components(isl_ctx *ctx, int val);
+int isl_options_get_schedule_separate_components(isl_ctx *ctx);
+
+#define		ISL_SCHEDULE_FUSE_MAX			0
+#define		ISL_SCHEDULE_FUSE_MIN			1
+int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
+int isl_options_get_schedule_fuse(isl_ctx *ctx);
+
+__isl_give isl_schedule *isl_union_set_compute_schedule(
+	__isl_take isl_union_set *domain,
+	__isl_take isl_union_map *validity,
+	__isl_take isl_union_map *proximity);
+void *isl_schedule_free(__isl_take isl_schedule *sched);
+__isl_give isl_union_map *isl_schedule_get_map(__isl_keep isl_schedule *sched);
+
+isl_ctx *isl_schedule_get_ctx(__isl_keep isl_schedule *sched);
+
+__isl_give isl_band_list *isl_schedule_get_band_forest(
+	__isl_keep isl_schedule *schedule);
+
+__isl_give isl_printer *isl_printer_print_schedule(__isl_take isl_printer *p,
+	__isl_keep isl_schedule *schedule);
+void isl_schedule_dump(__isl_keep isl_schedule *schedule);
+
+int isl_schedule_foreach_band(__isl_keep isl_schedule *sched,
+	int (*fn)(__isl_keep isl_band *band, void *user), void *user);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/seq.h b/include/isl/seq.h
new file mode 100644
index 0000000..0963352
--- /dev/null
+++ b/include/isl/seq.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_SEQ_H
+#define ISL_SEQ_H
+
+#include <sys/types.h>
+#include <isl/int.h>
+#include <isl/ctx.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Some common operations on sequences of isl_int's */
+
+void isl_seq_clr(isl_int *p, unsigned len);
+void isl_seq_set(isl_int *p, isl_int v, unsigned len);
+void isl_seq_set_si(isl_int *p, int v, unsigned len);
+void isl_seq_neg(isl_int *dat, isl_int *src, unsigned len);
+void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len);
+void isl_seq_addmul(isl_int *dst, isl_int f, isl_int *src, unsigned len);
+void isl_seq_submul(isl_int *dst, isl_int f, isl_int *src, unsigned len);
+void isl_seq_swp_or_cpy(isl_int *dst, isl_int *src, unsigned len);
+void isl_seq_scale(isl_int *dst, isl_int *src, isl_int f, unsigned len);
+void isl_seq_scale_down(isl_int *dst, isl_int *src, isl_int f, unsigned len);
+void isl_seq_cdiv_q(isl_int *dst, isl_int *src, isl_int m, unsigned len);
+void isl_seq_fdiv_q(isl_int *dst, isl_int *src, isl_int m, unsigned len);
+void isl_seq_fdiv_r(isl_int *dst, isl_int *src, isl_int m, unsigned len);
+void isl_seq_combine(isl_int *dst, isl_int m1, isl_int *src1,
+			isl_int m2, isl_int *src2, unsigned len);
+void isl_seq_elim(isl_int *dst, isl_int *src, unsigned pos, unsigned len,
+		  isl_int *m);
+void isl_seq_abs_max(isl_int *p, unsigned len, isl_int *max);
+void isl_seq_gcd(isl_int *p, unsigned len, isl_int *gcd);
+void isl_seq_lcm(isl_int *p, unsigned len, isl_int *lcm);
+void isl_seq_normalize(struct isl_ctx *ctx, isl_int *p, unsigned len);
+void isl_seq_inner_product(isl_int *p1, isl_int *p2, unsigned len,
+			   isl_int *prod);
+int isl_seq_first_non_zero(isl_int *p, unsigned len);
+int isl_seq_last_non_zero(isl_int *p, unsigned len);
+int isl_seq_abs_min_non_zero(isl_int *p, unsigned len);
+int isl_seq_eq(isl_int *p1, isl_int *p2, unsigned len);
+int isl_seq_cmp(isl_int *p1, isl_int *p2, unsigned len);
+int isl_seq_is_neg(isl_int *p1, isl_int *p2, unsigned len);
+
+uint32_t isl_seq_get_hash(isl_int *p, unsigned len);
+uint32_t isl_seq_get_hash_bits(isl_int *p, unsigned len, unsigned bits);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/set.h b/include/isl/set.h
new file mode 100644
index 0000000..3f65fea
--- /dev/null
+++ b/include/isl/set.h
@@ -0,0 +1,535 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_SET_H
+#define ISL_SET_H
+
+#include <isl/map_type.h>
+#include <isl/aff_type.h>
+#include <isl/list.h>
+#include <isl/mat.h>
+#include <isl/point.h>
+#include <isl/local_space.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+unsigned isl_basic_set_n_dim(__isl_keep isl_basic_set *bset);
+unsigned isl_basic_set_n_param(__isl_keep isl_basic_set *bset);
+unsigned isl_basic_set_total_dim(const struct isl_basic_set *bset);
+unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset,
+				enum isl_dim_type type);
+
+unsigned isl_set_n_dim(__isl_keep isl_set *set);
+unsigned isl_set_n_param(__isl_keep isl_set *set);
+unsigned isl_set_dim(__isl_keep isl_set *set, enum isl_dim_type type);
+
+isl_ctx *isl_basic_set_get_ctx(__isl_keep isl_basic_set *bset);
+isl_ctx *isl_set_get_ctx(__isl_keep isl_set *set);
+__isl_give isl_space *isl_basic_set_get_space(__isl_keep isl_basic_set *bset);
+__isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set);
+__isl_give isl_set *isl_set_reset_space(__isl_take isl_set *set,
+	__isl_take isl_space *dim);
+
+__isl_give isl_aff *isl_basic_set_get_div(__isl_keep isl_basic_set *bset,
+	int pos);
+
+__isl_give isl_local_space *isl_basic_set_get_local_space(
+	__isl_keep isl_basic_set *bset);
+
+const char *isl_basic_set_get_tuple_name(__isl_keep isl_basic_set *bset);
+int isl_set_has_tuple_name(__isl_keep isl_set *set);
+const char *isl_set_get_tuple_name(__isl_keep isl_set *set);
+__isl_give isl_basic_set *isl_basic_set_set_tuple_name(
+	__isl_take isl_basic_set *set, const char *s);
+__isl_give isl_set *isl_set_set_tuple_name(__isl_take isl_set *set,
+	const char *s);
+const char *isl_basic_set_get_dim_name(__isl_keep isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_basic_set *isl_basic_set_set_dim_name(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos, const char *s);
+int isl_set_has_dim_name(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+const char *isl_set_get_dim_name(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_set *isl_set_set_dim_name(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned pos, const char *s);
+
+__isl_give isl_id *isl_basic_set_get_dim_id(__isl_keep isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_set *isl_set_set_dim_id(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+int isl_set_has_dim_id(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_set_get_dim_id(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_set *isl_set_set_tuple_id(__isl_take isl_set *set,
+	__isl_take isl_id *id);
+__isl_give isl_set *isl_set_reset_tuple_id(__isl_take isl_set *set);
+int isl_set_has_tuple_id(__isl_keep isl_set *set);
+__isl_give isl_id *isl_set_get_tuple_id(__isl_keep isl_set *set);
+
+int isl_set_find_dim_by_id(__isl_keep isl_set *set, enum isl_dim_type type,
+	__isl_keep isl_id *id);
+int isl_set_find_dim_by_name(__isl_keep isl_set *set, enum isl_dim_type type,
+	const char *name);
+
+int isl_basic_set_is_rational(__isl_keep isl_basic_set *bset);
+
+struct isl_basic_set *isl_basic_set_alloc(struct isl_ctx *ctx,
+		unsigned nparam, unsigned dim, unsigned extra,
+		unsigned n_eq, unsigned n_ineq);
+struct isl_basic_set *isl_basic_set_extend(struct isl_basic_set *base,
+		unsigned nparam, unsigned dim, unsigned extra,
+		unsigned n_eq, unsigned n_ineq);
+struct isl_basic_set *isl_basic_set_extend_constraints(
+		struct isl_basic_set *base, unsigned n_eq, unsigned n_ineq);
+struct isl_basic_set *isl_basic_set_finalize(struct isl_basic_set *bset);
+void *isl_basic_set_free(__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_copy(__isl_keep isl_basic_set *bset);
+struct isl_basic_set *isl_basic_set_dup(struct isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_empty(__isl_take isl_space *dim);
+struct isl_basic_set *isl_basic_set_empty_like(struct isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_universe(__isl_take isl_space *dim);
+__isl_give isl_basic_set *isl_basic_set_nat_universe(__isl_take isl_space *dim);
+struct isl_basic_set *isl_basic_set_universe_like(struct isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_universe_like_set(
+	__isl_keep isl_set *model);
+struct isl_basic_set *isl_basic_set_interval(struct isl_ctx *ctx,
+	isl_int min, isl_int max);
+__isl_give isl_basic_set *isl_basic_set_positive_orthant(
+	__isl_take isl_space *space);
+void isl_basic_set_print_internal(__isl_keep isl_basic_set *bset,
+				FILE *out, int indent);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_intersect(
+		__isl_take isl_basic_set *bset1,
+		__isl_take isl_basic_set *bset2);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_intersect_params(
+	__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_apply(
+		__isl_take isl_basic_set *bset,
+		__isl_take isl_basic_map *bmap);
+__isl_give isl_basic_set *isl_basic_set_preimage_multi_aff(
+	__isl_take isl_basic_set *bset, __isl_take isl_multi_aff *ma);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_affine_hull(
+		__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_remove_dims(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_sample(__isl_take isl_basic_set *bset);
+struct isl_basic_set *isl_basic_set_simplify(struct isl_basic_set *bset);
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_detect_equalities(
+						__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_remove_redundancies(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_set *isl_set_remove_redundancies(__isl_take isl_set *set);
+__isl_give isl_basic_set *isl_basic_set_list_product(
+	__isl_take struct isl_basic_set_list *list);
+
+__isl_give isl_basic_set *isl_basic_set_read_from_file(isl_ctx *ctx,
+	FILE *input);
+__isl_constructor
+__isl_give isl_basic_set *isl_basic_set_read_from_str(isl_ctx *ctx,
+	const char *str);
+__isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx, FILE *input);
+__isl_constructor
+__isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx, const char *str);
+void isl_basic_set_dump(__isl_keep isl_basic_set *bset);
+void isl_set_dump(__isl_keep isl_set *set);
+__isl_give isl_printer *isl_printer_print_basic_set(
+	__isl_take isl_printer *printer, __isl_keep isl_basic_set *bset);
+__isl_give isl_printer *isl_printer_print_set(__isl_take isl_printer *printer,
+	__isl_keep isl_set *map);
+void isl_basic_set_print(__isl_keep isl_basic_set *bset, FILE *out, int indent,
+	const char *prefix, const char *suffix, unsigned output_format);
+void isl_set_print(__isl_keep struct isl_set *set, FILE *out, int indent,
+	unsigned output_format);
+__isl_give isl_basic_set *isl_basic_set_fix(__isl_take isl_basic_set *bset,
+		enum isl_dim_type type, unsigned pos, isl_int value);
+__isl_give isl_basic_set *isl_basic_set_fix_si(__isl_take isl_basic_set *bset,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_set *isl_set_lower_bound_si(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_set *isl_set_lower_bound(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned pos, isl_int value);
+__isl_give isl_set *isl_set_upper_bound_si(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned pos, int value);
+__isl_give isl_set *isl_set_upper_bound(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned pos, isl_int value);
+
+__isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
+	enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2);
+
+struct isl_basic_set *isl_basic_set_from_underlying_set(
+	struct isl_basic_set *bset, struct isl_basic_set *like);
+struct isl_set *isl_set_from_underlying_set(
+	struct isl_set *set, struct isl_basic_set *like);
+struct isl_set *isl_set_to_underlying_set(struct isl_set *set);
+
+__isl_export
+int isl_basic_set_is_equal(
+		struct isl_basic_set *bset1, struct isl_basic_set *bset2);
+
+__isl_give isl_set *isl_basic_set_partial_lexmin(
+		__isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_set *isl_basic_set_partial_lexmax(
+		__isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_set *isl_set_partial_lexmin(
+		__isl_take isl_set *set, __isl_take isl_set *dom,
+		__isl_give isl_set **empty);
+__isl_give isl_set *isl_set_partial_lexmax(
+		__isl_take isl_set *set, __isl_take isl_set *dom,
+		__isl_give isl_set **empty);
+__isl_export
+__isl_give isl_set *isl_basic_set_lexmin(__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_set *isl_basic_set_lexmax(__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_set *isl_set_lexmin(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_set *isl_set_lexmax(__isl_take isl_set *set);
+__isl_give isl_pw_multi_aff *isl_basic_set_partial_lexmin_pw_multi_aff(
+	__isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
+	__isl_give isl_set **empty);
+__isl_give isl_pw_multi_aff *isl_basic_set_partial_lexmax_pw_multi_aff(
+	__isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
+	__isl_give isl_set **empty);
+
+__isl_export
+__isl_give isl_set *isl_basic_set_union(
+		__isl_take isl_basic_set *bset1,
+		__isl_take isl_basic_set *bset2);
+
+int isl_basic_set_compare_at(struct isl_basic_set *bset1,
+	struct isl_basic_set *bset2, int pos);
+int isl_set_follows_at(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2, int pos);
+
+__isl_give isl_basic_set *isl_basic_set_params(__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_from_params(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_set *isl_set_params(__isl_take isl_set *set);
+__isl_give isl_set *isl_set_from_params(__isl_take isl_set *set);
+
+int isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos, unsigned n, int *signs);
+
+int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
+int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
+int isl_basic_set_fast_is_empty(__isl_keep isl_basic_set *bset);
+__isl_export
+int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
+int isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset);
+__isl_export
+int isl_basic_set_is_subset(__isl_keep isl_basic_set *bset1,
+	__isl_keep isl_basic_set *bset2);
+
+struct isl_set *isl_set_alloc(struct isl_ctx *ctx,
+		unsigned nparam, unsigned dim, int n, unsigned flags);
+struct isl_set *isl_set_extend(struct isl_set *base,
+		unsigned nparam, unsigned dim);
+__isl_give isl_set *isl_set_empty(__isl_take isl_space *dim);
+struct isl_set *isl_set_empty_like(struct isl_set *set);
+__isl_give isl_set *isl_set_universe(__isl_take isl_space *dim);
+__isl_give isl_set *isl_set_nat_universe(__isl_take isl_space *dim);
+__isl_give isl_set *isl_set_universe_like(__isl_keep isl_set *model);
+__isl_give isl_set *isl_set_add_basic_set(__isl_take isl_set *set,
+						__isl_take isl_basic_set *bset);
+struct isl_set *isl_set_finalize(struct isl_set *set);
+__isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
+void *isl_set_free(__isl_take isl_set *set);
+struct isl_set *isl_set_dup(struct isl_set *set);
+__isl_constructor
+__isl_give isl_set *isl_set_from_basic_set(__isl_take isl_basic_set *bset);
+__isl_export
+__isl_give isl_basic_set *isl_set_sample(__isl_take isl_set *set);
+__isl_give isl_point *isl_basic_set_sample_point(__isl_take isl_basic_set *bset);
+__isl_give isl_point *isl_set_sample_point(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_set *isl_set_detect_equalities(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_basic_set *isl_set_affine_hull(__isl_take isl_set *set);
+__isl_give isl_basic_set *isl_set_convex_hull(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_basic_set *isl_set_polyhedral_hull(__isl_take isl_set *set);
+__isl_give isl_basic_set *isl_set_simple_hull(__isl_take isl_set *set);
+__isl_give isl_basic_set *isl_set_unshifted_simple_hull(
+	__isl_take isl_set *set);
+struct isl_basic_set *isl_set_bounded_simple_hull(struct isl_set *set);
+__isl_give isl_set *isl_set_recession_cone(__isl_take isl_set *set);
+
+struct isl_set *isl_set_union_disjoint(
+			struct isl_set *set1, struct isl_set *set2);
+__isl_export
+__isl_give isl_set *isl_set_union(
+		__isl_take isl_set *set1,
+		__isl_take isl_set *set2);
+__isl_give isl_set *isl_set_product(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_give isl_basic_set *isl_basic_set_flat_product(
+	__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2);
+__isl_give isl_set *isl_set_flat_product(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_export
+__isl_give isl_set *isl_set_intersect(
+		__isl_take isl_set *set1,
+		__isl_take isl_set *set2);
+__isl_export
+__isl_give isl_set *isl_set_intersect_params(__isl_take isl_set *set,
+		__isl_take isl_set *params);
+__isl_export
+__isl_give isl_set *isl_set_subtract(
+		__isl_take isl_set *set1,
+		__isl_take isl_set *set2);
+__isl_export
+__isl_give isl_set *isl_set_complement(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_set *isl_set_apply(
+		__isl_take isl_set *set,
+		__isl_take isl_map *map);
+__isl_give isl_set *isl_set_preimage_multi_aff(__isl_take isl_set *set,
+	__isl_take isl_multi_aff *ma);
+__isl_give isl_set *isl_set_preimage_pw_multi_aff(__isl_take isl_set *set,
+	__isl_take isl_pw_multi_aff *pma);
+__isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned pos, isl_int value);
+struct isl_set *isl_set_fix_dim_si(struct isl_set *set,
+		unsigned dim, int value);
+struct isl_set *isl_set_lower_bound_dim(struct isl_set *set,
+		unsigned dim, isl_int value);
+__isl_give isl_basic_set *isl_basic_set_insert_dims(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned pos, unsigned n);
+__isl_give isl_set *isl_set_insert_dims(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned pos, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_add_dims(__isl_take isl_basic_set *bset,
+		enum isl_dim_type type, unsigned n);
+/* deprecated */
+__isl_give isl_basic_set *isl_basic_set_add(__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned n);
+__isl_give isl_set *isl_set_add_dims(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_move_dims(__isl_take isl_basic_set *bset,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_set *isl_set_move_dims(__isl_take isl_set *set,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_project_out(
+		__isl_take isl_basic_set *bset,
+		enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
+		enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_remove_divs(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_basic_set_eliminate(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned first, unsigned n);
+struct isl_set *isl_set_eliminate_dims(struct isl_set *set,
+		unsigned first, unsigned n);
+__isl_give isl_set *isl_set_remove_dims(__isl_take isl_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_remove_divs_involving_dims(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_set *isl_set_remove_divs_involving_dims(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_remove_unknown_divs(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_set *isl_set_remove_unknown_divs(__isl_take isl_set *set);
+__isl_give isl_set *isl_set_remove_divs(__isl_take isl_set *set);
+__isl_give isl_set *isl_set_split_dims(__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+__isl_give isl_basic_set *isl_basic_set_drop_constraints_involving_dims(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_basic_set *isl_basic_set_drop_constraints_not_involving_dims(
+	__isl_take isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+__isl_give isl_set *isl_set_drop_constraints_involving_dims(
+	__isl_take isl_set *set,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+int isl_basic_set_involves_dims(__isl_keep isl_basic_set *bset,
+	enum isl_dim_type type, unsigned first, unsigned n);
+int isl_set_involves_dims(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned first, unsigned n);
+
+void isl_set_print_internal(__isl_keep isl_set *set, FILE *out, int indent);
+int isl_set_plain_is_empty(__isl_keep isl_set *set);
+int isl_set_fast_is_empty(__isl_keep isl_set *set);
+int isl_set_plain_is_universe(__isl_keep isl_set *set);
+int isl_set_fast_is_universe(__isl_keep isl_set *set);
+int isl_set_is_params(__isl_keep isl_set *set);
+__isl_export
+int isl_set_is_empty(__isl_keep isl_set *set);
+int isl_set_is_bounded(__isl_keep isl_set *set);
+__isl_export
+int isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+__isl_export
+int isl_set_is_strict_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+__isl_export
+int isl_set_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+__isl_export
+int isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+int isl_set_is_singleton(__isl_keep isl_set *set);
+int isl_set_is_box(__isl_keep isl_set *set);
+int isl_set_has_equal_space(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+
+__isl_give isl_set *isl_set_sum(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_give isl_basic_set *isl_basic_set_neg(__isl_take isl_basic_set *bset);
+__isl_give isl_set *isl_set_neg(__isl_take isl_set *set);
+
+__isl_give isl_set *isl_set_make_disjoint(__isl_take isl_set *set);
+struct isl_set *isl_basic_set_compute_divs(struct isl_basic_set *bset);
+__isl_give isl_set *isl_set_compute_divs(__isl_take isl_set *set);
+__isl_give isl_set *isl_set_align_divs(__isl_take isl_set *set);
+
+struct isl_basic_set *isl_set_copy_basic_set(struct isl_set *set);
+struct isl_set *isl_set_drop_basic_set(struct isl_set *set,
+						struct isl_basic_set *bset);
+
+int isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
+	unsigned dim, isl_int *val);
+
+int isl_set_plain_is_fixed(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos, isl_int *val);
+int isl_set_plain_dim_is_fixed(__isl_keep isl_set *set,
+	unsigned dim, isl_int *val);
+int isl_set_fast_dim_is_fixed(__isl_keep isl_set *set,
+	unsigned dim, isl_int *val);
+int isl_set_plain_dim_has_fixed_lower_bound(__isl_keep isl_set *set,
+	unsigned dim, isl_int *val);
+int isl_set_dim_is_bounded(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
+	enum isl_dim_type type, unsigned pos);
+
+__isl_export
+__isl_give isl_basic_set *isl_basic_set_gist(__isl_take isl_basic_set *bset,
+					    __isl_take isl_basic_set *context);
+__isl_give isl_set *isl_set_gist_basic_set(__isl_take isl_set *set,
+	__isl_take isl_basic_set *context);
+__isl_export
+__isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
+	__isl_take isl_set *context);
+__isl_give isl_set *isl_set_gist_params(__isl_take isl_set *set,
+	__isl_take isl_set *context);
+int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
+	int pos, isl_int *modulo, isl_int *residue);
+int isl_set_dim_residue_class(struct isl_set *set,
+	int pos, isl_int *modulo, isl_int *residue);
+
+__isl_export
+__isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
+
+int isl_set_plain_cmp(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+int isl_set_plain_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+int isl_set_fast_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2);
+int isl_set_fast_is_disjoint(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2);
+
+uint32_t isl_set_get_hash(struct isl_set *set);
+
+int isl_set_dim_is_unique(struct isl_set *set, unsigned dim);
+
+int isl_set_n_basic_set(__isl_keep isl_set *set);
+__isl_export
+int isl_set_foreach_basic_set(__isl_keep isl_set *set,
+	int (*fn)(__isl_take isl_basic_set *bset, void *user), void *user);
+
+int isl_set_foreach_point(__isl_keep isl_set *set,
+	int (*fn)(__isl_take isl_point *pnt, void *user), void *user);
+int isl_set_count(__isl_keep isl_set *set, isl_int *count);
+int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset,
+	isl_int max, isl_int *count);
+int isl_set_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count);
+
+__isl_give isl_basic_set *isl_basic_set_from_point(__isl_take isl_point *pnt);
+__isl_give isl_set *isl_set_from_point(__isl_take isl_point *pnt);
+__isl_give isl_basic_set *isl_basic_set_box_from_points(
+	__isl_take isl_point *pnt1, __isl_take isl_point *pnt2);
+__isl_give isl_set *isl_set_box_from_points(__isl_take isl_point *pnt1,
+	__isl_take isl_point *pnt2);
+
+__isl_give isl_basic_set *isl_basic_set_lift(__isl_take isl_basic_set *bset);
+__isl_give isl_set *isl_set_lift(__isl_take isl_set *set);
+
+__isl_give isl_map *isl_set_lex_le_set(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_give isl_map *isl_set_lex_lt_set(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_give isl_map *isl_set_lex_ge_set(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+__isl_give isl_map *isl_set_lex_gt_set(__isl_take isl_set *set1,
+	__isl_take isl_set *set2);
+
+int isl_set_size(__isl_keep isl_set *set);
+
+__isl_give isl_basic_set *isl_basic_set_align_params(
+	__isl_take isl_basic_set *bset, __isl_take isl_space *model);
+__isl_give isl_set *isl_set_align_params(__isl_take isl_set *set,
+	__isl_take isl_space *model);
+
+__isl_give isl_mat *isl_basic_set_equalities_matrix(
+	__isl_keep isl_basic_set *bset, enum isl_dim_type c1,
+	enum isl_dim_type c2, enum isl_dim_type c3, enum isl_dim_type c4);
+__isl_give isl_mat *isl_basic_set_inequalities_matrix(
+	__isl_keep isl_basic_set *bset, enum isl_dim_type c1,
+	enum isl_dim_type c2, enum isl_dim_type c3, enum isl_dim_type c4);
+__isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
+	__isl_take isl_space *dim,
+	__isl_take isl_mat *eq, __isl_take isl_mat *ineq, enum isl_dim_type c1,
+	enum isl_dim_type c2, enum isl_dim_type c3, enum isl_dim_type c4);
+
+__isl_give isl_mat *isl_basic_set_reduced_basis(__isl_keep isl_basic_set *bset);
+
+__isl_give isl_basic_set *isl_basic_set_coefficients(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_set_coefficients(__isl_take isl_set *set);
+__isl_give isl_basic_set *isl_basic_set_solutions(
+	__isl_take isl_basic_set *bset);
+__isl_give isl_basic_set *isl_set_solutions(__isl_take isl_set *set);
+
+__isl_give isl_pw_aff *isl_set_dim_max(__isl_take isl_set *set, int pos);
+__isl_give isl_pw_aff *isl_set_dim_min(__isl_take isl_set *set, int pos);
+
+__isl_give char *isl_set_to_str(__isl_keep isl_set *set);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/set_type.h b/include/isl/set_type.h
new file mode 100644
index 0000000..ce349e1
--- /dev/null
+++ b/include/isl/set_type.h
@@ -0,0 +1,6 @@
+#ifndef ISL_SET_TYPE_H
+#define ISL_SET_TYPE_H
+
+#include <isl/map_type.h>
+
+#endif
diff --git a/include/isl/space.h b/include/isl/space.h
new file mode 100644
index 0000000..3ce4102
--- /dev/null
+++ b/include/isl/space.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_SPACE_H
+#define ISL_SPACE_H
+
+#include <isl/ctx.h>
+#include <isl/id.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_space;
+typedef struct isl_space isl_space;
+
+enum isl_dim_type {
+	isl_dim_cst,
+	isl_dim_param,
+	isl_dim_in,
+	isl_dim_out,
+	isl_dim_set = isl_dim_out,
+	isl_dim_div,
+	isl_dim_all
+};
+
+isl_ctx *isl_space_get_ctx(__isl_keep isl_space *dim);
+__isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
+			unsigned nparam, unsigned n_in, unsigned n_out);
+__isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
+			unsigned nparam, unsigned dim);
+__isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx, unsigned nparam);
+__isl_give isl_space *isl_space_copy(__isl_keep isl_space *dim);
+void *isl_space_free(__isl_take isl_space *dim);
+
+int isl_space_is_params(__isl_keep isl_space *space);
+int isl_space_is_set(__isl_keep isl_space *space);
+int isl_space_is_map(__isl_keep isl_space *space);
+
+__isl_give isl_space *isl_space_set_tuple_name(__isl_take isl_space *dim,
+	enum isl_dim_type type, const char *s);
+int isl_space_has_tuple_name(__isl_keep isl_space *space,
+	enum isl_dim_type type);
+const char *isl_space_get_tuple_name(__isl_keep isl_space *dim,
+				 enum isl_dim_type type);
+__isl_give isl_space *isl_space_set_tuple_id(__isl_take isl_space *dim,
+	enum isl_dim_type type, __isl_take isl_id *id);
+__isl_give isl_space *isl_space_reset_tuple_id(__isl_take isl_space *dim,
+	enum isl_dim_type type);
+int isl_space_has_tuple_id(__isl_keep isl_space *dim, enum isl_dim_type type);
+__isl_give isl_id *isl_space_get_tuple_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type);
+
+__isl_give isl_space *isl_space_set_dim_id(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
+int isl_space_has_dim_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_id *isl_space_get_dim_id(__isl_keep isl_space *dim,
+	enum isl_dim_type type, unsigned pos);
+
+int isl_space_find_dim_by_id(__isl_keep isl_space *dim, enum isl_dim_type type,
+	__isl_keep isl_id *id);
+int isl_space_find_dim_by_name(__isl_keep isl_space *space,
+	enum isl_dim_type type, const char *name);
+
+int isl_space_has_dim_name(__isl_keep isl_space *space,
+	enum isl_dim_type type, unsigned pos);
+__isl_give isl_space *isl_space_set_dim_name(__isl_take isl_space *dim,
+				 enum isl_dim_type type, unsigned pos,
+				 __isl_keep const char *name);
+__isl_keep const char *isl_space_get_dim_name(__isl_keep isl_space *dim,
+				 enum isl_dim_type type, unsigned pos);
+
+__isl_give isl_space *isl_space_extend(__isl_take isl_space *dim,
+			unsigned nparam, unsigned n_in, unsigned n_out);
+__isl_give isl_space *isl_space_add_dims(__isl_take isl_space *dim, enum isl_dim_type type,
+		unsigned n);
+__isl_give isl_space *isl_space_move_dims(__isl_take isl_space *dim,
+	enum isl_dim_type dst_type, unsigned dst_pos,
+	enum isl_dim_type src_type, unsigned src_pos, unsigned n);
+__isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned pos, unsigned n);
+__isl_give isl_space *isl_space_join(__isl_take isl_space *left,
+	__isl_take isl_space *right);
+__isl_give isl_space *isl_space_product(__isl_take isl_space *left,
+	__isl_take isl_space *right);
+__isl_give isl_space *isl_space_domain_product(__isl_take isl_space *left,
+	__isl_take isl_space *right);
+__isl_give isl_space *isl_space_range_product(__isl_take isl_space *left,
+	__isl_take isl_space *right);
+__isl_give isl_space *isl_space_map_from_set(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_map_from_domain_and_range(
+	__isl_take isl_space *domain, __isl_take isl_space *range);
+__isl_give isl_space *isl_space_reverse(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *dim,
+	enum isl_dim_type type, unsigned first, unsigned num);
+__isl_give isl_space *isl_space_drop_inputs(__isl_take isl_space *dim,
+		unsigned first, unsigned n);
+__isl_give isl_space *isl_space_drop_outputs(__isl_take isl_space *dim,
+		unsigned first, unsigned n);
+__isl_give isl_space *isl_space_domain(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_from_domain(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_range(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_from_range(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_params(__isl_take isl_space *space);
+__isl_give isl_space *isl_space_set_from_params(__isl_take isl_space *space);
+
+__isl_give isl_space *isl_space_align_params(__isl_take isl_space *dim1,
+	__isl_take isl_space *dim2);
+
+int isl_space_is_wrapping(__isl_keep isl_space *dim);
+__isl_give isl_space *isl_space_wrap(__isl_take isl_space *dim);
+__isl_give isl_space *isl_space_unwrap(__isl_take isl_space *dim);
+
+int isl_space_can_zip(__isl_keep isl_space *dim);
+__isl_give isl_space *isl_space_zip(__isl_take isl_space *dim);
+
+int isl_space_can_curry(__isl_keep isl_space *space);
+__isl_give isl_space *isl_space_curry(__isl_take isl_space *space);
+
+int isl_space_can_uncurry(__isl_keep isl_space *space);
+__isl_give isl_space *isl_space_uncurry(__isl_take isl_space *space);
+
+int isl_space_is_domain(__isl_keep isl_space *space1,
+	__isl_keep isl_space *space2);
+int isl_space_is_range(__isl_keep isl_space *space1,
+	__isl_keep isl_space *space2);
+int isl_space_is_equal(__isl_keep isl_space *space1,
+	__isl_keep isl_space *space2);
+int isl_space_match(__isl_keep isl_space *dim1, enum isl_dim_type dim1_type,
+	__isl_keep isl_space *dim2, enum isl_dim_type dim2_type);
+int isl_space_tuple_match(__isl_keep isl_space *dim1, enum isl_dim_type dim1_type,
+			__isl_keep isl_space *dim2, enum isl_dim_type dim2_type);
+int isl_space_compatible(__isl_keep isl_space *dim1,
+	__isl_keep isl_space *dim2);
+unsigned isl_space_dim(__isl_keep isl_space *dim, enum isl_dim_type type);
+
+__isl_give isl_printer *isl_printer_print_space(__isl_take isl_printer *p,
+	__isl_keep isl_space *dim);
+void isl_space_dump(__isl_keep isl_space *dim);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/stdint.h b/include/isl/stdint.h
new file mode 100644
index 0000000..3a8b71a
--- /dev/null
+++ b/include/isl/stdint.h
@@ -0,0 +1,9 @@
+#ifndef _ISL_INCLUDE_ISL_STDINT_H
+#define _ISL_INCLUDE_ISL_STDINT_H 1
+#ifndef _GENERATED_STDINT_H
+#define _GENERATED_STDINT_H "isl 0.11.1"
+/* generated using gnu compiler x86_64-linux-gcc (GCC) 4.6.x-google 20120106 (prerelease) */
+#define _STDINT_HAVE_STDINT_H 1
+#include <stdint.h>
+#endif
+#endif
diff --git a/include/isl/stream.h b/include/isl/stream.h
new file mode 100644
index 0000000..3706bcd
--- /dev/null
+++ b/include/isl/stream.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_STREAM_H
+#define ISL_STREAM_H
+
+#include <stdio.h>
+#include <isl/hash.h>
+#include <isl/aff_type.h>
+#include <isl/obj.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+enum isl_token_type { ISL_TOKEN_ERROR = -1,
+			ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
+			ISL_TOKEN_IDENT, ISL_TOKEN_GE,
+			ISL_TOKEN_LE, ISL_TOKEN_GT, ISL_TOKEN_LT,
+			ISL_TOKEN_NE, ISL_TOKEN_EQ_EQ,
+			ISL_TOKEN_LEX_GE, ISL_TOKEN_LEX_LE,
+			ISL_TOKEN_LEX_GT, ISL_TOKEN_LEX_LT,
+			ISL_TOKEN_TO, ISL_TOKEN_AND,
+			ISL_TOKEN_OR, ISL_TOKEN_EXISTS, ISL_TOKEN_NOT,
+			ISL_TOKEN_DEF, ISL_TOKEN_INFTY, ISL_TOKEN_NAN,
+			ISL_TOKEN_MIN, ISL_TOKEN_MAX, ISL_TOKEN_RAT,
+			ISL_TOKEN_TRUE, ISL_TOKEN_FALSE,
+			ISL_TOKEN_CEILD, ISL_TOKEN_FLOORD, ISL_TOKEN_MOD,
+			ISL_TOKEN_STRING,
+			ISL_TOKEN_MAP, ISL_TOKEN_AFF,
+			ISL_TOKEN_LAST };
+
+struct isl_token {
+	int type;
+
+	unsigned int on_new_line : 1;
+	unsigned is_keyword : 1;
+	int line;
+	int col;
+
+	union {
+		isl_int	v;
+		char	*s;
+		isl_map *map;
+		isl_pw_aff *pwaff;
+	} u;
+};
+
+void isl_token_free(struct isl_token *tok);
+
+struct isl_stream {
+	struct isl_ctx	*ctx;
+	FILE        	*file;
+	const char  	*str;
+	int	    	line;
+	int	    	col;
+	int	    	eof;
+
+	char	    	*buffer;
+	size_t	    	size;
+	size_t	    	len;
+	int	    	c;
+	int		un[5];
+	int		n_un;
+
+	struct isl_token	*tokens[5];
+	int	    	n_token;
+
+	struct isl_hash_table	*keywords;
+	enum isl_token_type	 next_type;
+};
+
+struct isl_stream* isl_stream_new_file(struct isl_ctx *ctx, FILE *file);
+struct isl_stream* isl_stream_new_str(struct isl_ctx *ctx, const char *str);
+void isl_stream_free(struct isl_stream *s);
+
+void isl_stream_error(struct isl_stream *s, struct isl_token *tok, char *msg);
+
+struct isl_token *isl_stream_next_token(struct isl_stream *s);
+struct isl_token *isl_stream_next_token_on_same_line(struct isl_stream *s);
+int isl_stream_next_token_is(struct isl_stream *s, int type);
+void isl_stream_push_token(struct isl_stream *s, struct isl_token *tok);
+void isl_stream_flush_tokens(struct isl_stream *s);
+int isl_stream_eat_if_available(struct isl_stream *s, int type);
+char *isl_stream_read_ident_if_available(struct isl_stream *s);
+int isl_stream_eat(struct isl_stream *s, int type);
+int isl_stream_is_empty(struct isl_stream *s);
+int isl_stream_skip_line(struct isl_stream *s);
+
+enum isl_token_type isl_stream_register_keyword(struct isl_stream *s,
+	const char *name);
+
+struct isl_obj isl_stream_read_obj(struct isl_stream *s);
+__isl_give isl_multi_aff *isl_stream_read_multi_aff(struct isl_stream *s);
+__isl_give isl_map *isl_stream_read_map(struct isl_stream *s);
+__isl_give isl_set *isl_stream_read_set(struct isl_stream *s);
+__isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(
+	struct isl_stream *s);
+__isl_give isl_union_map *isl_stream_read_union_map(struct isl_stream *s);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/union_map.h b/include/isl/union_map.h
new file mode 100644
index 0000000..8eb7b2f
--- /dev/null
+++ b/include/isl/union_map.h
@@ -0,0 +1,202 @@
+#ifndef ISL_UNION_MAP_H
+#define ISL_UNION_MAP_H
+
+#include <isl/space.h>
+#include <isl/map_type.h>
+#include <isl/union_map_type.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+__isl_constructor
+__isl_give isl_union_map *isl_union_map_from_basic_map(
+	__isl_take isl_basic_map *bmap);
+__isl_constructor
+__isl_give isl_union_map *isl_union_map_from_map(__isl_take isl_map *map);
+__isl_give isl_union_map *isl_union_map_empty(__isl_take isl_space *dim);
+__isl_give isl_union_map *isl_union_map_copy(__isl_keep isl_union_map *umap);
+void *isl_union_map_free(__isl_take isl_union_map *umap);
+
+isl_ctx *isl_union_map_get_ctx(__isl_keep isl_union_map *umap);
+__isl_give isl_space *isl_union_map_get_space(__isl_keep isl_union_map *umap);
+
+__isl_give isl_union_map *isl_union_map_universe(
+	__isl_take isl_union_map *umap);
+__isl_give isl_set *isl_union_map_params(__isl_take isl_union_map *umap);
+__isl_give isl_union_set *isl_union_map_domain(__isl_take isl_union_map *umap);
+__isl_give isl_union_set *isl_union_map_range(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_domain_map(
+	__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_range_map(
+	__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_from_domain(
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_map *isl_union_map_from_range(
+	__isl_take isl_union_set *uset);
+
+__isl_export
+__isl_give isl_union_map *isl_union_map_affine_hull(
+	__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_map *isl_union_map_polyhedral_hull(
+	__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_simple_hull(
+	__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_map *isl_union_map_coalesce(
+	__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_compute_divs(
+	__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_map *isl_union_map_lexmin(__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_map *isl_union_map_lexmax(__isl_take isl_union_map *umap);
+
+__isl_give isl_union_map *isl_union_map_add_map(__isl_take isl_union_map *umap,
+	__isl_take isl_map *map);
+__isl_export
+__isl_give isl_union_map *isl_union_map_union(__isl_take isl_union_map *umap1,
+	__isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_subtract(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_intersect(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_intersect_params(
+	__isl_take isl_union_map *umap, __isl_take isl_set *set);
+__isl_give isl_union_map *isl_union_map_product(__isl_take isl_union_map *umap1,
+	__isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_domain_product(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_range_product(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_flat_range_product(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_gist(__isl_take isl_union_map *umap,
+	__isl_take isl_union_map *context);
+__isl_export
+__isl_give isl_union_map *isl_union_map_gist_params(
+	__isl_take isl_union_map *umap, __isl_take isl_set *set);
+__isl_export
+__isl_give isl_union_map *isl_union_map_gist_domain(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_map *isl_union_map_gist_range(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *uset);
+
+__isl_export
+__isl_give isl_union_map *isl_union_map_intersect_domain(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_map *isl_union_map_intersect_range(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *uset);
+
+__isl_export
+__isl_give isl_union_map *isl_union_map_subtract_domain(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *dom);
+__isl_export
+__isl_give isl_union_map *isl_union_map_subtract_range(
+	__isl_take isl_union_map *umap, __isl_take isl_union_set *dom);
+
+__isl_export
+__isl_give isl_union_map *isl_union_map_apply_domain(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_apply_range(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_export
+__isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_from_domain_and_range(
+	__isl_take isl_union_set *domain, __isl_take isl_union_set *range);
+
+__isl_export
+__isl_give isl_union_map *isl_union_map_detect_equalities(
+	__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_set *isl_union_map_deltas(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_deltas_map(
+	__isl_take isl_union_map *umap);
+__isl_export
+__isl_give isl_union_map *isl_union_set_identity(__isl_take isl_union_set *uset);
+
+__isl_export
+int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
+__isl_export
+int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
+int isl_union_map_plain_is_injective(__isl_keep isl_union_map *umap);
+__isl_export
+int isl_union_map_is_injective(__isl_keep isl_union_map *umap);
+__isl_export
+int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
+
+__isl_export
+int isl_union_map_is_subset(__isl_keep isl_union_map *umap1,
+	__isl_keep isl_union_map *umap2);
+__isl_export
+int isl_union_map_is_equal(__isl_keep isl_union_map *umap1,
+	__isl_keep isl_union_map *umap2);
+__isl_export
+int isl_union_map_is_strict_subset(__isl_keep isl_union_map *umap1,
+	__isl_keep isl_union_map *umap2);
+
+int isl_union_map_n_map(__isl_keep isl_union_map *umap);
+__isl_export
+int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
+	int (*fn)(__isl_take isl_map *map, void *user), void *user);
+__isl_give int isl_union_map_contains(__isl_keep isl_union_map *umap,
+	__isl_keep isl_space *dim);
+__isl_give isl_map *isl_union_map_extract_map(__isl_keep isl_union_map *umap,
+	__isl_take isl_space *dim);
+__isl_give isl_map *isl_map_from_union_map(__isl_take isl_union_map *umap);
+
+__isl_give isl_basic_map *isl_union_map_sample(__isl_take isl_union_map *umap);
+
+__isl_give isl_union_map *isl_union_map_fixed_power(
+	__isl_take isl_union_map *umap, isl_int exp);
+__isl_give isl_union_map *isl_union_map_power(__isl_take isl_union_map *umap,
+	int *exact);
+__isl_give isl_union_map *isl_union_map_transitive_closure(
+	__isl_take isl_union_map *umap, int *exact);
+
+__isl_give isl_union_map *isl_union_map_lex_lt_union_map(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_lex_le_union_map(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_lex_gt_union_map(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+__isl_give isl_union_map *isl_union_map_lex_ge_union_map(
+	__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
+
+__isl_give isl_union_map *isl_union_map_read_from_file(isl_ctx *ctx,
+	FILE *input);
+__isl_constructor
+__isl_give isl_union_map *isl_union_map_read_from_str(isl_ctx *ctx,
+	const char *str);
+__isl_give isl_printer *isl_printer_print_union_map(__isl_take isl_printer *p,
+	__isl_keep isl_union_map *umap);
+void isl_union_map_dump(__isl_keep isl_union_map *umap);
+
+__isl_give isl_union_set *isl_union_map_wrap(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_set_unwrap(__isl_take isl_union_set *uset);
+
+__isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_curry(__isl_take isl_union_map *umap);
+__isl_give isl_union_map *isl_union_map_uncurry(__isl_take isl_union_map *umap);
+
+__isl_give isl_union_map *isl_union_map_align_params(
+	__isl_take isl_union_map *umap, __isl_take isl_space *model);
+__isl_give isl_union_set *isl_union_set_align_params(
+	__isl_take isl_union_set *uset, __isl_take isl_space *model);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/union_map_type.h b/include/isl/union_map_type.h
new file mode 100644
index 0000000..e93f2cc
--- /dev/null
+++ b/include/isl/union_map_type.h
@@ -0,0 +1,21 @@
+#ifndef ISL_UNION_MAP_TYPE_H
+#define ISL_UNION_MAP_TYPE_H
+
+#include <isl/ctx.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct __isl_export isl_union_map;
+typedef struct isl_union_map isl_union_map;
+#ifndef isl_union_set
+struct __isl_export isl_union_set;
+typedef struct isl_union_set isl_union_set;
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/union_set.h b/include/isl/union_set.h
new file mode 100644
index 0000000..be85977
--- /dev/null
+++ b/include/isl/union_set.h
@@ -0,0 +1,133 @@
+#ifndef ISL_UNION_SET_H
+#define ISL_UNION_SET_H
+
+#include <isl/point.h>
+#include <isl/union_map.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+__isl_constructor
+__isl_give isl_union_set *isl_union_set_from_basic_set(
+	__isl_take isl_basic_set *bset);
+__isl_constructor
+__isl_give isl_union_set *isl_union_set_from_set(__isl_take isl_set *set);
+__isl_give isl_union_set *isl_union_set_empty(__isl_take isl_space *dim);
+__isl_give isl_union_set *isl_union_set_copy(__isl_keep isl_union_set *uset);
+void *isl_union_set_free(__isl_take isl_union_set *uset);
+
+isl_ctx *isl_union_set_get_ctx(__isl_keep isl_union_set *uset);
+__isl_give isl_space *isl_union_set_get_space(__isl_keep isl_union_set *uset);
+
+__isl_give isl_union_set *isl_union_set_universe(
+	__isl_take isl_union_set *uset);
+__isl_give isl_set *isl_union_set_params(__isl_take isl_union_set *uset);
+
+__isl_export
+__isl_give isl_union_set *isl_union_set_detect_equalities(
+	__isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_set *isl_union_set_affine_hull(
+	__isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_set *isl_union_set_polyhedral_hull(
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_set *isl_union_set_simple_hull(
+	__isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_set *isl_union_set_coalesce(
+	__isl_take isl_union_set *uset);
+__isl_give isl_union_set *isl_union_set_compute_divs(
+	__isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_set *isl_union_set_lexmin(__isl_take isl_union_set *uset);
+__isl_export
+__isl_give isl_union_set *isl_union_set_lexmax(__isl_take isl_union_set *uset);
+
+__isl_give isl_union_set *isl_union_set_add_set(__isl_take isl_union_set *uset,
+	__isl_take isl_set *set);
+__isl_give isl_union_set *isl_union_set_union(__isl_take isl_union_set *uset1,
+	__isl_take isl_union_set *uset2);
+__isl_export
+__isl_give isl_union_set *isl_union_set_subtract(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+__isl_export
+__isl_give isl_union_set *isl_union_set_intersect(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+__isl_export
+__isl_give isl_union_set *isl_union_set_intersect_params(
+	__isl_take isl_union_set *uset, __isl_take isl_set *set);
+__isl_give isl_union_set *isl_union_set_product(__isl_take isl_union_set *uset1,
+	__isl_take isl_union_set *uset2);
+__isl_export
+__isl_give isl_union_set *isl_union_set_gist(__isl_take isl_union_set *uset,
+	__isl_take isl_union_set *context);
+__isl_export
+__isl_give isl_union_set *isl_union_set_gist_params(
+	__isl_take isl_union_set *uset, __isl_take isl_set *set);
+
+__isl_export
+__isl_give isl_union_set *isl_union_set_apply(
+	__isl_take isl_union_set *uset, __isl_take isl_union_map *umap);
+
+int isl_union_set_is_params(__isl_keep isl_union_set *uset);
+__isl_export
+int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
+
+__isl_export
+int isl_union_set_is_subset(__isl_keep isl_union_set *uset1,
+	__isl_keep isl_union_set *uset2);
+__isl_export
+int isl_union_set_is_equal(__isl_keep isl_union_set *uset1,
+	__isl_keep isl_union_set *uset2);
+__isl_export
+int isl_union_set_is_strict_subset(__isl_keep isl_union_set *uset1,
+	__isl_keep isl_union_set *uset2);
+
+int isl_union_set_n_set(__isl_keep isl_union_set *uset);
+__isl_export
+int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
+	int (*fn)(__isl_take isl_set *set, void *user), void *user);
+__isl_give int isl_union_set_contains(__isl_keep isl_union_set *uset,
+	__isl_keep isl_space *dim);
+__isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset,
+	__isl_take isl_space *dim);
+__isl_give isl_set *isl_set_from_union_set(__isl_take isl_union_set *uset);
+int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
+	int (*fn)(__isl_take isl_point *pnt, void *user), void *user);
+
+__isl_give isl_basic_set *isl_union_set_sample(__isl_take isl_union_set *uset);
+
+__isl_give isl_union_set *isl_union_set_lift(__isl_take isl_union_set *uset);
+
+__isl_give isl_union_map *isl_union_set_lex_lt_union_set(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+__isl_give isl_union_map *isl_union_set_lex_le_union_set(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+__isl_give isl_union_map *isl_union_set_lex_gt_union_set(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+__isl_give isl_union_map *isl_union_set_lex_ge_union_set(
+	__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
+
+__isl_give isl_union_set *isl_union_set_coefficients(
+	__isl_take isl_union_set *bset);
+__isl_give isl_union_set *isl_union_set_solutions(
+	__isl_take isl_union_set *bset);
+
+__isl_give isl_union_set *isl_union_set_read_from_file(isl_ctx *ctx,
+	FILE *input);
+__isl_constructor
+__isl_give isl_union_set *isl_union_set_read_from_str(isl_ctx *ctx,
+	const char *str);
+__isl_give isl_printer *isl_printer_print_union_set(__isl_take isl_printer *p,
+	__isl_keep isl_union_set *uset);
+void isl_union_set_dump(__isl_keep isl_union_set *uset);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#include <isl/dim.h>
+
+#endif
diff --git a/include/isl/union_set_type.h b/include/isl/union_set_type.h
new file mode 100644
index 0000000..86b2c31
--- /dev/null
+++ b/include/isl/union_set_type.h
@@ -0,0 +1,6 @@
+#ifndef ISL_UNION_SET_TYPE_H
+#define ISL_UNION_SET_TYPE_H
+
+#include <isl/union_map_type.h>
+
+#endif
diff --git a/include/isl/vec.h b/include/isl/vec.h
new file mode 100644
index 0000000..7122997
--- /dev/null
+++ b/include/isl/vec.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
+#ifndef ISL_VEC_H
+#define ISL_VEC_H
+
+#include <stdio.h>
+
+#include <isl/int.h>
+#include <isl/ctx.h>
+#include <isl/blk.h>
+#include <isl/printer.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_vec {
+	int ref;
+
+	struct isl_ctx *ctx;
+
+	unsigned size;
+	isl_int *el;
+
+	struct isl_blk block;
+};
+typedef struct isl_vec isl_vec;
+
+__isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx, unsigned size);
+__isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
+struct isl_vec *isl_vec_cow(struct isl_vec *vec);
+void *isl_vec_free(__isl_take isl_vec *vec);
+
+isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);
+
+int isl_vec_size(__isl_keep isl_vec *vec);
+int isl_vec_get_element(__isl_keep isl_vec *vec, int pos, isl_int *v);
+__isl_give isl_vec *isl_vec_set_element(__isl_take isl_vec *vec,
+	int pos, isl_int v);
+__isl_give isl_vec *isl_vec_set_element_si(__isl_take isl_vec *vec,
+	int pos, int v);
+
+int isl_vec_is_equal(__isl_keep isl_vec *vec1, __isl_keep isl_vec *vec2);
+
+void isl_vec_dump(__isl_keep isl_vec *vec);
+__isl_give isl_printer *isl_printer_print_vec(__isl_take isl_printer *printer,
+	__isl_keep isl_vec *vec);
+
+void isl_vec_lcm(struct isl_vec *vec, isl_int *lcm);
+struct isl_vec *isl_vec_ceil(struct isl_vec *vec);
+struct isl_vec *isl_vec_normalize(struct isl_vec *vec);
+__isl_give isl_vec *isl_vec_set(__isl_take isl_vec *vec, isl_int v);
+__isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec, int v);
+__isl_give isl_vec *isl_vec_clr(__isl_take isl_vec *vec);
+__isl_give isl_vec *isl_vec_neg(__isl_take isl_vec *vec);
+__isl_give isl_vec *isl_vec_scale(__isl_take isl_vec *vec, isl_int m);
+__isl_give isl_vec *isl_vec_fdiv_r(__isl_take isl_vec *vec, isl_int m);
+__isl_give isl_vec *isl_vec_add(__isl_take isl_vec *vec1,
+	__isl_take isl_vec *vec2);
+__isl_give isl_vec *isl_vec_extend(__isl_take isl_vec *vec, unsigned size);
+__isl_give isl_vec *isl_vec_zero_extend(__isl_take isl_vec *vec, unsigned size);
+__isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
+	__isl_take isl_vec *vec2);
+
+__isl_give isl_vec *isl_vec_sort(__isl_take isl_vec *vec);
+
+__isl_give isl_vec *isl_vec_read_from_file(isl_ctx *ctx, FILE *input);
+
+__isl_give isl_vec *isl_vec_drop_els(__isl_take isl_vec *vec,
+	unsigned pos, unsigned n);
+__isl_give isl_vec *isl_vec_insert_els(__isl_take isl_vec *vec,
+	unsigned pos, unsigned n);
+__isl_give isl_vec *isl_vec_insert_zero_els(__isl_take isl_vec *vec,
+	unsigned pos, unsigned n);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/version.h b/include/isl/version.h
new file mode 100644
index 0000000..7f8f23d
--- /dev/null
+++ b/include/isl/version.h
@@ -0,0 +1,14 @@
+#ifndef ISL_VERSION_H
+#define ISL_VERSION_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char *isl_version(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/isl/vertices.h b/include/isl/vertices.h
new file mode 100644
index 0000000..3e8460d
--- /dev/null
+++ b/include/isl/vertices.h
@@ -0,0 +1,46 @@
+#ifndef ISL_VERTICES_H
+#define ISL_VERTICES_H
+
+#include <isl/set_type.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct isl_external_vertex;
+typedef struct isl_external_vertex	isl_vertex;
+
+struct isl_cell;
+typedef struct isl_cell		isl_cell;
+
+struct isl_vertices;
+typedef struct isl_vertices	isl_vertices;
+
+isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
+int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
+__isl_give isl_basic_set *isl_vertex_get_domain(__isl_keep isl_vertex *vertex);
+__isl_give isl_basic_set *isl_vertex_get_expr(__isl_keep isl_vertex *vertex);
+void isl_vertex_free(__isl_take isl_vertex *vertex);
+
+__isl_give isl_vertices *isl_basic_set_compute_vertices(
+	__isl_keep isl_basic_set *bset);
+isl_ctx *isl_vertices_get_ctx(__isl_keep isl_vertices *vertices);
+int isl_vertices_get_n_vertices(__isl_keep isl_vertices *vertices);
+int isl_vertices_foreach_vertex(__isl_keep isl_vertices *vertices,
+	int (*fn)(__isl_take isl_vertex *vertex, void *user), void *user);
+void isl_vertices_free(__isl_take isl_vertices *vertices);
+
+isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
+__isl_give isl_basic_set *isl_cell_get_domain(__isl_keep isl_cell *cell);
+int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
+	int (*fn)(__isl_take isl_vertex *vertex, void *user), void *user);
+void isl_cell_free(__isl_take isl_cell *cell);
+
+int isl_vertices_foreach_cell(__isl_keep isl_vertices *vertices,
+	int (*fn)(__isl_take isl_cell *cell, void *user), void *user);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/mpc.h b/include/mpc.h
new file mode 100644
index 0000000..02c1943
--- /dev/null
+++ b/include/mpc.h
@@ -0,0 +1,269 @@
+/* mpc.h -- Include file for mpc.
+
+Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#ifndef __MPC_H
+#define __MPC_H
+
+#include "gmp.h"
+#include "mpfr.h"
+
+/* Backwards compatibility with mpfr<3.0.0 */
+#ifndef mpfr_exp_t
+#define mpfr_exp_t mp_exp_t
+#endif
+
+/* Define MPC version number */
+#define MPC_VERSION_MAJOR 1
+#define MPC_VERSION_MINOR 0
+#define MPC_VERSION_PATCHLEVEL 1
+#define MPC_VERSION_STRING "1.0.1"
+
+/* Macros dealing with MPC VERSION */
+#define MPC_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+#define MPC_VERSION                                                     \
+  MPC_VERSION_NUM(MPC_VERSION_MAJOR,MPC_VERSION_MINOR,MPC_VERSION_PATCHLEVEL)
+
+/* Check if stdint.h/inttypes.h is included */
+#if defined (INTMAX_C) && defined (UINTMAX_C)
+#define _MPC_H_HAVE_INTMAX_T 1
+#endif
+
+/* Return values */
+
+/* Transform negative to 2, positive to 1, leave 0 unchanged */
+#define MPC_INEX_POS(inex) (((inex) < 0) ? 2 : ((inex) == 0) ? 0 : 1)
+/* Transform 2 to negative, 1 to positive, leave 0 unchanged */
+#define MPC_INEX_NEG(inex) (((inex) == 2) ? -1 : ((inex) == 0) ? 0 : 1)
+
+/* The global inexact flag is made of (real flag) + 4 * (imaginary flag), where
+   each of the real and imaginary inexact flag are:
+   0 when the result is exact (no rounding error)
+   1 when the result is larger than the exact value
+   2 when the result is smaller than the exact value */
+#define MPC_INEX(inex_re, inex_im) \
+        (MPC_INEX_POS(inex_re) | (MPC_INEX_POS(inex_im) << 2))
+#define MPC_INEX_RE(inex) MPC_INEX_NEG((inex) & 3)
+#define MPC_INEX_IM(inex) MPC_INEX_NEG((inex) >> 2)
+
+/* For functions computing two results, the return value is
+   inexact1+16*inexact2, which is 0 iif both results are exact. */
+#define MPC_INEX12(inex1, inex2) (inex1 | (inex2 << 4))
+#define MPC_INEX1(inex) (inex & 15)
+#define MPC_INEX2(inex) (inex >> 4)
+
+/* Definition of rounding modes */
+
+/* a complex rounding mode is just a pair of two real rounding modes
+   we reserve four bits for a real rounding mode.  */
+typedef int mpc_rnd_t;
+
+#define MPC_RND(r1,r2) (((int)(r1)) + ((int)(r2) << 4))
+#define MPC_RND_RE(x) ((mpfr_rnd_t)((x) & 0x0F))
+#define MPC_RND_IM(x) ((mpfr_rnd_t)((x) >> 4))
+
+#define MPC_RNDNN MPC_RND (GMP_RNDN,GMP_RNDN)
+#define MPC_RNDNZ MPC_RND (GMP_RNDN,GMP_RNDZ)
+#define MPC_RNDNU MPC_RND (GMP_RNDN,GMP_RNDU)
+#define MPC_RNDND MPC_RND (GMP_RNDN,GMP_RNDD)
+
+#define MPC_RNDZN MPC_RND (GMP_RNDZ,GMP_RNDN)
+#define MPC_RNDZZ MPC_RND (GMP_RNDZ,GMP_RNDZ)
+#define MPC_RNDZU MPC_RND (GMP_RNDZ,GMP_RNDU)
+#define MPC_RNDZD MPC_RND (GMP_RNDZ,GMP_RNDD)
+
+#define MPC_RNDUN MPC_RND (GMP_RNDU,GMP_RNDN)
+#define MPC_RNDUZ MPC_RND (GMP_RNDU,GMP_RNDZ)
+#define MPC_RNDUU MPC_RND (GMP_RNDU,GMP_RNDU)
+#define MPC_RNDUD MPC_RND (GMP_RNDU,GMP_RNDD)
+
+#define MPC_RNDDN MPC_RND (GMP_RNDD,GMP_RNDN)
+#define MPC_RNDDZ MPC_RND (GMP_RNDD,GMP_RNDZ)
+#define MPC_RNDDU MPC_RND (GMP_RNDD,GMP_RNDU)
+#define MPC_RNDDD MPC_RND (GMP_RNDD,GMP_RNDD)
+
+
+/* Definitions of types and their semantics */
+
+typedef struct {
+  mpfr_t re;
+  mpfr_t im;
+}
+__mpc_struct;
+
+typedef __mpc_struct mpc_t[1];
+typedef __mpc_struct *mpc_ptr;
+typedef const __mpc_struct *mpc_srcptr;
+
+/* Support for WINDOWS DLL, see
+   http://lists.gforge.inria.fr/pipermail/mpc-discuss/2011-November/000990.html;
+   when building the DLL, export symbols, otherwise behave as GMP           */
+#if defined (__MPC_LIBRARY_BUILD) && __GMP_LIBGMP_DLL
+#define __MPC_DECLSPEC __GMP_DECLSPEC_EXPORT
+#else
+#define __MPC_DECLSPEC __GMP_DECLSPEC
+#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+__MPC_DECLSPEC int  mpc_add       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_add_fr    (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_add_si    (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_add_ui    (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sub       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sub_fr    (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_fr_sub    (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sub_ui    (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_ui_ui_sub (mpc_ptr, unsigned long int, unsigned long int, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_fr    (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_ui    (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_si    (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_i     (mpc_ptr, mpc_srcptr, int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sqr       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_div       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_fr    (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_ld    (mpc_ptr, mpc_srcptr, long double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_d     (mpc_ptr, mpc_srcptr, double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_si    (mpc_ptr, mpc_srcptr, long, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_ui    (mpc_ptr, mpc_srcptr, unsigned long, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_pow_z     (mpc_ptr, mpc_srcptr, mpz_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_div_fr    (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_fr_div    (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_div_ui    (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_ui_div    (mpc_ptr, unsigned long int, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_div_2ui   (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_2ui   (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_div_2si   (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_mul_2si   (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_conj      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_neg       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_norm      (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
+__MPC_DECLSPEC int  mpc_abs       (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
+__MPC_DECLSPEC int  mpc_sqrt      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_d     (mpc_ptr, double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_d_d   (mpc_ptr, double, double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_ld    (mpc_ptr, long double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_ld_ld (mpc_ptr, long double, long double, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_f     (mpc_ptr, mpf_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_f_f   (mpc_ptr, mpf_srcptr, mpf_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_fr    (mpc_ptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_fr_fr (mpc_ptr, mpfr_srcptr, mpfr_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_q     (mpc_ptr, mpq_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_q_q   (mpc_ptr, mpq_srcptr, mpq_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_si    (mpc_ptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_si_si (mpc_ptr, long int, long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_ui    (mpc_ptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_ui_ui (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_z     (mpc_ptr, mpz_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_z_z   (mpc_ptr, mpz_srcptr, mpz_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC void mpc_swap      (mpc_ptr, mpc_ptr);
+__MPC_DECLSPEC int  mpc_fma       (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t);
+
+__MPC_DECLSPEC void mpc_set_nan   (mpc_ptr);
+
+__MPC_DECLSPEC int  mpc_real      (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
+__MPC_DECLSPEC int  mpc_imag      (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
+__MPC_DECLSPEC int  mpc_arg       (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
+__MPC_DECLSPEC int  mpc_proj      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_cmp       (mpc_srcptr, mpc_srcptr);
+__MPC_DECLSPEC int  mpc_cmp_si_si (mpc_srcptr, long int, long int);
+__MPC_DECLSPEC int  mpc_exp       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_log       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_log10     (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sin       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_cos       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sin_cos   (mpc_ptr, mpc_ptr, mpc_srcptr, mpc_rnd_t, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_tan       (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_sinh      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_cosh      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_tanh      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_asin      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_acos      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_atan      (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_asinh     (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_acosh     (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_atanh     (mpc_ptr, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC void mpc_clear     (mpc_ptr);
+__MPC_DECLSPEC int  mpc_urandom   (mpc_ptr, gmp_randstate_t);
+__MPC_DECLSPEC void mpc_init2     (mpc_ptr, mpfr_prec_t);
+__MPC_DECLSPEC void mpc_init3     (mpc_ptr, mpfr_prec_t, mpfr_prec_t);
+__MPC_DECLSPEC mpfr_prec_t mpc_get_prec (mpc_srcptr x);
+__MPC_DECLSPEC void mpc_get_prec2 (mpfr_prec_t *pr, mpfr_prec_t *pi, mpc_srcptr x);
+__MPC_DECLSPEC void mpc_set_prec  (mpc_ptr, mpfr_prec_t);
+__MPC_DECLSPEC const char * mpc_get_version (void);
+
+__MPC_DECLSPEC int  mpc_strtoc    (mpc_ptr, const char *, char **, int, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_str   (mpc_ptr, const char *, int, mpc_rnd_t);
+__MPC_DECLSPEC char * mpc_get_str (int, size_t, mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC void mpc_free_str  (char *);
+
+/* declare certain functions only if appropriate headers have been included */
+#ifdef _MPC_H_HAVE_INTMAX_T
+__MPC_DECLSPEC int  mpc_set_sj    (mpc_ptr, intmax_t, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_uj    (mpc_ptr, uintmax_t,  mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_sj_sj (mpc_ptr, intmax_t, intmax_t, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_uj_uj (mpc_ptr, uintmax_t, uintmax_t, mpc_rnd_t);
+#endif
+
+#ifdef _Complex_I
+__MPC_DECLSPEC int  mpc_set_dc    (mpc_ptr, double _Complex, mpc_rnd_t);
+__MPC_DECLSPEC int  mpc_set_ldc   (mpc_ptr, long double _Complex, mpc_rnd_t);
+__MPC_DECLSPEC double _Complex mpc_get_dc (mpc_srcptr, mpc_rnd_t);
+__MPC_DECLSPEC long double _Complex mpc_get_ldc (mpc_srcptr, mpc_rnd_t);
+#endif
+
+#ifdef _GMP_H_HAVE_FILE
+__MPC_DECLSPEC int mpc_inp_str    (mpc_ptr, FILE *, size_t *, int, mpc_rnd_t);
+__MPC_DECLSPEC size_t mpc_out_str (FILE *, int, size_t, mpc_srcptr, mpc_rnd_t);
+#endif
+
+#if defined (__cplusplus)
+}
+#endif
+
+#define mpc_realref(x) ((x)->re)
+#define mpc_imagref(x) ((x)->im)
+
+#define mpc_cmp_si(x, y) \
+ ( mpc_cmp_si_si ((x), (y), 0l) )
+#define mpc_ui_sub(x, y, z, r) mpc_ui_ui_sub (x, y, 0ul, z, r)
+
+/*
+   Define a fake mpfr_set_fr so that, for instance, mpc_set_fr_z would
+   be defined as follows:
+   mpc_set_fr_z (mpc_t rop, mpfr_t x, mpz_t y, mpc_rnd_t rnd)
+       MPC_SET_X_Y (fr, z, rop, x, y, rnd)
+*/
+#ifndef mpfr_set_fr
+#define mpfr_set_fr mpfr_set
+#endif
+#define MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd)     \
+  {                                                                     \
+    int _inex_re, _inex_im;                                             \
+    _inex_re = (mpfr_set_ ## real_t) (mpc_realref (z), (real_value), MPC_RND_RE (rnd)); \
+    _inex_im = (mpfr_set_ ## imag_t) (mpc_imagref (z), (imag_value), MPC_RND_IM (rnd)); \
+    return MPC_INEX (_inex_re, _inex_im);                               \
+  }
+
+#endif /* ifndef __MPC_H */
diff --git a/include/mpf2mpfr.h b/include/mpf2mpfr.h
new file mode 100644
index 0000000..2775a61
--- /dev/null
+++ b/include/mpf2mpfr.h
@@ -0,0 +1,175 @@
+/* mpf2mpfr.h -- Compatibility include file with mpf.
+
+Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+Contributed by the AriC and Caramel projects, INRIA.
+
+This file is part of the GNU MPFR Library.
+
+The GNU MPFR Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MPFR Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
+http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef __MPFR_FROM_MPF__
+#define __MPFR_FROM_MPF__
+
+/* types */
+#define mpf_t mpfr_t
+#define mpf_srcptr mpfr_srcptr
+#define mpf_ptr mpfr_ptr
+
+/* Get current Rounding Mode */
+#ifndef MPFR_DEFAULT_RND
+# define MPFR_DEFAULT_RND mpfr_get_default_rounding_mode ()
+#endif
+
+/* mpf_init initalizes at 0 */
+#undef mpf_init
+#define mpf_init(x) mpfr_init_set_ui ((x), 0, MPFR_DEFAULT_RND)
+#undef mpf_init2
+#define mpf_init2(x,p) (mpfr_init2((x),(p)), mpfr_set_ui ((x), 0, MPFR_DEFAULT_RND))
+
+/* functions which don't take as argument the rounding mode */
+#undef mpf_ceil
+#define mpf_ceil mpfr_ceil
+#undef mpf_clear
+#define mpf_clear mpfr_clear
+#undef mpf_cmp
+#define mpf_cmp mpfr_cmp
+#undef mpf_cmp_si
+#define mpf_cmp_si mpfr_cmp_si
+#undef mpf_cmp_ui
+#define mpf_cmp_ui mpfr_cmp_ui
+#undef mpf_cmp_d
+#define mpf_cmp_d mpfr_cmp_d
+#undef mpf_eq
+#define mpf_eq mpfr_eq
+#undef mpf_floor
+#define mpf_floor mpfr_floor
+#undef mpf_get_prec
+#define mpf_get_prec mpfr_get_prec
+#undef mpf_integer_p
+#define mpf_integer_p mpfr_integer_p
+#undef mpf_random2
+#define mpf_random2 mpfr_random2
+#undef mpf_set_default_prec
+#define mpf_set_default_prec mpfr_set_default_prec
+#undef mpf_get_default_prec
+#define mpf_get_default_prec mpfr_get_default_prec
+#undef mpf_set_prec
+#define mpf_set_prec mpfr_set_prec
+#undef mpf_set_prec_raw
+#define mpf_set_prec_raw(x,p) mpfr_prec_round(x,p,MPFR_DEFAULT_RND)
+#undef mpf_trunc
+#define mpf_trunc mpfr_trunc
+#undef mpf_sgn
+#define mpf_sgn mpfr_sgn
+#undef mpf_swap
+#define mpf_swap mpfr_swap
+#undef mpf_dump
+#define mpf_dump mpfr_dump
+
+/* functions which take as argument the rounding mode */
+#undef mpf_abs
+#define mpf_abs(x,y) mpfr_abs(x,y,MPFR_DEFAULT_RND)
+#undef mpf_add
+#define mpf_add(x,y,z) mpfr_add(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_add_ui
+#define mpf_add_ui(x,y,z) mpfr_add_ui(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_div
+#define mpf_div(x,y,z) mpfr_div(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_div_ui
+#define mpf_div_ui(x,y,z) mpfr_div_ui(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_div_2exp
+#define mpf_div_2exp(x,y,z) mpfr_div_2exp(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_fits_slong_p
+#define mpf_fits_slong_p(x) mpfr_fits_ulong_p(x,MPFR_DEFAULT_RND)
+#undef mpf_fits_ulong_p
+#define mpf_fits_ulong_p(x) mpfr_fits_ulong_p(x,MPFR_DEFAULT_RND)
+#undef mpf_fits_sint_p
+#define mpf_fits_sint_p(x) mpfr_fits_uint_p(x,MPFR_DEFAULT_RND)
+#undef mpf_fits_uint_p
+#define mpf_fits_uint_p(x) mpfr_fits_uint_p(x,MPFR_DEFAULT_RND)
+#undef mpf_fits_sshort_p
+#define mpf_fits_sshort_p(x) mpfr_fits_ushort_p(x,MPFR_DEFAULT_RND)
+#undef mpf_fits_ushort_p
+#define mpf_fits_ushort_p(x) mpfr_fits_ushort_p(x,MPFR_DEFAULT_RND)
+#undef mpf_get_str
+#define mpf_get_str(x,y,z,t,u) mpfr_get_str(x,y,z,t,u,MPFR_DEFAULT_RND)
+#undef mpf_get_d
+#define mpf_get_d(x) mpfr_get_d(x,MPFR_DEFAULT_RND)
+#undef mpf_get_d_2exp
+#define mpf_get_d_2exp(e,x) mpfr_get_d_2exp(e,x,MPFR_DEFAULT_RND)
+#undef mpf_get_ui
+#define mpf_get_ui(x) mpfr_get_ui(x,MPFR_DEFAULT_RND)
+#undef mpf_get_si
+#define mpf_get_si(x) mpfr_get_ui(x,MPFR_DEFAULT_RND)
+#undef mpf_inp_str
+#define mpf_inp_str(x,y,z) mpfr_inp_str(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_set_str
+#define mpf_set_str(x,y,z) mpfr_set_str(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_init_set
+#define mpf_init_set(x,y) mpfr_init_set(x,y,MPFR_DEFAULT_RND)
+#undef mpf_init_set_d
+#define mpf_init_set_d(x,y) mpfr_init_set_d(x,y,MPFR_DEFAULT_RND)
+#undef mpf_init_set_si
+#define mpf_init_set_si(x,y) mpfr_init_set_si(x,y,MPFR_DEFAULT_RND)
+#undef mpf_init_set_str
+#define mpf_init_set_str(x,y,z) mpfr_init_set_str(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_init_set_ui
+#define mpf_init_set_ui(x,y) mpfr_init_set_ui(x,y,MPFR_DEFAULT_RND)
+#undef mpf_mul
+#define mpf_mul(x,y,z) mpfr_mul(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_mul_2exp
+#define mpf_mul_2exp(x,y,z) mpfr_mul_2exp(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_mul_ui
+#define mpf_mul_ui(x,y,z) mpfr_mul_ui(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_neg
+#define mpf_neg(x,y) mpfr_neg(x,y,MPFR_DEFAULT_RND)
+#undef mpf_out_str
+#define mpf_out_str(x,y,z,t) mpfr_out_str(x,y,z,t,MPFR_DEFAULT_RND)
+#undef mpf_pow_ui
+#define mpf_pow_ui(x,y,z) mpfr_pow_ui(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_reldiff
+#define mpf_reldiff(x,y,z) mpfr_reldiff(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_set
+#define mpf_set(x,y) mpfr_set(x,y,MPFR_DEFAULT_RND)
+#undef mpf_set_d
+#define mpf_set_d(x,y) mpfr_set_d(x,y,MPFR_DEFAULT_RND)
+#undef mpf_set_q
+#define mpf_set_q(x,y) mpfr_set_q(x,y,MPFR_DEFAULT_RND)
+#undef mpf_set_si
+#define mpf_set_si(x,y) mpfr_set_si(x,y,MPFR_DEFAULT_RND)
+#undef mpf_set_ui
+#define mpf_set_ui(x,y) mpfr_set_ui(x,y,MPFR_DEFAULT_RND)
+#undef mpf_set_z
+#define mpf_set_z(x,y) mpfr_set_z(x,y,MPFR_DEFAULT_RND)
+#undef mpf_sqrt
+#define mpf_sqrt(x,y) mpfr_sqrt(x,y,MPFR_DEFAULT_RND)
+#undef mpf_sqrt_ui
+#define mpf_sqrt_ui(x,y) mpfr_sqrt_ui(x,y,MPFR_DEFAULT_RND)
+#undef mpf_sub
+#define mpf_sub(x,y,z) mpfr_sub(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_sub_ui
+#define mpf_sub_ui(x,y,z) mpfr_sub_ui(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_ui_div
+#define mpf_ui_div(x,y,z) mpfr_ui_div(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_ui_sub
+#define mpf_ui_sub(x,y,z) mpfr_ui_sub(x,y,z,MPFR_DEFAULT_RND)
+#undef mpf_urandomb
+#define mpf_urandomb(x,y,n) mpfr_urandomb(x,y)
+
+#undef mpz_set_f
+#define mpz_set_f(z,f) mpfr_get_z(z,f,MPFR_DEFAULT_RND)
+
+#endif /* __MPFR_FROM_MPF__ */
diff --git a/include/mpfr.h b/include/mpfr.h
new file mode 100644
index 0000000..2e9ad27
--- /dev/null
+++ b/include/mpfr.h
@@ -0,0 +1,1059 @@
+/* mpfr.h -- Include file for mpfr.
+
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+Contributed by the AriC and Caramel projects, INRIA.
+
+This file is part of the GNU MPFR Library.
+
+The GNU MPFR Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MPFR Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
+http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef __MPFR_H
+#define __MPFR_H
+
+/* Define MPFR version number */
+#define MPFR_VERSION_MAJOR 3
+#define MPFR_VERSION_MINOR 1
+#define MPFR_VERSION_PATCHLEVEL 1
+#define MPFR_VERSION_STRING "3.1.1"
+
+/* Macros dealing with MPFR VERSION */
+#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+#define MPFR_VERSION \
+MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
+
+/* Check if GMP is included, and try to include it (Works with local GMP) */
+#ifndef __GMP_H__
+# include <gmp.h>
+#endif
+
+/* GMP's internal __gmp_const macro has been removed on 2012-03-04:
+     http://gmplib.org:8000/gmp/rev/d287cfaf6732
+   const is standard and now assumed to be available. If the __gmp_const
+   definition is no longer present in GMP, this probably means that GMP
+   assumes that const is available; thus let's define it to const.
+   Note: this is a temporary fix that can be backported to previous MPFR
+   versions. In the future, __gmp_const should be replaced by const like
+   in GMP. */
+#ifndef __gmp_const
+# define __gmp_const const
+#endif
+
+/* Avoid some problems with macro expansion if the user defines macros
+   with the same name as keywords. By convention, identifiers and macro
+   names starting with mpfr_ are reserved by MPFR. */
+typedef void            mpfr_void;
+typedef int             mpfr_int;
+typedef unsigned int    mpfr_uint;
+typedef long            mpfr_long;
+typedef unsigned long   mpfr_ulong;
+typedef size_t          mpfr_size_t;
+
+/* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
+   Warning! Changing the contents of this enum should be seen as an
+   interface change since the old and the new types are not compatible
+   (the integer type compatible with the enumerated type can even change,
+   see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0.
+
+   MPFR_RNDU must appear just before MPFR_RNDD (see
+   MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h).
+
+   MPFR_RNDF has been added, though not implemented yet, in order to avoid
+   to break the ABI once faithful rounding gets implemented.
+
+   If you change the order of the rounding modes, please update the routines
+   in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA.
+*/
+typedef enum {
+  MPFR_RNDN=0,  /* round to nearest, with ties to even */
+  MPFR_RNDZ,    /* round toward zero */
+  MPFR_RNDU,    /* round toward +Inf */
+  MPFR_RNDD,    /* round toward -Inf */
+  MPFR_RNDA,    /* round away from zero */
+  MPFR_RNDF,    /* faithful rounding (not implemented yet) */
+  MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
+} mpfr_rnd_t;
+
+/* kept for compatibility with MPFR 2.4.x and before */
+#define GMP_RNDN MPFR_RNDN
+#define GMP_RNDZ MPFR_RNDZ
+#define GMP_RNDU MPFR_RNDU
+#define GMP_RNDD MPFR_RNDD
+
+/* Note: With the following default choices for _MPFR_PREC_FORMAT and
+   _MPFR_EXP_FORMAT, mpfr_exp_t will be the same as [mp_exp_t] (at least
+   up to GMP 5). */
+
+/* Define precision: 1 (short), 2 (int) or 3 (long) (DON'T USE IT!) */
+#ifndef _MPFR_PREC_FORMAT
+# if __GMP_MP_SIZE_T_INT == 1
+#  define _MPFR_PREC_FORMAT 2
+# else
+#  define _MPFR_PREC_FORMAT 3
+# endif
+#endif
+
+/* Define exponent: 1 (short), 2 (int), 3 (long) or 4 (intmax_t)
+   (DON'T USE IT!) */
+#ifndef _MPFR_EXP_FORMAT
+# define _MPFR_EXP_FORMAT _MPFR_PREC_FORMAT
+#endif
+
+#if _MPFR_PREC_FORMAT > _MPFR_EXP_FORMAT
+# error "mpfr_prec_t must not be larger than mpfr_exp_t"
+#endif
+
+/* Let's make mpfr_prec_t signed in order to avoid problems due to the
+   usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t
+   in an expression (for error analysis) if casts are forgotten. */
+#if   _MPFR_PREC_FORMAT == 1
+typedef short mpfr_prec_t;
+typedef unsigned short mpfr_uprec_t;
+#elif _MPFR_PREC_FORMAT == 2
+typedef int   mpfr_prec_t;
+typedef unsigned int   mpfr_uprec_t;
+#elif _MPFR_PREC_FORMAT == 3
+typedef long  mpfr_prec_t;
+typedef unsigned long  mpfr_uprec_t;
+#else
+# error "Invalid MPFR Prec format"
+#endif
+
+/* Definition of precision limits without needing <limits.h> */
+/* Note: the casts allows the expression to yield the wanted behavior
+   for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). */
+#define MPFR_PREC_MIN 2
+#define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))
+
+/* Definition of sign */
+typedef int          mpfr_sign_t;
+
+/* Definition of the exponent. _MPFR_EXP_FORMAT must be large enough
+   so that mpfr_exp_t has at least 32 bits. */
+#if   _MPFR_EXP_FORMAT == 1
+typedef short mpfr_exp_t;
+typedef unsigned short mpfr_uexp_t;
+#elif _MPFR_EXP_FORMAT == 2
+typedef int mpfr_exp_t;
+typedef unsigned int mpfr_uexp_t;
+#elif _MPFR_EXP_FORMAT == 3
+typedef long mpfr_exp_t;
+typedef unsigned long mpfr_uexp_t;
+#elif _MPFR_EXP_FORMAT == 4
+/* Note: in this case, intmax_t and uintmax_t must be defined before
+   the inclusion of mpfr.h (we do not include <stdint.h> here because
+   of some non-ISO C99 implementations that support these types). */
+typedef intmax_t mpfr_exp_t;
+typedef uintmax_t mpfr_uexp_t;
+#else
+# error "Invalid MPFR Exp format"
+#endif
+
+/* Definition of the standard exponent limits */
+#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
+#define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
+
+/* DON'T USE THIS! (For MPFR-public macros only, see below.)
+   The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
+   are the smallest values. */
+#define __MPFR_EXP_MAX ((mpfr_exp_t) (((mpfr_uexp_t) -1) >> 1))
+#define __MPFR_EXP_NAN  (1 - __MPFR_EXP_MAX)
+#define __MPFR_EXP_ZERO (0 - __MPFR_EXP_MAX)
+#define __MPFR_EXP_INF  (2 - __MPFR_EXP_MAX)
+
+/* Definition of the main structure */
+typedef struct {
+  mpfr_prec_t  _mpfr_prec;
+  mpfr_sign_t  _mpfr_sign;
+  mpfr_exp_t   _mpfr_exp;
+  mp_limb_t   *_mpfr_d;
+} __mpfr_struct;
+
+/* Compatibility with previous types of MPFR */
+#ifndef mp_rnd_t
+# define mp_rnd_t  mpfr_rnd_t
+#endif
+#ifndef mp_prec_t
+# define mp_prec_t mpfr_prec_t
+#endif
+
+/*
+   The represented number is
+      _sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
+   where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS.
+
+   For the msb (most significant bit) normalized representation, we must have
+      _d[k-1]>=B/2, unless the number is singular.
+
+   We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero.
+*/
+
+typedef __mpfr_struct mpfr_t[1];
+typedef __mpfr_struct *mpfr_ptr;
+typedef __gmp_const __mpfr_struct *mpfr_srcptr;
+
+/* For those who need a direct and fast access to the sign field.
+   However it is not in the API, thus use it at your own risk: it might
+   not be supported, or change name, in further versions!
+   Unfortunately, it must be defined here (instead of MPFR's internal
+   header file mpfr-impl.h) because it is used by some macros below.
+*/
+#define MPFR_SIGN(x) ((x)->_mpfr_sign)
+
+/* Stack interface */
+typedef enum {
+  MPFR_NAN_KIND = 0,
+  MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
+} mpfr_kind_t;
+
+/* GMP defines:
+    + size_t:                Standard size_t
+    + __GMP_ATTRIBUTE_PURE   Attribute for math functions.
+    + __GMP_NOTHROW          For C++: can't throw .
+    + __GMP_EXTERN_INLINE    Attribute for inline function.
+    * __gmp_const            const (Supports for K&R compiler only for mpfr.h).
+    + __GMP_DECLSPEC_EXPORT  compiling to go into a DLL
+    + __GMP_DECLSPEC_IMPORT  compiling to go into a application
+*/
+/* Extra MPFR defines */
+#define __MPFR_SENTINEL_ATTR
+#if defined (__GNUC__)
+# if __GNUC__ >= 4
+#  undef __MPFR_SENTINEL_ATTR
+#  define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
+# endif
+#endif
+
+/* Prototypes: Support of K&R compiler */
+#if defined (__GMP_PROTO)
+# define _MPFR_PROTO __GMP_PROTO
+#elif defined (__STDC__) || defined (__cplusplus)
+# define _MPFR_PROTO(x) x
+#else
+# define _MPFR_PROTO(x) ()
+#endif
+/* Support for WINDOWS Dll:
+   Check if we are inside a MPFR build, and if so export the functions.
+   Otherwise does the same thing as GMP */
+#if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
+# define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
+#else
+# define __MPFR_DECLSPEC __GMP_DECLSPEC
+#endif
+
+/* Use MPFR_DEPRECATED to mark MPFR functions, types or variables as
+   deprecated. Code inspired by Apache Subversion's svn_types.h file. */
+#if defined(__GNUC__) && \
+  (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+# define MPFR_DEPRECATED __attribute__ ((deprecated))
+#elif defined(_MSC_VER) && _MSC_VER >= 1300
+# define MPFR_DEPRECATED __declspec(deprecated)
+#else
+# define MPFR_DEPRECATED
+#endif
+
+/* Note: In order to be declared, some functions need a specific
+   system header to be included *before* "mpfr.h". If the user
+   forgets to include the header, the MPFR function prototype in
+   the user object file is not correct. To avoid wrong results,
+   we raise a linker error in that case by changing their internal
+   name in the library (prefixed by __gmpfr instead of mpfr). See
+   the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+__MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
+__MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
+__MPFR_DECLSPEC int mpfr_buildopt_tls_p          _MPFR_PROTO ((void));
+__MPFR_DECLSPEC int mpfr_buildopt_decimal_p      _MPFR_PROTO ((void));
+__MPFR_DECLSPEC int mpfr_buildopt_gmpinternals_p _MPFR_PROTO ((void));
+__MPFR_DECLSPEC __gmp_const char * mpfr_buildopt_tune_case _MPFR_PROTO ((void));
+
+__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin     _MPFR_PROTO ((void));
+__MPFR_DECLSPEC int        mpfr_set_emin     _MPFR_PROTO ((mpfr_exp_t));
+__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
+__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
+__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax     _MPFR_PROTO ((void));
+__MPFR_DECLSPEC int        mpfr_set_emax     _MPFR_PROTO ((mpfr_exp_t));
+__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
+__MPFR_DECLSPEC mpfr_exp_t mpfr