[gmp-ecm] 58/77: Imported Upstream version 6.4.1-rc2

Jerome Benoit calculus-guest at moszumanska.debian.org
Sat Jun 6 12:33:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

calculus-guest pushed a commit to branch master
in repository gmp-ecm.

commit 767b849447da1abe02d81523bcf194aa06efeeba
Author: Laurent Fousse <laurent at komite.net>
Date:   Sun Mar 11 11:24:20 2012 -0700

    Imported Upstream version 6.4.1-rc2
---
 ChangeLog                                          |  945 ++++++++++++++++
 Fgw.c                                              |   17 +-
 INSTALL-ecm                                        |   18 +-
 Makefile.am                                        |   11 +-
 Makefile.in                                        |   29 +-
 NEWS                                               |   14 +
 README                                             |   19 +
 TODO                                               |    1 +
 auxi.c                                             |   85 ++
 batch.c                                            |  302 +++--
 bench_mulredc.c                                    |  433 +++++--
 build.vc10/Makefile.am                             |   10 +
 {build.vc9 => build.vc10}/Makefile.in              |   18 +-
 {build.vc9 => build.vc10}/assembler/Makefile.am    |    2 +-
 {build.vc9 => build.vc10}/assembler/Makefile.in    |    8 +-
 .../assembler/a_win32a_mulredc.asm                 |    0
 .../assembler/a_win32a_redc.asm                    |    0
 .../assembler/a_win32p_mulredc.asm                 |    0
 .../assembler/a_win32p_redc.asm                    |    0
 .../assembler/a_x64_mulredc.asm                    |    0
 {build.vc9 => build.vc10}/assembler/a_x64_redc.asm |    0
 build.vc10/assembler/mulredc.asm                   |    8 +
 {build.vc9 => build.vc10}/assembler/mulredc.h      |   65 +-
 build.vc10/assembler/redc.asm                      |    7 +
 {build.vc9 => build.vc10}/assembler/test_mulredc.c |    0
 build.vc10/bench_mulredc/.svn/entries              |  164 +++
 .../.svn/text-base/Makefile.am.svn-base            |    1 +
 .../bench_mulredc.vcxproj.filters.svn-base         |   26 +
 .../.svn/text-base/bench_mulredc.vcxproj.svn-base  |  171 +++
 .../text-base/bench_mulredc.vcxproj.user.svn-base  |    3 +
 .../bench_mulredc/Makefile                         |  281 +++--
 build.vc10/bench_mulredc/Makefile.am               |    1 +
 .../ecm => build.vc10/bench_mulredc}/Makefile.in   |    8 +-
 build.vc10/bench_mulredc/bench_mulredc.vcxproj     |  171 +++
 .../bench_mulredc/bench_mulredc.vcxproj.filters    |   26 +
 .../bench_mulredc/bench_mulredc.vcxproj.user       |    3 +
 {build.vc9 => build.vc10}/config.h                 |  443 ++++----
 .../ecm-params.h                                   |    2 -
 {build.vc9 => build.vc10}/ecm-params.h.win32.amd   |    1 +
 .../ecm-params.h.win32.intel                       |    0
 .../ecm-params.h.x64.amd                           |   30 +-
 build.vc10/ecm-params.h.x64.intel                  |   16 +
 build.vc10/ecm.sln                                 |   58 +
 build.vc10/ecm/Makefile.am                         |    1 +
 {build.vc9/tune => build.vc10/ecm}/Makefile.in     |    8 +-
 build.vc10/ecm/ecm.vcxproj                         |  234 ++++
 build.vc10/ecm/ecm.vcxproj.filters                 |   62 +
 {build.vc9 => build.vc10}/file_copy.bat            |    0
 build.vc10/getrusage.h                             |   46 +
 build.vc10/libecm/Makefile.am                      |    2 +
 {build.vc9 => build.vc10}/libecm/Makefile.in       |    8 +-
 build.vc10/libecm/libecm.vcxproj                   |  244 ++++
 build.vc10/libecm/libecm.vcxproj.filters           |  154 +++
 build.vc10/mp_lib.props                            |   20 +
 .../mul_fft-params.h.win32.amd                     |    0
 .../mul_fft-params.h.win32.intel                   |    0
 {build.vc9 => build.vc10}/mul_fft-params.h.x64.amd |    0
 .../mul_fft-params.h.x64.intel                     |    0
 {build.vc9 => build.vc10}/readme.txt               |   48 +-
 {build.vc9 => build.vc10}/tests.py                 |   27 +-
 build.vc10/tune/Makefile.am                        |    1 +
 {build.vc9/ecm => build.vc10/tune}/Makefile.in     |    8 +-
 build.vc10/tune/tune.vcxproj                       |  160 +++
 build.vc10/tune/tune.vcxproj.filters               |  112 ++
 build.vc10/vsyasm.props                            |   27 +
 build.vc10/vsyasm.targets                          |  108 ++
 build.vc10/vsyasm.xml                              |  283 +++++
 build.vc9/Makefile.am                              |    8 -
 build.vc9/ecm-params.h                             |   11 -
 build.vc9/ecm-params.h.win32.intel                 |   10 -
 build.vc9/ecm-params.h.x64.amd                     |   12 -
 build.vc9/ecm-params.h.x64.intel                   |   22 -
 build.vc9/ecm.sln                                  |   72 --
 build.vc9/ecm/Makefile.am                          |    1 -
 build.vc9/ecm/ecm.vcproj                           |  733 ------------
 build.vc9/libecm/Makefile.am                       |    1 -
 build.vc9/libecm/libecm.vcproj                     | 1192 --------------------
 build.vc9/mp_lib.vsprops                           |   14 -
 build.vc9/tune/Makefile.am                         |    1 -
 build.vc9/tune/tune.vcproj                         |  646 -----------
 build.vc9/yasm.rules                               |  114 --
 config.h.in                                        |   26 +-
 configure                                          |  327 ++++--
 configure.in                                       |   60 +-
 ecm-ecm.h                                          |   10 +-
 ecm-gmp.h                                          |    5 +-
 ecm-impl.h                                         |   44 +-
 ecm-params.h                                       |   34 +-
 ecm-params.h.alpha-ev56                            |    2 -
 ecm-params.h.armv5tel                              |    2 -
 ecm-params.h.athlon64                              |   18 +-
 ecm-params.h.core2                                 |   18 +-
 ecm-params.h.corei5                                |   26 +
 ecm-params.h.hppa2.0                               |    2 -
 ecm-params.h.ia64                                  |    2 -
 ecm-params.h.mips64el                              |    2 -
 ecm-params.h.pentium-m                             |    2 -
 ecm-params.h.pentium4                              |    2 -
 ecm-params.h.powerpc970                            |    2 -
 ecm-params.h.sparc64                               |    2 -
 ecm.c                                              |  105 +-
 ecm2.c                                             |   12 +-
 ecm_ntt.c                                          |    5 +-
 ellparam_batch.c                                   |  232 ++++
 getprime.c                                         |    2 +-
 listz.c                                            |  124 +-
 lucas.c                                            |    2 +-
 main.c                                             |  183 +--
 mpmod.c                                            |  573 ++++++++--
 mpmod.h                                            |   27 +
 mpzspv.c                                           |   14 +-
 pm1fs2.c                                           |   58 +-
 pp1.c                                              |   10 +-
 resume.c                                           |    5 +
 sets_long.c                                        |   10 +-
 stage2.c                                           |    1 -
 test.ecm                                           |   40 +-
 test.pm1                                           |    4 +-
 test_mulredc.c                                     |   21 -
 tune.c                                             |   71 +-
 x86_64/mulredc.h                                   |    3 +-
 x86_64/mulredc.m4                                  |    5 +-
 x86_64/mulredc10.asm                               |    6 +-
 x86_64/mulredc11.asm                               |    6 +-
 x86_64/mulredc12.asm                               |    6 +-
 x86_64/mulredc13.asm                               |    6 +-
 x86_64/mulredc14.asm                               |    6 +-
 x86_64/mulredc15.asm                               |    6 +-
 x86_64/mulredc16.asm                               |    6 +-
 x86_64/mulredc17.asm                               |    6 +-
 x86_64/mulredc18.asm                               |    6 +-
 x86_64/mulredc19.asm                               |    6 +-
 x86_64/mulredc2.asm                                |    6 +-
 x86_64/mulredc20.asm                               |    6 +-
 x86_64/mulredc3.asm                                |    6 +-
 x86_64/mulredc4.asm                                |    6 +-
 x86_64/mulredc5.asm                                |    6 +-
 x86_64/mulredc6.asm                                |    6 +-
 x86_64/mulredc7.asm                                |    6 +-
 x86_64/mulredc8.asm                                |    6 +-
 x86_64/mulredc9.asm                                |    6 +-
 141 files changed, 5812 insertions(+), 4182 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 03679e7..5517174 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,949 @@
 ------------------------------------------------------------------------
+r1793 | bouvierc | 2012-03-07 15:12:28 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+
+Some changes in the Makefile for GPU-ECM
+
+------------------------------------------------------------------------
+r1792 | zimmerma | 2012-03-07 15:11:10 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/ecm-params.h.powerpc970
+
+[ecm-params.h.powerpc970] removed exec flag
+
+------------------------------------------------------------------------
+r1791 | zimmerma | 2012-03-07 15:02:14 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/ecm-impl.h
+   M /trunk/mpmod.c
+
+[ecm-impl.h,mpmod.c] removed mult_modulus (was always equal to orig_modulus)
+
+------------------------------------------------------------------------
+r1790 | zimmerma | 2012-03-07 14:22:50 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/pm1fs2.c
+
+[pm1fs2.c] changed assert to avoid compiler warning with clang 2.9
+
+------------------------------------------------------------------------
+r1789 | zimmerma | 2012-03-07 13:54:25 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/configure.in
+
+[configure.in] added missing build.vc10/bench_mulredc/Makefile
+
+------------------------------------------------------------------------
+r1788 | zimmerma | 2012-03-07 13:46:16 +0100 (Wed, 07 Mar 2012) | 3 lines
+Changed paths:
+   M /trunk/README.dev
+   M /trunk/build.vc10/config.h
+   M /trunk/configure.in
+   M /trunk/ecm-gmp.h
+
+change version to 6.4.1-rc1
+switched assertions to off for the release candidate
+
+------------------------------------------------------------------------
+r1787 | zimmerma | 2012-03-07 13:13:20 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/listz.c
+   M /trunk/stage2.c
+
+[listz.c] cleanup, and removed some dead code in #if 0 ... #endif
+
+------------------------------------------------------------------------
+r1786 | zimmerma | 2012-03-07 10:40:51 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/ecm-impl.h
+   M /trunk/ecm_ntt.c
+   M /trunk/listz.c
+
+fix NEGATED_ROOTS=1 once for all
+
+------------------------------------------------------------------------
+r1785 | zimmerma | 2012-03-07 10:12:57 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/main.c
+
+[main.c] -treefile is valid for ECM only
+
+------------------------------------------------------------------------
+r1784 | zimmerma | 2012-03-07 10:01:19 +0100 (Wed, 07 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/test.ecm
+
+[test.ecm] added test with -treefile
+
+------------------------------------------------------------------------
+r1783 | zimmerma | 2012-03-05 08:56:02 +0100 (Mon, 05 Mar 2012) | 3 lines
+Changed paths:
+   M /trunk/ecm.c
+
+[ecm.c] with -v -v, print A=... and x0=... for coherence with command line
+	options
+
+------------------------------------------------------------------------
+r1782 | zimmerma | 2012-03-02 17:27:57 +0100 (Fri, 02 Mar 2012) | 3 lines
+Changed paths:
+   M /trunk/README.dev
+   M /trunk/TODO
+
+[README.dev] added check of -treefile before a release
+[TODO] at some point we should raise sigma to 64 bits
+
+------------------------------------------------------------------------
+r1781 | bouvierc | 2012-03-01 17:43:16 +0100 (Thu, 01 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/cudakernel.cu
+   M /trunk/gpu/gpu_ecm/main.c
+
+Better measurement of actual running time.
+
+------------------------------------------------------------------------
+r1779 | bouvierc | 2012-03-01 13:44:35 +0100 (Thu, 01 Mar 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/check.sh
+   M /trunk/gpu/gpu_ecm/cudakernel.cu
+   M /trunk/gpu/gpu_ecm/main.c
+
+Don't do modular reduction anymore in GPU arithmetic.
+
+------------------------------------------------------------------------
+r1778 | bouvierc | 2012-02-29 15:50:23 +0100 (Wed, 29 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/cudakernel.cu
+   M /trunk/gpu/gpu_ecm/main.c
+
+Prepare the code to use Montgomery-Svoboda algorithm for REDC
+
+------------------------------------------------------------------------
+r1777 | bouvierc | 2012-02-29 15:49:02 +0100 (Wed, 29 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+
+Add an include when linked for GPU-ECM
+
+------------------------------------------------------------------------
+r1775 | bouvierc | 2012-02-28 15:50:25 +0100 (Tue, 28 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/ecm-ecm.h
+   M /trunk/ecm-impl.h
+   M /trunk/main.c
+
+Batch mode: allow to save and load s from a file.
+
+------------------------------------------------------------------------
+r1774 | bouvierc | 2012-02-27 11:45:40 +0100 (Mon, 27 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/test.ecm
+
+Replace ecm and ./ecm by $ECM in two lines of the test file.
+
+------------------------------------------------------------------------
+r1773 | brian_gladman | 2012-02-24 16:47:31 +0100 (Fri, 24 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/ecm/ecm.vcxproj
+   M /trunk/build.vc10/ecm/ecm.vcxproj.filters
+
+
+------------------------------------------------------------------------
+r1772 | brian_gladman | 2012-02-24 16:43:18 +0100 (Fri, 24 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/config.h
+   M /trunk/build.vc10/gpu_ecm/gpu_ecm.vcxproj
+   M /trunk/build.vc10/libecm/libecm.vcxproj
+   M /trunk/build.vc10/libecm/libecm.vcxproj.filters
+
+Update the gpu_ecm build for Windows
+------------------------------------------------------------------------
+r1771 | bouvierc | 2012-02-24 15:15:31 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/cudakernel.cu
+   M /trunk/gpu/gpu_ecm/cudakernel.h
+
+Make the CPU code handling the GPU clearer.
+
+------------------------------------------------------------------------
+r1770 | bouvierc | 2012-02-24 13:58:59 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+Minor change in main.c. Add some comments.
+
+------------------------------------------------------------------------
+r1769 | bouvierc | 2012-02-24 13:43:26 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+
+Fix a problem reported by Brian Gladman.
+
+------------------------------------------------------------------------
+r1768 | bouvierc | 2012-02-24 11:24:31 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+All factors found and cofactors are printed the same way.
+
+------------------------------------------------------------------------
+r1767 | bouvierc | 2012-02-24 11:02:51 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/main.c
+
+Use the struct mpcandi_t.
+
+------------------------------------------------------------------------
+r1766 | bouvierc | 2012-02-24 10:45:26 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/resume.c
+
+Write the right program name and right version in resume file.
+
+------------------------------------------------------------------------
+r1765 | bouvierc | 2012-02-24 10:32:36 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/cudakernel.cu
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+More clear variables' name. More comment in main.c
+
+------------------------------------------------------------------------
+r1764 | bouvierc | 2012-02-24 09:47:36 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+Use write_resumefile_line from GMP-ECM.
+
+------------------------------------------------------------------------
+r1763 | zimmerma | 2012-02-24 08:19:43 +0100 (Fri, 24 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/check.sh
+
+[check.sh] translated error message in english
+
+------------------------------------------------------------------------
+r1762 | bouvierc | 2012-02-23 18:19:07 +0100 (Thu, 23 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   M /trunk/gpu/gpu_ecm/README
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+Using more functions from GMP-ECM.
+
+------------------------------------------------------------------------
+r1761 | bouvierc | 2012-02-23 18:18:26 +0100 (Thu, 23 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/check.sh
+
+Keep temp files when an error occurs in check.sh.
+
+------------------------------------------------------------------------
+r1760 | bouvierc | 2012-02-23 17:55:03 +0100 (Thu, 23 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/ecm-ecm.h
+
+Delete duplicate prototypes.
+
+------------------------------------------------------------------------
+r1759 | bouvierc | 2012-02-23 17:11:10 +0100 (Thu, 23 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/auxi.c
+   M /trunk/ecm-ecm.h
+   M /trunk/main.c
+
+Move some functions out of main.c in order to use them with GPU-ECM.
+
+------------------------------------------------------------------------
+r1758 | bouvierc | 2012-02-23 16:23:58 +0100 (Thu, 23 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/gpu/gpu_ecm/Makefile
+   M /trunk/gpu/gpu_ecm/def.h
+   M /trunk/gpu/gpu_ecm/main.c
+   M /trunk/gpu/gpu_ecm/utils.c
+   M /trunk/gpu/gpu_ecm/utils.h
+
+Start to use GMP-ECM functions in GPU-ECM when they exist.
+
+------------------------------------------------------------------------
+r1757 | bouvierc | 2012-02-23 14:54:11 +0100 (Thu, 23 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   A /trunk/gpu/gpu_ecm/README.dev
+   D /trunk/gpu/gpu_ecm/cudaarith.cu
+   D /trunk/gpu/gpu_ecm/cudaarith.h
+   A /trunk/gpu/gpu_ecm/cudakernel.cu (from /trunk/gpu/gpu_ecm/cudautils.cu:1756)
+   A /trunk/gpu/gpu_ecm/cudakernel.h (from /trunk/gpu/gpu_ecm/cudautils.h:1756)
+   D /trunk/gpu/gpu_ecm/cudautils.cu
+   D /trunk/gpu/gpu_ecm/cudautils.h
+   A /trunk/gpu/gpu_ecm/def.h (from /trunk/gpu/gpu_ecm/main.h:1756)
+   A /trunk/gpu/gpu_ecm/main.c (from /trunk/gpu/gpu_ecm/main.cu:1756)
+   D /trunk/gpu/gpu_ecm/main.cu
+   D /trunk/gpu/gpu_ecm/main.h
+   A /trunk/gpu/gpu_ecm/utils.c (from /trunk/gpu/gpu_ecm/utils.cu:1756)
+   D /trunk/gpu/gpu_ecm/utils.cu
+   M /trunk/gpu/gpu_ecm/utils.h
+
+Reorganization of the code. C code is put in C files compiled with gcc and Cuda
+code is put in .cu files and compiled with nvcc.
+
+
+------------------------------------------------------------------------
+r1756 | bouvierc | 2012-02-22 21:18:28 +0100 (Wed, 22 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/utils.cu
+
+Fix a bug reported by Brian Gladman.
+
+------------------------------------------------------------------------
+r1755 | bouvierc | 2012-02-22 16:12:37 +0100 (Wed, 22 Feb 2012) | 5 lines
+Changed paths:
+   M /trunk/ecm.c
+   M /trunk/main.c
+   M /trunk/test.ecm
+
+[ecm.c] Fix a problem for batch mode 2 when the value obtained from the
+parametrization is printed
+[main.c] Print which batch mode is used.
+[test.ecm] Add a test for batch mode 2.
+
+------------------------------------------------------------------------
+r1754 | bouvierc | 2012-02-22 16:09:58 +0100 (Wed, 22 Feb 2012) | 2 lines
+Changed paths:
+   D /trunk/gpu/gpu_ecm/obj
+   D /trunk/gpu/gpu_ecm/test.sh
+
+Delete useless files
+
+------------------------------------------------------------------------
+r1753 | bouvierc | 2012-02-22 16:07:10 +0100 (Wed, 22 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   A /trunk/gpu/gpu_ecm/README
+   M /trunk/gpu/gpu_ecm/check.sh
+   M /trunk/gpu/gpu_ecm/main.h
+
+[Makefile] A more-easy-to-use Makefile
+[README] README explaining how to compile and execute GPU-ECM and how to use
+check.sh
+
+------------------------------------------------------------------------
+r1752 | bouvierc | 2012-02-22 12:04:26 +0100 (Wed, 22 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+
+fix a bug in batch mode 2
+
+------------------------------------------------------------------------
+r1751 | bouvierc | 2012-02-22 11:42:57 +0100 (Wed, 22 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/ecm.c
+
+Fix batch mode 1 which didn't pass all the test because of previous commits.
+
+------------------------------------------------------------------------
+r1750 | bouvierc | 2012-02-22 10:21:27 +0100 (Wed, 22 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/main.cu
+   M /trunk/gpu/gpu_ecm/utils.cu
+
+Fix some bugs for 32-bits machines.
+
+------------------------------------------------------------------------
+r1749 | bouvierc | 2012-02-21 18:25:00 +0100 (Tue, 21 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/batch.c
+   D /trunk/batchmode.h
+   M /trunk/ecm-impl.h
+   M /trunk/ecm.c
+   M /trunk/main.c
+
+Now the choice of the which batch mode is used is not done by a #define.
+It can be passed as a argument: -batch[=1|2], with -batch being equivalent to
+-batch=1 
+
+------------------------------------------------------------------------
+r1748 | bouvierc | 2012-02-21 17:46:23 +0100 (Tue, 21 Feb 2012) | 2 lines
+Changed paths:
+   A /trunk/batchmode.h
+   A /trunk/ellparam_batch.c
+
+Forgot to add 2 new files in the last commit.
+
+------------------------------------------------------------------------
+r1747 | bouvierc | 2012-02-21 17:45:28 +0100 (Tue, 21 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/Makefile.am
+   M /trunk/batch.c
+   M /trunk/ecm.c
+   M /trunk/main.c
+
+Add elliptic parametrization for batch mode 2
+Move the choice of A for batch mode in ecm.c (as the choice of sigma for Suyama)
+
+
+------------------------------------------------------------------------
+r1746 | brian_gladman | 2012-02-16 18:40:14 +0100 (Thu, 16 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/gpu/gpu_ecm/main.cu
+
+set IDLE priority for GPU application on Windows 
+------------------------------------------------------------------------
+r1745 | brian_gladman | 2012-02-16 17:31:39 +0100 (Thu, 16 Feb 2012) | 1 line
+Changed paths:
+   A /trunk/build.vc10/readme_gpu.txt
+
+add short readme for the Windows GPU build
+------------------------------------------------------------------------
+r1744 | brian_gladman | 2012-02-16 17:18:53 +0100 (Thu, 16 Feb 2012) | 1 line
+Changed paths:
+   A /trunk/build.vc10/ecm.cuda.sln
+
+Add Visual Studio build for the GPU code
+------------------------------------------------------------------------
+r1743 | brian_gladman | 2012-02-16 17:15:45 +0100 (Thu, 16 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/getrusage.h
+   A /trunk/build.vc10/gpu_ecm
+   A /trunk/build.vc10/gpu_ecm/gpu_ecm.vcxproj
+   M /trunk/gpu/gpu_ecm/main.cu
+   M /trunk/gpu/gpu_ecm/main.h
+   M /trunk/gpu/gpu_ecm/utils.cu
+   M /trunk/gpu/gpu_ecm/utils.h
+   M /trunk/gpu/modular_arithmetic.c
+
+
+------------------------------------------------------------------------
+r1742 | brian_gladman | 2012-02-13 22:33:07 +0100 (Mon, 13 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/config.h
+
+correct conflicted config.h
+------------------------------------------------------------------------
+r1741 | brian_gladman | 2012-02-13 22:06:19 +0100 (Mon, 13 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/bench_mulredc.c
+   M /trunk/build.vc10/Makefile.am
+   M /trunk/build.vc10/assembler/Makefile.am
+   A /trunk/build.vc10/assembler/mulredc.asm
+   M /trunk/build.vc10/assembler/mulredc.h
+   A /trunk/build.vc10/assembler/redc.asm
+   A /trunk/build.vc10/bench_mulredc
+   A /trunk/build.vc10/bench_mulredc/Makefile.am
+   A /trunk/build.vc10/bench_mulredc/bench_mulredc.vcxproj
+   A /trunk/build.vc10/bench_mulredc/bench_mulredc.vcxproj.filters
+   A /trunk/build.vc10/bench_mulredc/bench_mulredc.vcxproj.user
+   M /trunk/build.vc10/config.h
+   M /trunk/build.vc10/ecm/ecm.vcxproj
+   M /trunk/build.vc10/ecm.sln
+   A /trunk/build.vc10/getrusage.c
+   A /trunk/build.vc10/getrusage.h
+   M /trunk/build.vc10/libecm/libecm.vcxproj
+   M /trunk/build.vc10/libecm/libecm.vcxproj.filters
+   M /trunk/build.vc10/tune/tune.vcxproj
+   M /trunk/build.vc10/tune/tune.vcxproj.filters
+
+Revamp the Windows Visual Studio 2010 build
+------------------------------------------------------------------------
+r1738 | zimmerma | 2012-02-12 23:46:20 +0100 (Sun, 12 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/bench_mulredc.c
+
+[bench_mulredc.c] added some Svoboda code (not tested so far) and avoid some
+		  warnings if mpn_redc_2 and mpn_redc_n are not defined
+
+------------------------------------------------------------------------
+r1737 | dcleaver | 2012-02-12 23:24:37 +0100 (Sun, 12 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/Fgw.c
+   M /trunk/test.ecm
+
+Clean up comments and make ecm test deterministic
+------------------------------------------------------------------------
+r1736 | zimmerma | 2012-02-12 23:05:25 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/mpmod.c
+
+[mpmod.c] fixed misplaced #ifdef, added comments, MPN_COPY -> mpn_copyi
+
+------------------------------------------------------------------------
+r1735 | dcleaver | 2012-02-12 21:50:37 +0100 (Sun, 12 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/test.ecm
+
+Added/fixed test to exercise r1734 patch
+------------------------------------------------------------------------
+r1734 | dcleaver | 2012-02-12 21:44:33 +0100 (Sun, 12 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/Fgw.c
+   M /trunk/test.ecm
+
+Patched Fgw.c to allocate adequate memory for special inputs
+------------------------------------------------------------------------
+r1733 | zimmerma | 2012-02-12 20:15:50 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/bench_mulredc.c
+   M /trunk/configure.in
+   M /trunk/mpmod.h
+
+also consider mpn_redc_n in bench_mulredc (not yet used in mpmod.c)
+
+------------------------------------------------------------------------
+r1732 | brian_gladman | 2012-02-12 19:54:10 +0100 (Sun, 12 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/assembler/mulredc.h
+   M /trunk/build.vc10/libecm/libecm.vcxproj
+   M /trunk/build.vc10/tune/tune.vcxproj
+
+Make use of assembler code the default for Windows
+------------------------------------------------------------------------
+r1731 | zimmerma | 2012-02-12 17:34:08 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/mpmod.c
+
+[mpmod.c] fixed problem reported by David Cleaver on ecm-discuss
+
+------------------------------------------------------------------------
+r1730 | zimmerma | 2012-02-12 17:23:22 +0100 (Sun, 12 Feb 2012) | 5 lines
+Changed paths:
+   M /trunk/bench_mulredc.c
+   M /trunk/configure.in
+   M /trunk/ecm-params.h.core2
+   M /trunk/mpmod.c
+
+[configure.in] bump minimal GMP version to 5.0.0
+[bench_mulredc.c,mpmod.c] since mpn_sqr is defined in GMP >= 5, no need to test
+			  it
+[ecm-params.h.core2] updated
+
+------------------------------------------------------------------------
+r1729 | zimmerma | 2012-02-12 16:12:25 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/build.vc10/assembler/Makefile.am
+
+[assembler/Makefile.am] added missing mulredc.h
+
+------------------------------------------------------------------------
+r1726 | zimmerma | 2012-02-12 12:03:54 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/Makefile.am
+   M /trunk/bench_mulredc.c
+   M /trunk/mpmod.c
+   A /trunk/mpmod.h
+
+define macros for different choices of redc modular arithmetic
+
+------------------------------------------------------------------------
+r1725 | zimmerma | 2012-02-12 08:35:20 +0100 (Sun, 12 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/build.vc10/Makefile.am
+
+[build.vc10/Makefile.am] removed non-existent file ecm-params.h.x64.core2
+
+------------------------------------------------------------------------
+r1724 | brian_gladman | 2012-02-12 00:07:15 +0100 (Sun, 12 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/Makefile.am
+
+add distributed in build.vc10 to files to makefile.am 
+------------------------------------------------------------------------
+r1723 | zimmerma | 2012-02-11 14:37:39 +0100 (Sat, 11 Feb 2012) | 15 lines
+Changed paths:
+   M /trunk/README
+   M /trunk/bench_mulredc.c
+   M /trunk/ecm-impl.h
+   M /trunk/ecm-params.h.alpha-ev56
+   M /trunk/ecm-params.h.armv5tel
+   M /trunk/ecm-params.h.athlon64
+   M /trunk/ecm-params.h.core2
+   M /trunk/ecm-params.h.corei5
+   M /trunk/ecm-params.h.hppa2.0
+   M /trunk/ecm-params.h.ia64
+   M /trunk/ecm-params.h.mips64el
+   M /trunk/ecm-params.h.pentium-m
+   M /trunk/ecm-params.h.pentium4
+   M /trunk/ecm-params.h.powerpc970
+   M /trunk/ecm-params.h.sparc64
+   M /trunk/main.c
+   M /trunk/mpmod.c
+   M /trunk/test.pm1
+   M /trunk/tune.c
+
+Complete rewrite of the tuning mechanism for mulredc and sqrredc: instead of
+having a simple threshold, we have a full table for each one up to 20 limbs,
+where each entry for n limbs is an integer saying which function(s) should be
+used for the modular multiplication or squaring.
+
+Those tables are computed by bench_mulredc.
+
+On processors where assembly redc is available, I suggest we always have
+--enable-asm-redc, since the best routine will be chosen by bench_mulredc.
+
+On processors where assembly redc is not available, I suggest we still can
+use/compile bench_mulredc to choose the best routines.
+
+Ultimately bench_mulredc should be incorporated into "make tune".
+
+------------------------------------------------------------------------
+r1722 | brian_gladman | 2012-02-11 12:09:52 +0100 (Sat, 11 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/ecm/Makefile.am
+   M /trunk/build.vc10/libecm/Makefile.am
+   M /trunk/build.vc10/tune/Makefile.am
+
+Add IDE filters to the GMP-ECM distrubution
+------------------------------------------------------------------------
+r1721 | zimmerma | 2012-02-11 09:45:15 +0100 (Sat, 11 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/build.vc10/Makefile.am
+   A /trunk/build.vc10/tune/Makefile.am
+   M /trunk/configure.in
+
+another try to fix missing vc10 files
+
+------------------------------------------------------------------------
+r1720 | brian_gladman | 2012-02-10 21:40:28 +0100 (Fri, 10 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/ecm/ecm.vcxproj
+   M /trunk/build.vc10/tests.py
+
+another Windows build correction
+------------------------------------------------------------------------
+r1719 | zimmerma | 2012-02-10 21:38:19 +0100 (Fri, 10 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/bench_mulredc.c
+   M /trunk/x86_64/Makefile.am
+   M /trunk/x86_64/mulredc.h
+
+[x86_64] enable back redc3 code (can be useful for modular squaring)
+[bench_mulredc.c] print results of tuning at the end
+
+------------------------------------------------------------------------
+r1718 | zimmerma | 2012-02-10 20:52:57 +0100 (Fri, 10 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/Makefile.am
+   A /trunk/build.vc10/Makefile.am
+   A /trunk/build.vc10/assembler/Makefile.am
+   A /trunk/build.vc10/ecm/Makefile.am
+   A /trunk/build.vc10/libecm/Makefile.am
+   M /trunk/configure.in
+
+put in "make dist" missing build.vc10 files (to be checked)
+
+------------------------------------------------------------------------
+r1717 | zimmerma | 2012-02-10 20:12:15 +0100 (Fri, 10 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/ecm.c
+
+[ecm.c] for the batch mode and A=4d-2 with d "random", the torsion smoothness
+	multiplier is 1/(3*3^(1/128)) = 0.330... and not 1/3 !
+
+------------------------------------------------------------------------
+r1716 | brian_gladman | 2012-02-10 13:32:53 +0100 (Fri, 10 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/libecm/libecm.vcxproj
+
+minor windows build change
+------------------------------------------------------------------------
+r1715 | brian_gladman | 2012-02-10 10:49:38 +0100 (Fri, 10 Feb 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/ecm-params.h
+   M /trunk/build.vc10/ecm-params.h.win32.amd
+   M /trunk/build.vc10/ecm-params.h.win32.intel
+   M /trunk/build.vc10/ecm-params.h.x64.amd
+   M /trunk/build.vc10/ecm-params.h.x64.intel
+   M /trunk/build.vc10/tune/tune.vcxproj
+   M /trunk/build.vc10/tune/tune.vcxproj.filters
+
+correct windows tuning errors
+------------------------------------------------------------------------
+r1714 | zimmerma | 2012-02-09 12:42:54 +0100 (Thu, 09 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/bench_mulredc.c
+
+[bench_mulredc.c] updated to measure more low-level functions
+
+------------------------------------------------------------------------
+r1713 | zimmerma | 2012-02-08 12:29:36 +0100 (Wed, 08 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/ecm.c
+
+[ecm.c] corrected the value of BATCH_EXTRA_SMOOTHNESS for GMP_NUMB_BITS >= 64,
+	where we use A=4d-2 with d a square
+
+------------------------------------------------------------------------
+r1712 | zimmerma | 2012-02-07 22:24:56 +0100 (Tue, 07 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/mpmod.c
+
+[mpmod.c] new function sqrredc in C (not used yet because slower than the
+	  assembly mulredc)
+	  use redc_basecase_n in mpresn_sqr and mpresn_mul: small speedup
+
+------------------------------------------------------------------------
+r1711 | zimmerma | 2012-02-06 17:15:47 +0100 (Mon, 06 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/mpmod.c
+
+[mpmod.c] use TUNE_SQRREDC_THRESH and TUNE_MULREDC_THRESH in the mpresn_*
+	  functions
+
+------------------------------------------------------------------------
+r1710 | zimmerma | 2012-02-06 16:10:32 +0100 (Mon, 06 Feb 2012) | 3 lines
+Changed paths:
+   M /trunk/README.dev
+   M /trunk/ecmbench
+
+[ecmbench] use $1 to allow testing different versions
+[README.dev] added item for efficiency non-regression
+
+------------------------------------------------------------------------
+r1708 | zimmerma | 2012-02-06 15:58:01 +0100 (Mon, 06 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/ecm.c
+   M /trunk/ecm2.c
+   M /trunk/lucas.c
+   M /trunk/mpmod.c
+   M /trunk/pm1fs2.c
+   M /trunk/pp1.c
+   M /trunk/tune.c
+
+replaced all occurrences of mpres_mul (a, x, x, m) by mpres_sqr (a, x, m)
+
+------------------------------------------------------------------------
+r1706 | zimmerma | 2012-02-06 14:34:35 +0100 (Mon, 06 Feb 2012) | 7 lines
+Changed paths:
+   M /trunk/NEWS
+   M /trunk/README.dev
+   M /trunk/configure.in
+   M /trunk/ecm-impl.h
+   A /trunk/ecm-params.h.corei5
+   A /trunk/ecmbench
+   M /trunk/mpmod.c
+   M /trunk/tune.c
+
+[tune.c] cleaned up comptutation of TUNE_MULREDC_THRESH and TUNE_SQRREDC_THRESH
+[ecm-params.h.corei5] new parameters for Core i5
+[configure.in] now recognize Core i5
+[ecmbench] new bench utility
+[ecm-impl.h] new macro MULREDC_ASSEMBLY_MAX
+[mpmod.c] use MULREDC_ASSEMBLY_MAX
+
+------------------------------------------------------------------------
+r1703 | zimmerma | 2012-02-04 09:47:09 +0100 (Sat, 04 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/build.vc10/config.h
+   M /trunk/configure.in
+
+switch version to 6.5-dev, and assertions on by default
+
+------------------------------------------------------------------------
+r1701 | zimmerma | 2012-02-03 20:59:21 +0100 (Fri, 03 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/mpmod.c
+
+make new batch-mode code also work with --disable-asm-redc
+
+------------------------------------------------------------------------
+r1700 | zimmerma | 2012-02-03 17:14:22 +0100 (Fri, 03 Feb 2012) | 6 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/ecm-impl.h
+   M /trunk/ecm.c
+   M /trunk/mpmod.c
+   M /trunk/pm1fs2.c
+
+[pm1fs2.c] renamed mpmod_copy into mpmod_init_set
+[batch.c] use new function mpresn_pad
+[ecm-impl.h] added mult_modulus (currrently initialized to N)
+[mpmod.c] simplified the mpresn_* functions (assuming repr=ECM_MOD_MODMULN)
+[ecm.c] in batch mode, force repr=ECM_MOD_MODMULN
+
+------------------------------------------------------------------------
+r1697 | zimmerma | 2012-02-03 10:07:59 +0100 (Fri, 03 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/ecm-impl.h
+   M /trunk/mpmod.c
+
+[ecm-impl.h] added missing prototypes
+[batch.c] removed debug printf() statements
+[mpmod.c] fixed compiler warnings
+
+------------------------------------------------------------------------
+r1696 | zimmerma | 2012-02-02 20:08:19 +0100 (Thu, 02 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/NEWS
+
+[NEWS] added --enable-mulredc-svodoba
+
+------------------------------------------------------------------------
+r1695 | bouvierc | 2012-02-02 15:57:09 +0100 (Thu, 02 Feb 2012) | 4 lines
+Changed paths:
+   M /trunk/batch.c
+   M /trunk/mpmod.c
+
+Replace mpz operations by mpn operations in dup_add in batch.c
+For now only mul, sqr, add and sub have been modified.
+Reduction have not changed.
+
+------------------------------------------------------------------------
+r1694 | kruppa | 2012-02-02 15:52:19 +0100 (Thu, 02 Feb 2012) | 2 lines
+Changed paths:
+   M /trunk/configure.in
+   M /trunk/x86_64/mulredc.m4
+
+Support for Svoboda mulredc in x86_64/. Matching support in mpmod.c TBD
+
+------------------------------------------------------------------------
+r1693 | zimmerma | 2012-01-30 17:58:24 +0100 (Mon, 30 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/getprime.c
+
+[getprime.c] fixed typo in commented printf()
+
+------------------------------------------------------------------------
+r1690 | kruppa | 2012-01-16 16:00:54 +0100 (Mon, 16 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/mpzspv.c
+
+Slight cleanup
+
+------------------------------------------------------------------------
+r1684 | zimmerma | 2012-01-09 14:12:38 +0100 (Mon, 09 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/mpmod.c
+
+[mpmod.c] perform lazy reduction in REDC when N < B^n/4
+
+------------------------------------------------------------------------
+r1678 | zimmerma | 2012-01-07 16:45:28 +0100 (Sat, 07 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/INSTALL-ecm
+   M /trunk/Makefile.am
+   M /trunk/configure.in
+
+removed leftover references to build.vc9
+
+------------------------------------------------------------------------
+r1677 | zimmerma | 2012-01-06 18:32:22 +0100 (Fri, 06 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/gpu/gpu_ecm/Makefile
+   M /trunk/gpu/gpu_ecm_cc13/Makefile
+
+cleaned up Makefiles
+
+------------------------------------------------------------------------
+r1676 | brian_gladman | 2012-01-04 18:14:22 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk
+   D /trunk/build.vc9
+
+Remove some errors from the Visual Studio readme.txt filesremove unmaintained Visual Studio 2008 build files
+
+------------------------------------------------------------------------
+r1675 | zimmerma | 2012-01-04 09:53:53 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/main.c
+
+[main.c] fixed warning on 32-bit processor
+
+------------------------------------------------------------------------
+r1674 | zimmerma | 2012-01-04 00:44:48 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/README.dev
+
+[README.dev] added tag for 6.4
+
+------------------------------------------------------------------------
+r1672 | zimmerma | 2012-01-04 00:42:50 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/ChangeLog
+
+[ChangeLog] updated, this is the GMP-ECM 6.4 release
+
+------------------------------------------------------------------------
+r1671 | brian_gladman | 2012-01-04 00:39:25 +0100 (Wed, 04 Jan 2012) | 1 line
+Changed paths:
+   M /trunk/build.vc10/readme.txt
+   M /trunk/build.vc9/readme.txt
+
+Remove some errors from the Visual Studio readme.txt files
+------------------------------------------------------------------------
+r1670 | zimmerma | 2012-01-04 00:38:05 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   A /trunk/INSTALL-ecm (from /trunk/INSTALL:1662)
+
+[INSTALL-ecm] specific INSTALL file for GMP-ECM
+
+------------------------------------------------------------------------
+r1669 | zimmerma | 2012-01-04 00:34:36 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/mpmod.c
+   M /trunk/resume.c
+
+removed compiler warnings found with gcc 4.6.1
+
+------------------------------------------------------------------------
+r1668 | zimmerma | 2012-01-04 00:26:26 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/configure.in
+
+[configure.in] added code to check for Pentium 4
+
+------------------------------------------------------------------------
+r1667 | zimmerma | 2012-01-04 00:24:49 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   D /trunk/INSTALL
+
+[INSTALL] removed from svn, since it is now autogenerated by the autotools
+
+------------------------------------------------------------------------
+r1666 | zimmerma | 2012-01-04 00:24:01 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/ChangeLog
+
+[ChangeLog] updated for 6.4
+
+------------------------------------------------------------------------
+r1665 | zimmerma | 2012-01-04 00:21:36 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/TODO
+
+[TODO] removed several done items
+
+------------------------------------------------------------------------
+r1664 | zimmerma | 2012-01-04 00:21:13 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/README
+
+[README] added sample example
+
+------------------------------------------------------------------------
+r1663 | zimmerma | 2012-01-04 00:20:54 +0100 (Wed, 04 Jan 2012) | 2 lines
+Changed paths:
+   M /trunk/Makefile.am
+
+[Makefile.am] added INSTALL-ecm (INSTALL is now the generic GNU package file)
+
+------------------------------------------------------------------------
 r1662 | zimmerma | 2012-01-04 00:13:33 +0100 (Wed, 04 Jan 2012) | 2 lines
 Changed paths:
    M /trunk/NEWS
diff --git a/Fgw.c b/Fgw.c
index e96c063..18d4062 100644
--- a/Fgw.c
+++ b/Fgw.c
@@ -322,6 +322,19 @@ kbnc_str (double *k, unsigned long *b, unsigned long *n, signed long *c,
   return 0;
 }
 
+/* this method doesn't care if v is 32 or 64 bits... */
+unsigned long gw_log_2(unsigned long v)
+{
+  unsigned long r = 0; /* r will be lg(v) */
+
+  while (v >>= 1)
+    {
+      r++;
+    }
+
+  return r;
+}
+
 int 
 gw_ecm_stage1 (mpz_t f, curve *P, mpmod_t modulus, 
 	       double B1, double *B1done, mpz_t go, double gw_k,
@@ -350,8 +363,8 @@ gw_ecm_stage1 (mpz_t f, curve *P, mpmod_t modulus,
      plain integers */
 
   /* Allocate enough memory for any residue (mod k*b^n+c) for x, z */
-  mpz_init2 (gw_x, mpz_sizeinbase (modulus->orig_modulus, 2) + 64);
-  mpz_init2 (gw_z, mpz_sizeinbase (modulus->orig_modulus, 2) + 64);
+  mpz_init2 (gw_x, (gw_n+1)*gw_log_2(gw_b)+64);
+  mpz_init2 (gw_z, (gw_n+1)*gw_log_2(gw_b)+64);
   mpz_init (gw_A);
 
   /* mpres_get_z always produces non-negative integers */
diff --git a/INSTALL-ecm b/INSTALL-ecm
index 95422ce..9510cf6 100644
--- a/INSTALL-ecm
+++ b/INSTALL-ecm
@@ -6,7 +6,7 @@ Instructions to install GMP-ECM:
    Remark: GNU MP is already installed in most Linux distributions.
    However it is often an old version, moreover without processor-specific
    optimizations. If you care about efficiency, be sure to install the
-   latest version of GNU MP (5.0.2 as of May 2011), and to compile it
+   latest version of GNU MP (5.0.4 as of March 2012), and to compile it
    for your particular processor.
    Warning: make sure you have only one version of GMP installed on your
    system at a given time. Frequently, after compiling GMP from source
@@ -141,7 +141,7 @@ For Windows users:
 Windows users have two options for building GMP-ECM: (a) the use of a
 number of Unix on Windows environments, or (b) the use of Microsoft
 Visual Studio C/C++ 2008.  The former is described here while the latter
-is described in the readme.txt file within the build.vc9 subdirectory.
+is described in the readme.txt file within the build.vc10 subdirectory.
 
 (a) For Windows users with a Unix-like environment:
 
@@ -164,8 +164,8 @@ Step-by-step instructions, courtesy of Jes Hansen:
    Now you get an icon on the desktop where you can start the MinSys. Do
    this, because is creates your home folder. Then exit it again.
 
-4) Download the latest version of GMP (in May 2011 the latest
-   version is 5.0.2, this will be assumed for the rest of this document) 
+4) Download the latest version of GMP (in March 2012 the latest
+   version is 5.0.4, this will be assumed for the rest of this document) 
    in .tar.gz format from http://gmplib.org/ and place it in your 
    newly created home folder. The home folder is in C:\GNU\msys\home and 
    has the same name as your Windows login name.
@@ -174,15 +174,15 @@ Step-by-step instructions, courtesy of Jes Hansen:
    http://ecm.gforge.inria.fr/ and place it in your home folder as well.
 
 6) Start the MinSys up again from the desktop and type 
-   tar -xvzf gmp-5.0.2.tar.gz
-   cd gmp-5.0.2
+   tar -xvzf gmp-5.0.4.tar.gz
+   cd gmp-5.0.4
    ./configure
    make install
    cd ~
 
 7) You are back in your home directory. Now type
-   tar -xvzf ecm-6.4.tar.gz
-   cd ecm-6.4
+   tar -xvzf ecm-6.4.1.tar.gz
+   cd ecm-6.4.1
    ./configure --with-gmp=/usr/local
    make
 
@@ -197,7 +197,7 @@ In case of a problem, report it to us, with:
 
 - the versions of GMP-ECM and GMP used (first output line), for example:
   
-  GMP-ECM 6.4 [powered by GMP 5.0.2] [P+1]
+  GMP-ECM 6.4.1 [configured with GMP 5.0.4, --enable-asm-redc] [P+1]
 
 - the detailed input enabling us to reproduce the problem, for example:
 
diff --git a/Makefile.am b/Makefile.am
index 0fb91d9..9e16a9c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,12 +30,12 @@ libecm_la_SOURCES = ecm.c ecm2.c pm1.c pp1.c getprime.c listz.c lucas.c \
 		   schoen_strass.c ks-multiply.c rho.c bestd.c auxlib.c \
 		   random.c factor.c sp.c spv.c spm.c mpzspm.c mpzspv.c \
 		   ntt_gfp.c ecm_ntt.c pm1fs2.c mul_fft.c sets_long.c \
-		   auxarith.c batch.c
+		   auxarith.c batch.c ellparam_batch.c
 # Link the asm redc code (if we use it) into libecm.la
 libecm_la_CPPFLAGS = $(MULREDCINCPATH)
 libecm_la_CFLAGS = $(OPENMP_CFLAGS)
 libecm_la_LDFLAGS = '-version-info 0:0:0'
-libecm_la_LIBADD = $(MULREDCLIBRARY) $(GMPLIB)
+libecm_la_LIBADD = $(MULREDCLIBRARY)
 
 bin_PROGRAMS = ecm
 noinst_PROGRAMS = tune ecmfactor ecmfactor2
@@ -83,7 +83,8 @@ if WITH_GWNUM
 endif
 
 include_HEADERS = ecm.h
-noinst_HEADERS = ecm-impl.h ecm-gmp.h ecm-ecm.h sp.h longlong.h ecm-params.h
+noinst_HEADERS = ecm-impl.h ecm-gmp.h ecm-ecm.h sp.h longlong.h ecm-params.h \
+                 mpmod.h
 
 EXTRA_DIST = test.pm1 test.pp1 test.ecm README.lib INSTALL-ecm ecm.xml \
              ecm-params.h.alpha-ev5 ecm-params.h.athlon64 \
@@ -94,11 +95,11 @@ EXTRA_DIST = test.pm1 test.pp1 test.ecm README.lib INSTALL-ecm ecm.xml \
              ecm-params.h.mips64el ecm-params.h.armv5tel \
              ecm-params.h.sparc64 ecm-params.h.ia64 \
              ecm-params.h.hppa2.0 ecm-params.h.alpha-ev56 \
-             ecm-params.h.core2 \
+             ecm-params.h.core2 ecm-params.h.corei5 \
              mul_fft-params.h.athlon64 mul_fft-params.h.pentium3 \
              mul_fft-params.h.default mul_fft-params.h.pentium4
 
-DIST_SUBDIRS = athlon pentium4 x86_64 powerpc64 build.vc9
+DIST_SUBDIRS = athlon pentium4 x86_64 powerpc64 build.vc10
 
 DISTCLEANFILES = config.m4
 
diff --git a/Makefile.in b/Makefile.in
index 6c2db1c..466cb86 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -88,14 +88,13 @@ am__base_list = \
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(man1dir)" "$(DESTDIR)$(includedir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-am__DEPENDENCIES_1 =
-libecm_la_DEPENDENCIES = $(MULREDCLIBRARY) $(am__DEPENDENCIES_1)
+libecm_la_DEPENDENCIES = $(MULREDCLIBRARY)
 am__libecm_la_SOURCES_DIST = ecm.c ecm2.c pm1.c pp1.c getprime.c \
 	listz.c lucas.c stage2.c toomcook.c mpmod.c mul_lo.c \
 	polyeval.c median.c schoen_strass.c ks-multiply.c rho.c \
 	bestd.c auxlib.c random.c factor.c sp.c spv.c spm.c mpzspm.c \
 	mpzspv.c ntt_gfp.c ecm_ntt.c pm1fs2.c mul_fft.c sets_long.c \
-	auxarith.c batch.c memory.c Fgw.c
+	auxarith.c batch.c ellparam_batch.c memory.c Fgw.c
 @MEMORY_DEBUG_TRUE at am__objects_1 = libecm_la-memory.lo
 @WITH_GWNUM_TRUE at am__objects_2 = libecm_la-Fgw.lo
 am_libecm_la_OBJECTS = libecm_la-ecm.lo libecm_la-ecm2.lo \
@@ -110,7 +109,8 @@ am_libecm_la_OBJECTS = libecm_la-ecm.lo libecm_la-ecm2.lo \
 	libecm_la-mpzspv.lo libecm_la-ntt_gfp.lo libecm_la-ecm_ntt.lo \
 	libecm_la-pm1fs2.lo libecm_la-mul_fft.lo \
 	libecm_la-sets_long.lo libecm_la-auxarith.lo \
-	libecm_la-batch.lo $(am__objects_1) $(am__objects_2)
+	libecm_la-batch.lo libecm_la-ellparam_batch.lo \
+	$(am__objects_1) $(am__objects_2)
 libecm_la_OBJECTS = $(am_libecm_la_OBJECTS)
 libecm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libecm_la_CFLAGS) \
@@ -120,6 +120,7 @@ libecm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
 am_batch_OBJECTS = batch.$(OBJEXT)
 batch_OBJECTS = $(am_batch_OBJECTS)
+am__DEPENDENCIES_1 =
 batch_DEPENDENCIES = $(am__DEPENDENCIES_1)
 bench_mulredc_SOURCES = bench_mulredc.c
 bench_mulredc_OBJECTS = bench_mulredc-bench_mulredc.$(OBJEXT)
@@ -393,12 +394,12 @@ libecm_la_SOURCES = ecm.c ecm2.c pm1.c pp1.c getprime.c listz.c \
 	median.c schoen_strass.c ks-multiply.c rho.c bestd.c auxlib.c \
 	random.c factor.c sp.c spv.c spm.c mpzspm.c mpzspv.c ntt_gfp.c \
 	ecm_ntt.c pm1fs2.c mul_fft.c sets_long.c auxarith.c batch.c \
-	$(am__append_2) $(am__append_4)
+	ellparam_batch.c $(am__append_2) $(am__append_4)
 # Link the asm redc code (if we use it) into libecm.la
 libecm_la_CPPFLAGS = $(MULREDCINCPATH)
 libecm_la_CFLAGS = $(OPENMP_CFLAGS)
 libecm_la_LDFLAGS = '-version-info 0:0:0'
-libecm_la_LIBADD = $(MULREDCLIBRARY) $(GMPLIB)
+libecm_la_LIBADD = $(MULREDCLIBRARY)
 # Most binaries want to link libecm.la, and the ones which don't will
 # have their own _LDADD which overrides the default LDADD here
 LDADD = libecm.la $(GMPLIB)
@@ -423,7 +424,9 @@ batch_LDADD = $(GMPLIB)
 @WITH_GWNUM_TRUE at ecm_DEPENDENCIES = gwdata.ld
 @WITH_GWNUM_TRUE at ecm_LDFLAGS = $(AM_LDFLAGS) -Wl,gwdata.ld
 include_HEADERS = ecm.h
-noinst_HEADERS = ecm-impl.h ecm-gmp.h ecm-ecm.h sp.h longlong.h ecm-params.h
+noinst_HEADERS = ecm-impl.h ecm-gmp.h ecm-ecm.h sp.h longlong.h ecm-params.h \
+                 mpmod.h
+
 EXTRA_DIST = test.pm1 test.pp1 test.ecm README.lib INSTALL-ecm ecm.xml \
              ecm-params.h.alpha-ev5 ecm-params.h.athlon64 \
              ecm-params.h.default ecm-params.h.alpha-ev6 \
@@ -433,11 +436,11 @@ EXTRA_DIST = test.pm1 test.pp1 test.ecm README.lib INSTALL-ecm ecm.xml \
              ecm-params.h.mips64el ecm-params.h.armv5tel \
              ecm-params.h.sparc64 ecm-params.h.ia64 \
              ecm-params.h.hppa2.0 ecm-params.h.alpha-ev56 \
-             ecm-params.h.core2 \
+             ecm-params.h.core2 ecm-params.h.corei5 \
              mul_fft-params.h.athlon64 mul_fft-params.h.pentium3 \
              mul_fft-params.h.default mul_fft-params.h.pentium4
 
-DIST_SUBDIRS = athlon pentium4 x86_64 powerpc64 build.vc9
+DIST_SUBDIRS = athlon pentium4 x86_64 powerpc64 build.vc10
 DISTCLEANFILES = config.m4
 dist_man_MANS = ecm.1
 all: config.h
@@ -633,6 +636,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-ecm.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-ecm2.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-ecm_ntt.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-ellparam_batch.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-factor.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-getprime.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libecm_la-ks-multiply.Plo at am__quote@
@@ -928,6 +932,13 @@ libecm_la-batch.lo: batch.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libecm_la_CPPFLAGS) $(CPPFLAGS) $(libecm_la_CFLAGS) $(CFLAGS) -c -o libecm_la-batch.lo `test -f 'batch.c' || echo '$(srcdir)/'`batch.c
 
+libecm_la-ellparam_batch.lo: ellparam_batch.c
+ at am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libecm_la_CPPFLAGS) $(CPPFLAGS) $(libecm_la_CFLAGS) $(CFLAGS) -MT libecm_la-ellparam_batch.lo -MD -MP -MF $(DEPDIR)/libecm_la-ellparam_batch.Tpo -c -o libecm_la-ellparam_batch.lo `test -f 'ellparam_batch.c' || echo '$(srcdir)/'`ellparam_batch.c
+ at am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libecm_la-ellparam_batch.Tpo $(DEPDIR)/libecm_la-ellparam_batch.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='ellparam_batch.c' object='libecm_la-ellparam_batch.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libecm_la_CPPFLAGS) $(CPPFLAGS) $(libecm_la_CFLAGS) $(CFLAGS) -c -o libecm_la-ellparam_batch.lo `test -f 'ellparam_batch.c' || echo '$(srcdir)/'`ellparam_batch.c
+
 libecm_la-memory.lo: memory.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libecm_la_CPPFLAGS) $(CPPFLAGS) $(libecm_la_CFLAGS) $(CFLAGS) -MT libecm_la-memory.lo -MD -MP -MF $(DEPDIR)/libecm_la-memory.Tpo -c -o libecm_la-memory.lo `test -f 'memory.c' || echo '$(srcdir)/'`memory.c
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libecm_la-memory.Tpo $(DEPDIR)/libecm_la-memory.Plo
diff --git a/NEWS b/NEWS
index fbda149..6b24389 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,17 @@
+Changes between ecm-6.4 and ecm-6.5:
+* New configure option --enable-mulredc-svoboda, for input numbers whose low
+  limbs is congruent to -1
+* New tuning parameters for Intel Core i5
+* New ecmbench utility
+
+Changes between ecm-6.4 and ecm-6.4.1:
+* Fixed a speed regression with respect to ecm-6.3
+  http://lists.gforge.inria.fr/pipermail/ecm-discuss/2012-February/004103.html
+* Fixed a bug with the -treefile option which had been present for a long time
+* Several fixes for the Visual Studio 2010 build
+* New experimental option -batch=2, and speedup for -batch (i.e., -batch=1)
+* New tuning mechanism, now --enable-asm-redc is always recommended
+
 Changes between ecm-6.3 and ecm-6.4:
 * Fixed configure problem with SSE2
   (http://trac.sagemath.org/sage_trac/ticket/10252)
diff --git a/README b/README
index cede917..9aa0344 100644
--- a/README
+++ b/README
@@ -521,6 +521,25 @@ system is idle again.
 
 8. How to get the best of GMP-ECM?
 
+[this part has to be rewritten, beginning of new part]
+
+After configuring GMP-ECM, type "make bench_mulredc", and type:
+
+$ ./bench_mulredc
+
+This will output at the end two lines as follows:
+
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,1,1,3,1,1,3,1,1,1,1,2,1,2}
+
+Then put those lines in the ecm-params.h file (which is a symbolic link),
+or replace the corresponding values in that file if already present, and
+recompile GMP-ECM.
+
+[end of new part]
+
 Choice of modular multiplication. The ecm program may choose between 4 kinds
 of modular arithmetic:
 
diff --git a/TODO b/TODO
index 60ba39c..95b008c 100644
--- a/TODO
+++ b/TODO
@@ -9,6 +9,7 @@ Table of contents:
 6) others
 
 1) efficiency/memory
+- use a random sigma value of 64 bits by default
 - try the mpn/generic/{sb,dc,mu}_bdiv_qr.c functions in GMP >= 4.3.0 for REDC
 - the conversion from NTT primes to mpz_t in function mpzspv_to_mpzv()
   (file mpzspv.c) is quadratic. A faster conversion is possible with a
diff --git a/auxi.c b/auxi.c
index 48a9dc4..1908b7a 100644
--- a/auxi.c
+++ b/auxi.c
@@ -52,3 +52,88 @@ nb_digits (const mpz_t n)
   return size;
 }
 
+/* Tries to read a number from a line from fd and stores it in r.
+   Keeps reading lines until a number is found. Lines beginning with "#"
+     are skipped.
+   Returns 1 if a number was successfully read, 0 if no number can be read
+     (i.e. at EOF)
+   Function is now simpler.  Much of the logic (other than skipping # lines
+     is now contained within eval() function.
+*/
+
+int
+read_number (mpcandi_t *n, FILE *fd, int primetest)
+{
+  int c;
+
+new_line:
+  c = fgetc (fd);
+
+  /* Skip comment lines beginning with '#' */
+  if (c == '#')
+    {
+      do
+        c = fgetc (fd);
+      while (c != EOF && !IS_NEWLINE(c));
+      if (IS_NEWLINE(c))
+        goto new_line;
+    }
+
+  if (c == EOF)
+    return 0;
+
+  ungetc (c, fd);
+  if (!eval (n, fd, primetest))
+    goto new_line;
+
+#if 0
+  /*  Code to test out eval_str function, which "appears" to work correctly. */
+  {
+    /* warning!! Line is pretty small, but since this is just testing code, we
+       can easily control the input for this test.  This code should NEVER be
+       compiled into released build, its only for testing of eval_str() */
+    char Line[500], *cp;
+    fgets (Line, sizeof(Line), fd);
+
+    if (!eval_str (n, Line, primetest, &cp))
+      goto new_line;
+    fprintf (stderr, "\nLine is at %X cp is at %X\n", Line, cp);
+  }
+#endif
+
+#if defined (DEBUG_EVALUATOR)
+  if (n->cpExpr)
+    fprintf (stderr, "%s\n", n->cpExpr);
+  mpz_out_str (stderr, 10, n->n);
+  fprintf (stderr, "\n");
+#endif
+
+  return 1;
+}
+
+int
+probab_prime_p (mpz_t N, int reps)
+{
+#ifdef WANT_SHELLCMD
+  if (prpcmd != NULL)
+    {
+      FILE *fc;
+      int r;
+      fc = popen (prpcmd, "w");
+      if (fc != NULL)
+        {
+          gmp_fprintf (fc, "%Zd\n", N);
+          r = pclose (fc);
+          if (r == 0) /* Exit status of 0 means success = is a PRP */
+            return 1;
+          else
+            return 0;
+        } else {
+          fprintf (stderr, "Error executing the PRP command\n");
+          exit (EXIT_FAILURE);
+        }
+    } else
+#endif
+      return mpz_probab_prime_p (N, reps);
+}
+
diff --git a/batch.c b/batch.c
index 862b64f..6dfcf10 100644
--- a/batch.c
+++ b/batch.c
@@ -1,5 +1,5 @@
 /* ECM stage 1 in batch mode, for initial point (x:z) with small coordinates,
-   such that x and z fit into an unsigned long.
+   such that x and z fit into a mp_limb_t.
    For example we can start with (x=2:y=1) with the curve by^2 = x^3 + ax^2 + x
    with a = 4d-2 and b=16d+2, then we have to multiply by d=(a+2)/4 in the
    duplicates.
@@ -7,45 +7,12 @@
    Y^2 = X^3 + a/b*X^2 + 1/b^2*X.
 */
 
-#include "ecm-gmp.h"
+#ifdef GPUECM
+#include <stdlib.h>
+#include "ecm-ecm.h"
+#else
 #include "ecm-impl.h"
-
-/* (x1:z1) <- 2(x1:z1)
-   (x2:z2) <- (x1:z1) + (x2:z2)
-   assume (x2:z2) - (x1:z1) = (2:1)
-   Uses 4 modular multiplies and 4 modular squarings.
-*/
-static void
-dup_add (mpres_t x1, mpres_t z1, mpres_t x2, mpres_t z2,
-         mpres_t q, mpres_t t, mpres_t u, mpres_t v, mpres_t w,
-         unsigned long d, mpmod_t n)
-{
-  mpres_add (w, x1, z1, n); /* w = x1+z1 */
-  mpres_sub (u, x1, z1, n); /* u = x1-z1 */
-  mpres_add (t, x2, z2, n); /* t = x2+z2 */
-  mpres_sub (v, x2, z2, n); /* v = x2-z2 */
-
-  mpres_mul (t, t, u, n); /* t = (x1-z1)(x2+z2) */
-  mpres_mul (v, v, w, n); /* v = (x2-z2)(x1+z1) */
-  mpres_sqr (w, w, n);    /* w = (x1+z1)^2 */
-  mpres_sqr (u, u, n);    /* u = (x1-z1)^2 */
-
-  mpres_mul (x1, u, w, n); /* xdup = (x1+z1)^2 * (x1-z1)^2 */
-
-  mpres_sub (w, w, u, n);   /* w = (x1+z1)^2 - (x1-z1)^2 */
-
-  mpres_mul_ui (q, w, d, n); /* q = d * ((x1+z1)^2 - (x1-z1)^2) */
-
-  mpres_add (u, u, q, n);  /* u = (x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2) */
-  mpres_mul (z1, w, u, n); /* zdup = w * [(x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2)] */
-
-  mpres_add (w, v, t, n);
-  mpres_sub (v, v, t, n);
-
-  mpres_sqr (v, v, n);
-  mpres_sqr (x2, w, n);
-  mpres_add (z2, v, v, n);
-}
+#endif
 
 
 #define MAX_HEIGHT 32
@@ -105,12 +72,159 @@ compute_s (mpz_t s, unsigned long B1)
 
   for (mpz_set (s, acc[0]), j = 1; mpz_cmp_ui (acc[j], 0) != 0; j++)
     mpz_mul (s, s, acc[j]);
-	
   getprime_clear (); /* free the prime tables, and reinitialize */
   
   for (i = 0; i < MAX_HEIGHT; i++)
       mpz_clear (acc[i]);
 }
+/* Return the number of bytes written */
+int
+write_s_in_file (char *fn, mpz_t s)
+{
+  FILE *file;
+  int ret = 0;
+
+#ifdef DEBUG
+  if (fn == NULL)
+    {
+      fprintf (stderr, "write_s_in_file: fn == NULL\n");
+      exit (EXIT_FAILURE);
+    }
+#endif
+  
+  file = fopen (fn, "w");
+  if (file == NULL)
+    {
+      fprintf (stderr, "Could not open file %s for writing\n", fn);
+      return 0;
+    }
+  
+  ret = mpz_out_raw (file, s);
+  
+  fclose (file);
+  return ret;
+}
+
+void
+read_s_from_file (mpz_t s, char *fn) 
+{
+  FILE *file;
+  int ret = 0;
+
+#ifdef DEBUG
+  if (fn == NULL)
+    {
+      fprintf (stderr, "read_s_from_file: fn == NULL\n");
+      exit (EXIT_FAILURE);
+    }
+#endif
+  
+  file = fopen (fn, "r");
+  if (file == NULL)
+    {
+      fprintf (stderr, "Could not open file %s for reading\n", fn);
+      exit (EXIT_FAILURE);
+    }
+ 
+  ret = mpz_inp_raw (s, file);
+  if (ret == 0)
+    {
+      fprintf (stderr, "read_s_from_file: 0 bytes read from %s\n", fn);
+      exit (EXIT_FAILURE);
+    }
+
+  fclose (file);
+}
+
+#ifndef GPUECM
+
+#if 0
+/* this function is useful in debug mode to print non-normalized residues */
+static void
+mpresn_print (mpres_t x, mpmod_t n)
+{
+  mp_size_t m, xn;
+
+  xn = SIZ(x);
+  m = ABSIZ(x);
+  MPN_NORMALIZE(PTR(x), m);
+  SIZ(x) = xn >= 0 ? m : -m;
+  gmp_printf ("%Zd\n", x);
+  SIZ(x) = xn;
+}
+#endif
+
+/* (x1:z1) <- 2(x1:z1)
+   (x2:z2) <- (x1:z1) + (x2:z2)
+   assume (x2:z2) - (x1:z1) = (2:1)
+   Uses 4 modular multiplies and 4 modular squarings.
+   Inputs are x1, z1, x2, z2, d, n.
+   Auxiliary variables: q, t, u, v, w.
+
+   In the batch 1 mode, we pass d_prime such that the actual d is d_prime/beta.
+   Since beta is a square, if d_prime is a square (on 64-bit machines),
+   so is d.
+   In mpresn_mul_1, we multiply by d_prime = beta*d and divide by beta.
+*/
+static void
+dup_add_batch1 (mpres_t x1, mpres_t z1, mpres_t x2, mpres_t z2,
+         mpres_t q, mpres_t t, mpres_t u, mpres_t v, mpres_t w,
+         mp_limb_t d_prime, mpmod_t n)
+{
+  mpresn_addsub (w, u, x1, z1, n); /* w = x1+/-z1 */
+  mpresn_addsub (t, v, x2, z2, n); /* t = x2+/-z2 */
+
+  mpresn_mul (t, t, u, n); /* t = (x1-z1)(x2+z2) */
+  mpresn_mul (v, v, w, n); /* v = (x2-z2)(x1+z1) */
+  mpresn_sqr (w, w, n);    /* w = (x1+z1)^2 */
+  mpresn_sqr (u, u, n);    /* u = (x1-z1)^2 */
+
+  mpresn_mul (x1, u, w, n); /* xdup = (x1+z1)^2 * (x1-z1)^2 */
+
+  mpresn_sub (w, w, u, n);   /* w = (x1+z1)^2 - (x1-z1)^2 */
+
+  mpresn_mul_1 (q, w, d_prime, n); /* q = d * ((x1+z1)^2 - (x1-z1)^2) */
+
+  mpresn_add (u, u, q, n);  /* u = (x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2) */
+  mpresn_mul (z1, w, u, n); /* zdup = w * [(x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2)] */
+
+  mpresn_add (w, v, t, n);
+  mpresn_sub (v, v, t, n);
+
+  mpresn_sqr (v, v, n);
+  mpresn_sqr (x2, w, n);
+  mpresn_add (z2, v, v, n);
+}
+
+static void
+dup_add_batch2 (mpres_t x1, mpres_t z1, mpres_t x2, mpres_t z2,
+         mpres_t q, mpres_t t, mpres_t u, mpres_t v, mpres_t w,
+         mpres_t d, mpmod_t n)
+{
+  mpresn_addsub (w, u, x1, z1, n); /* w = x1+/-z1 */
+  mpresn_addsub (t, v, x2, z2, n); /* t = x2+/-z2 */
+
+  mpresn_mul (t, t, u, n); /* t = (x1-z1)(x2+z2) */
+  mpresn_mul (v, v, w, n); /* v = (x2-z2)(x1+z1) */
+  mpresn_sqr (w, w, n);    /* w = (x1+z1)^2 */
+  mpresn_sqr (u, u, n);    /* u = (x1-z1)^2 */
+
+  mpresn_mul (x1, u, w, n); /* xdup = (x1+z1)^2 * (x1-z1)^2 */
+
+  mpresn_sub (w, w, u, n);   /* w = (x1+z1)^2 - (x1-z1)^2 */
+
+  mpresn_mul (q, w, d, n); /* q = d * ((x1+z1)^2 - (x1-z1)^2) */
+
+  mpresn_add (u, u, q, n);  /* u = (x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2) */
+  mpresn_mul (z1, w, u, n); /* zdup = w * [(x1-z1)^2 - d* ((x1+z1)^2 - (x1-z1)^2)] */
+
+  mpresn_add (w, v, t, n);
+  mpresn_sub (v, v, t, n);
+
+  mpresn_sqr (v, v, n);
+  mpresn_sqr (x2, w, n);
+  mpresn_add (z2, v, v, n);
+}
 
 
 /* Input: x is initial point
@@ -132,22 +246,24 @@ For now we don't take into account go stop_asap and chkfilename
 */
 int
 ecm_stage1_batch (mpz_t f, mpres_t x, mpres_t A, mpmod_t n, double B1,
-                  double *B1done, mpz_t s)
+                  double *B1done, int batch, mpz_t s)
 {
-  unsigned long d;
-  mpz_t x1, z1, x2, z2;
+  mp_limb_t d_1;
+  mpz_t d_2;
+
+  mpres_t x1, z1, x2, z2;
   unsigned long i;
-  mpz_t q, t, u, v, w;
+  mpres_t q, t, u, v, w;
   int ret = ECM_NO_FACTOR_FOUND;
 
   MEMORY_TAG;
-  mpz_init (x1);
+  mpres_init (x1, n);
   MEMORY_TAG;
-  mpz_init (z1);
+  mpres_init (z1, n);
   MEMORY_TAG;
-  mpz_init (x2);
+  mpres_init (x2, n);
   MEMORY_TAG;
-  mpz_init (z2);
+  mpres_init (z2, n);
   MEMORY_TAG;
   mpres_init (q, n);
   MEMORY_TAG;
@@ -158,51 +274,96 @@ ecm_stage1_batch (mpz_t f, mpres_t x, mpres_t A, mpmod_t n, double B1,
   mpres_init (v, n);
   MEMORY_TAG;
   mpres_init (w, n);
+  MEMORY_TAG;
+  mpres_init (d_2, n);
   MEMORY_UNTAG;
 
   /* initialize P */
   mpres_set (x1, x, n);
   mpres_set_ui (z1, 1, n); /* P1 <- 1P */
 
-  /* Compute d=(A+2)/4 from A */
-  mpz_add_ui (u, A, 2);
-  if (mpz_fdiv_ui (u, 4) != 0)
-    {
-      outputf (OUTPUT_ERROR, "Error, A+2 should be divisible by 4\n");
-      return ECM_ERROR;
+  /* Compute d=(A+2)/4 from A and d'=B*d thus d' = 2^(GMP_NUMB_BITS-2)*(A+2) */
+  if (batch == 1)
+  {
+      mpres_get_z (u, A, n);
+      mpz_add_ui (u, u, 2);
+      mpz_mul_2exp (u, u, GMP_NUMB_BITS - 2);
+      mpres_set_z_for_gcd (u, u, n); /* reduces u mod n */
+      if (mpz_size (u) > 1)
+        {
+          mpres_get_z (u, A, n);
+          outputf (OUTPUT_ERROR,
+               "Error, d'=B*(A+2)/4 should fit in a mp_limb_t, A=%Zd\n", u);
+          return ECM_ERROR;
+        }
+      d_1 = mpz_getlimbn (u, 0);
     }
-  mpz_div_2exp (u, u, 2);
-  mpres_set_z_for_gcd (u, u, n);
-  if (mpz_fits_ulong_p (u) == 0)
+  else
     {
-      outputf (OUTPUT_ERROR,
-               "Error, d=(A+2)/4 should fit in an ulong, A=%Zd\n", A);
-      return ECM_ERROR;
+      /* b = (A0+2)*B/4, where B=2^(k*GMP_NUMB_BITS)
+         for MODMULN or REDC, B=2^GMP_NUMB_BITS for batch1,
+         and B=1 otherwise */
+      mpres_add_ui (d_2, A, 2, n);
+      mpres_div_2exp (d_2, d_2, 2, n); 
     }
-  d = mpz_get_ui (u);
 
   /* Compute 2P : no need to duplicate P, the coordinates are simple. */
   mpres_set_ui (x2, 9, n);
-  mpres_set_ui (z2, d, n);
+  if (batch == 1) /* here d = d_1 / GMP_NUMB_BITS */
+    {
+      /* warning: mpres_set_ui takes an unsigned long which has only 32 bits
+         on Windows, while d_1 might have 64 bits */
+      ASSERT_ALWAYS (mpz_size (u) == 1 && mpz_getlimbn (u, 0) == d_1);
+      mpres_set_z (z2, u, n);
+      mpres_div_2exp (z2, z2, GMP_NUMB_BITS, n);
+    }
+  else
+      mpres_set (z2, d_2, n);
+ 
   mpres_mul_2exp (z2, z2, 6, n);
   mpres_add_ui (z2, z2, 8, n); /* P2 <- 2P = (9 : : 64d+8) */
 
   /* invariant: if j represents the upper bits of s,
      then P1 = j*P and P2=(j+1)*P */
 
+  mpresn_pad (x1, n);
+  mpresn_pad (z1, n);
+  mpresn_pad (x2, n);
+  mpresn_pad (z2, n);
+  if (batch == 2)
+    mpresn_pad (d_2, n);
+
   /* now perform the double-and-add ladder */
-  for (i = mpz_sizeinbase (s, 2) - 1; i-- > 0;)
+  if (batch == 1)
+    {
+      for (i = mpz_sizeinbase (s, 2) - 1; i-- > 0;)
+        {
+          if (mpz_tstbit (s, i) == 0) /* (j,j+1) -> (2j,2j+1) */
+            /* P2 <- P1+P2    P1 <- 2*P1 */
+            dup_add_batch1 (x1, z1, x2, z2, q, t, u, v , w, d_1, n);
+          else /* (j,j+1) -> (2j+1,2j+2) */
+              /* P1 <- P1+P2     P2 <- 2*P2 */
+            dup_add_batch1 (x2, z2, x1, z1, q, t, u, v, w, d_1, n);
+        }
+    }
+  else
     {
-      if (mpz_tstbit (s, i) == 0) /* (j,j+1) -> (2j,2j+1) */
-        /* P2 <- P1+P2    P1 <- 2*P1 */
-        dup_add (x1, z1, x2, z2, q, t, u, v , w, d, n);
-      else /* (j,j+1) -> (2j+1,2j+2) */
-          /* P1 <- P1+P2     P2 <- 2*P2 */
-        dup_add (x2, z2, x1, z1, q, t, u, v, w, d, n);
+      for (i = mpz_sizeinbase (s, 2) - 1; i-- > 0;)
+        {
+          if (mpz_tstbit (s, i) == 0) /* (j,j+1) -> (2j,2j+1) */
+            /* P2 <- P1+P2    P1 <- 2*P1 */
+            dup_add_batch2 (x1, z1, x2, z2, q, t, u, v , w, d_2, n);
+          else /* (j,j+1) -> (2j+1,2j+2) */
+              /* P1 <- P1+P2     P2 <- 2*P2 */
+            dup_add_batch2 (x2, z2, x1, z1, q, t, u, v, w, d_2, n);
+        }
     }
 
   *B1done=B1;
 
+  mpresn_unpad (x1);
+  mpresn_unpad (z1);
+
   if (!mpres_invert (u, z1, n)) /* Factor found? */
     {
       mpres_gcd (f, z1, n);
@@ -219,6 +380,9 @@ ecm_stage1_batch (mpz_t f, mpres_t x, mpres_t A, mpmod_t n, double B1,
   mpz_clear (u);
   mpz_clear (v);
   mpz_clear (w);
+  mpz_clear (d_2);
 
   return ret;
 }
+
+#endif
diff --git a/bench_mulredc.c b/bench_mulredc.c
index 7d4d198..51383a6 100644
--- a/bench_mulredc.c
+++ b/bench_mulredc.c
@@ -3,12 +3,16 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <time.h>
+#include <string.h>
+#ifndef _MSC_VER
 # include <sys/time.h>
 # include <sys/times.h>
 # include <sys/param.h>
 # include <sys/resource.h>
-# include <string.h>
 # include <unistd.h>
+#else
+#include "getrusage.h"
+#endif
 # ifndef HZ
 #  ifdef CLK_TCK
 #   define HZ CLK_TCK
@@ -18,9 +22,31 @@
 # endif
 
 #define LOOPCOUNT 10000000UL
+#define MAXSIZE 20
+
+int tune_mul[MAXSIZE+1], tune_sqr[MAXSIZE+1];
 
 #include <gmp.h>
 #include "mulredc.h"
+#include "mpmod.h"
+
+#ifdef HAVE___GMPN_REDC_1
+#ifndef __gmpn_redc_1
+void __gmpn_redc_1 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);
+#endif
+#endif
+
+#ifdef HAVE___GMPN_REDC_2
+#ifndef __gmpn_redc_2
+void __gmpn_redc_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
+#endif
+#endif
+
+#ifdef HAVE___GMPN_REDC_N
+#ifndef __gmpn_redc_N
+void __gmpn_redc_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
+#endif
+#endif
 
 double CPUTime()
 {
@@ -54,172 +80,353 @@ void mp_print(mp_limb_t *x, int N) {
   printf("\n");
 }
 
+static void
+ecm_redc_1_svoboda (mp_ptr rp, mp_ptr tmp, mp_srcptr np, mp_size_t nn,
+                    mp_limb_t invm, mp_srcptr sp)
+{
+  mp_size_t j;
+  mp_limb_t t0, cy;
+
+  /* instead of adding {np, nn} * (invm * tmp[0] mod B), we add
+     {sp, nn} * tmp[0], where {np, nn} * invm = B * {sp, nn} - 1 */
+  for (j = 0; j < nn - 1; j++, tmp++)
+    rp[j + 1] = mpn_addmul_1 (tmp + 1, sp, nn, tmp[0]);
+  /* for the last step, we reduce with {np, nn} */
+  t0 = mpn_addmul_1 (tmp, np, nn, tmp[0] * invm);
+  tmp ++;
+
+  rp[0] = tmp[0];
+  cy = mpn_add_n (rp + 1, rp + 1, tmp + 1, nn - 1);
+  rp[nn-1] += t0;
+  cy += rp[nn-1] < t0;
+  if (cy != 0)
+    mpn_sub_n (rp, rp, np, nn); /* a borrow should always occur here */
+}
+
 void bench(mp_size_t N)
 {
-  mp_limb_t *x, *y, *z, *m, invm, cy, cy2, *tmp;
+  mp_limb_t *x, *y, *z, *m, *invm, cy, *tmp, *svoboda1;
   unsigned long i;
   const unsigned long iter = LOOPCOUNT/N;
-  double t1, t2, t3 = 0.;
+  double t2, t3 = 0., tmul, tsqr, tredc_1, t_mulredc_1;
+  double t_sqrredc_1, tmul_best, tsqr_best, tsvoboda1;
+  mpz_t M, B;
+#ifdef HAVE___GMPN_REDC_2
+  double tredc_2, t_mulredc_2, t_sqrredc_2;
+#endif
+#ifdef HAVE___GMPN_REDC_N
+  double tredc_n, t_mulredc_n, t_sqrredc_n;
+#endif
   
   x = (mp_limb_t *) malloc(N*sizeof(mp_limb_t));
   y = (mp_limb_t *) malloc(N*sizeof(mp_limb_t));
-  z = (mp_limb_t *) malloc((N+1)*sizeof(mp_limb_t));
+  z = (mp_limb_t *) malloc((2*N)*sizeof(mp_limb_t));
   m = (mp_limb_t *) malloc(N*sizeof(mp_limb_t));
   tmp = (mp_limb_t *) malloc((2*N+2)*sizeof(mp_limb_t));
+  invm = (mp_limb_t *) malloc(N*sizeof(mp_limb_t));
+  svoboda1 = (mp_limb_t *) malloc(N*sizeof(mp_limb_t));
  
   mpn_random(m, N);
   m[0] |= 1UL;
   if (m[N-1] == 0) 
     m[N-1] = 1UL;
 
-  invm = m[0];
-  for (i = 0; i < 5UL; ++i)
-    invm = (2*invm-m[0]*invm*invm);
-  invm = -invm;
+  mpz_init (M);
+  mpz_init (B);
+  mpz_set_ui (M, m[1]);
+  mpz_mul_2exp (M, M, GMP_NUMB_BITS);
+  mpz_add_ui (M, M, m[0]);
+  mpz_set_ui (B, 1);
+  mpz_mul_2exp (B, B, 2 * GMP_NUMB_BITS);
+  mpz_invert (M, M, B);
+  mpz_sub (M, B, M);
+
+  for (i = 0; i < (unsigned) N; i++)
+    invm[i] = mpz_getlimbn(M, i);
+
+  tmp[N] = mpn_mul_1 (tmp, m, N, invm[0]); /* {tmp,N+1} should be = -1 mod B */
+  mpn_add_1 (tmp, tmp, N + 1, 1); /* now = 0 mod B */
+  mpn_copyi (svoboda1, tmp + 1, N);
+
+  mpz_clear (M);
+  mpz_clear (B);
 
   mpn_random(x, N);
   mpn_random(y, N);
 
-  /* Mul followed by ecm_redc3 */
-  t1 = CPUTime();
-  for (i = 0; i < iter; ++i) {
+  tmul = CPUTime();
+  for (i = 0; i < iter; ++i)
     mpn_mul_n(tmp, x, y, N);
-    ecm_redc3(tmp, m, N, invm);
-    cy2 = mpn_add_n (tmp, tmp + N, tmp, N);
-    x[0] += tmp[0];
-  }
-  t1 = CPUTime()-t1;
-  
+  tmul = CPUTime()-tmul;
+
+  tsqr = CPUTime();
+  for (i = 0; i < iter; ++i)
+    mpn_sqr (tmp, x, N);
+  tsqr = CPUTime()-tsqr;
+
+#ifdef HAVE___GMPN_REDC_1
+  mpn_mul_n(tmp, x, y, N);
+  tredc_1 = CPUTime();
+  for (i = 0; i < iter; ++i)
+    __gmpn_redc_1 (z, tmp, m, N, invm[0]);
+  tredc_1 = CPUTime()-tredc_1;
+#endif
+
+  if (N > 1) /* Svoboda only works for N > 1 */
+    {
+      mpn_mul_n(tmp, x, y, N);
+      tsvoboda1 = CPUTime();
+      for (i = 0; i < iter; ++i)
+        ecm_redc_1_svoboda (z, tmp, m, N, invm[0], svoboda1);
+      tsvoboda1 = CPUTime()-tsvoboda1;
+    }
+
+#ifdef HAVE___GMPN_REDC_2
+  mpn_mul_n(tmp, x, y, N);
+  tredc_2 = CPUTime();
+  for (i = 0; i < iter; ++i)
+    __gmpn_redc_2 (z, tmp, m, N, invm);
+  tredc_2 = CPUTime()-tredc_2;
+#endif
+
+#ifdef HAVE___GMPN_REDC_N
+  mpn_mul_n(tmp, x, y, N);
+  tredc_n = CPUTime();
+  for (i = 0; i < iter; ++i)
+    __gmpn_redc_n (z, tmp, m, N, invm);
+  tredc_n = CPUTime()-tredc_n;
+#endif
+
   /* Mixed mul and redc */
   t2 = CPUTime();
   switch (N) {
    case 1:
     for (i=0; i < iter; ++i) {
-      cy += mulredc1(z, x[0], y[0], m[0], invm);
+      cy += mulredc1(z, x[0], y[0], m[0], invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 2:
     for (i=0; i < iter; ++i) {
-      cy += mulredc2(z, x, y, m, invm);
+      cy += mulredc2(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 3:
     for (i=0; i < iter; ++i) {
-      cy += mulredc3(z, x, y, m, invm);
+      cy += mulredc3(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 4:
     for (i=0; i < iter; ++i) {
-      cy += mulredc4(z, x, y, m, invm);
+      cy += mulredc4(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 5:
     for (i=0; i < iter; ++i) {
-      cy += mulredc5(z, x, y, m, invm);
+      cy += mulredc5(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 6:
     for (i=0; i < iter; ++i) {
-      cy += mulredc6(z, x, y, m, invm);
+      cy += mulredc6(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 7:
     for (i=0; i < iter; ++i) {
-      cy += mulredc7(z, x, y, m, invm);
+      cy += mulredc7(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 8:
     for (i=0; i < iter; ++i) {
-      cy += mulredc8(z, x, y, m, invm);
+      cy += mulredc8(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 9:
     for (i=0; i < iter; ++i) {
-      cy += mulredc9(z, x, y, m, invm);
+      cy += mulredc9(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 10:
     for (i=0; i < iter; ++i) {
-      cy += mulredc10(z, x, y, m, invm);
+      cy += mulredc10(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 11:
     for (i=0; i < iter; ++i) {
-      cy += mulredc11(z, x, y, m, invm);
+      cy += mulredc11(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 12:
     for (i=0; i < iter; ++i) {
-      cy += mulredc12(z, x, y, m, invm);
+      cy += mulredc12(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 13:
     for (i=0; i < iter; ++i) {
-      cy += mulredc13(z, x, y, m, invm);
+      cy += mulredc13(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 14:
     for (i=0; i < iter; ++i) {
-      cy += mulredc14(z, x, y, m, invm);
+      cy += mulredc14(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 15:
     for (i=0; i < iter; ++i) {
-      cy += mulredc15(z, x, y, m, invm);
+      cy += mulredc15(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 16:
     for (i=0; i < iter; ++i) {
-      cy += mulredc16(z, x, y, m, invm);
+      cy += mulredc16(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 17:
     for (i=0; i < iter; ++i) {
-      cy += mulredc17(z, x, y, m, invm);
+      cy += mulredc17(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 18:
     for (i=0; i < iter; ++i) {
-      cy += mulredc18(z, x, y, m, invm);
+      cy += mulredc18(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 19:
     for (i=0; i < iter; ++i) {
-      cy += mulredc19(z, x, y, m, invm);
+      cy += mulredc19(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 20:
     for (i=0; i < iter; ++i) {
-      cy += mulredc20(z, x, y, m, invm);
+      cy += mulredc20(z, x, y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    default:
     for (i=0; i < iter; ++i) {
-      cy += mulredc20(z, x, y, m,  invm);
+      cy += mulredc20(z, x, y, m,  invm[0]);
       x[0] += tmp[0];
     }
   }
   t2 = CPUTime()-t2;
+  tmul_best = t2;
+  tune_mul[N] = MPMOD_MULREDC;
+  tsqr_best = t2;
+  tune_sqr[N] = MPMOD_MULREDC;
+  
+  /* Mul followed by mpn_redc_1 */
+#ifdef HAVE___GMPN_REDC_1
+  t_mulredc_1 = CPUTime();
+  for (i = 0; i < iter; ++i) {
+    mpn_mul_n(tmp, x, y, N);
+    __gmpn_redc_1 (z, tmp, m, N, invm[0]);
+    x[0] += tmp[0];
+  }
+  t_mulredc_1 = CPUTime()-t_mulredc_1;
+  if (t_mulredc_1 < tmul_best)
+    {
+      tune_mul[N] = MPMOD_MUL_REDC1;
+      tmul_best = t_mulredc_1;
+    }
+#endif
+  
+  /* Mul followed by mpn_redc_2 */
+#ifdef HAVE___GMPN_REDC_2
+  t_mulredc_2 = CPUTime();
+  for (i = 0; i < iter; ++i) {
+    mpn_mul_n(tmp, x, y, N);
+    __gmpn_redc_2 (z, tmp, m, N, invm);
+    x[0] += tmp[0];
+  }
+  t_mulredc_2 = CPUTime()-t_mulredc_2;
+  if (t_mulredc_2 < tmul_best)
+    {
+      tune_mul[N] = MPMOD_MUL_REDC2;
+      tmul_best = t_mulredc_2;
+    }
+#endif
+  
+  /* Mul followed by mpn_redc_n */
+#ifdef HAVE___GMPN_REDC_N
+  t_mulredc_n = CPUTime();
+  for (i = 0; i < iter; ++i)
+    {
+      mpn_mul_n (tmp, x, y, N);
+      __gmpn_redc_n (z, tmp, m, N, invm);
+    }
+  t_mulredc_n = CPUTime()-t_mulredc_n;
+  if (t_mulredc_n < tmul_best)
+    {
+      tune_mul[N] = MPMOD_MUL_REDCN;
+      tmul_best = t_mulredc_n;
+    }
+#endif
+  
+  /* Sqr followed by mpn_redc_1 */
+#if defined(HAVE___GMPN_REDC_1)
+  t_sqrredc_1 = CPUTime();
+  for (i = 0; i < iter; ++i) {
+    mpn_sqr(tmp, x, N);
+    __gmpn_redc_1 (z, tmp, m, N, invm[0]);
+    x[0] += tmp[0];
+  }
+  t_sqrredc_1 = CPUTime()-t_sqrredc_1;
+  if (t_sqrredc_1 < tsqr_best)
+    {
+      tune_sqr[N] = MPMOD_MUL_REDC1;
+      tsqr_best = t_sqrredc_1;
+    }
+#endif
+  
+  /* Sqr followed by mpn_redc_2 */
+#if defined(HAVE___GMPN_REDC_2)
+  t_sqrredc_2 = CPUTime();
+  for (i = 0; i < iter; ++i) {
+    mpn_sqr(tmp, x, N);
+    __gmpn_redc_2 (z, tmp, m, N, invm);
+    x[0] += tmp[0];
+  }
+  t_sqrredc_2 = CPUTime()-t_sqrredc_2;
+  if (t_sqrredc_2 < tsqr_best)
+    {
+      tune_sqr[N] = MPMOD_MUL_REDC2;
+      tsqr_best = t_sqrredc_2;
+    }
+#endif
+  
+  /* Sqr followed by mpn_redc_n */
+#if defined(HAVE___GMPN_REDC_N)
+  t_sqrredc_n = CPUTime();
+  for (i = 0; i < iter; ++i)
+    {
+      mpn_sqr (tmp, x, N);
+      __gmpn_redc_n (z, tmp, m, N, invm);
+    }
+  t_sqrredc_n = CPUTime()-t_sqrredc_n;
+  if (t_sqrredc_n < tsqr_best)
+    {
+      tune_sqr[N] = MPMOD_MUL_REDCN;
+      tsqr_best = t_sqrredc_n;
+    }
+#endif
   
 #if defined(HAVE_NATIVE_MULREDC1_N)
   /* mulredc1 */
@@ -227,188 +434,214 @@ void bench(mp_size_t N)
   switch (N) {
    case 1:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1(z, x[0], y[0], m[0], invm);
+      cy += mulredc1(z, x[0], y[0], m[0], invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 2:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_2(z, x[0], y, m, invm);
+      cy += mulredc1_2(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 3:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_3(z, x[0], y, m, invm);
+      cy += mulredc1_3(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 4:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_4(z, x[0], y, m, invm);
+      cy += mulredc1_4(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 5:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_5(z, x[0], y, m, invm);
+      cy += mulredc1_5(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 6:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_6(z, x[0], y, m, invm);
+      cy += mulredc1_6(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 7:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_7(z, x[0], y, m, invm);
+      cy += mulredc1_7(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 8:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_8(z, x[0], y, m, invm);
+      cy += mulredc1_8(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 9:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_9(z, x[0], y, m, invm);
+      cy += mulredc1_9(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 10:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_10(z, x[0], y, m, invm);
+      cy += mulredc1_10(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 11:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_11(z, x[0], y, m, invm);
+      cy += mulredc1_11(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 12:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_12(z, x[0], y, m, invm);
+      cy += mulredc1_12(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 13:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_13(z, x[0], y, m, invm);
+      cy += mulredc1_13(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 14:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_14(z, x[0], y, m, invm);
+      cy += mulredc1_14(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 15:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_15(z, x[0], y, m, invm);
+      cy += mulredc1_15(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 16:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_16(z, x[0], y, m, invm);
+      cy += mulredc1_16(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 17:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_17(z, x[0], y, m, invm);
+      cy += mulredc1_17(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 18:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_18(z, x[0], y, m, invm);
+      cy += mulredc1_18(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 19:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_19(z, x[0], y, m, invm);
+      cy += mulredc1_19(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    case 20:
     for (i=0; i<LOOPCOUNT; ++i) {
-      cy += mulredc1_20(z, x[0], y, m, invm);
+      cy += mulredc1_20(z, x[0], y, m, invm[0]);
       x[0] += tmp[0];
     }
     break;
    default: ;
   }
   t3 = CPUTime() - t3;
-  
-  t1 *= 1000000.;
-  t2 *= 1000000.;
   t3 *= 1000000.;
-  printf("******************\nTime in microseconds per call, size=%lu\n", N);
-  printf("mul+redc = %f\nmulredc  = %f\n", t1/iter, t2/iter);
-  printf("mulredc1 = %f\n", t3/LOOPCOUNT);
-#else /* if defined(HAVE_NATIVE_MULREDC1_N) */
-  t1 *= 1000000.;
+#endif /* if defined(HAVE_NATIVE_MULREDC1_N) */
+
+  tmul *= 1000000.;
+  tsqr *= 1000000.;
+  tredc_1 *= 1000000.;
+  tsvoboda1 *= 1000000.;
   t2 *= 1000000.;
-  t3 *= 1000000.;
   printf("******************\nTime in microseconds per call, size=%lu\n", N);
-  printf("mul+redc = %f\nmulredc  = %f\n", t1/iter, t2/iter);
+
+  /* basic operations */
+  printf("mpn_mul_n  = %f\n", tmul/iter);
+  printf("mpn_sqr    = %f\n", tsqr/iter);
+#ifdef HAVE___GMPN_REDC_1
+  printf("mpn_redc_1 = %f\n", tredc_1/iter);
+#endif
+  if (N > 1)
+    printf("svoboda1   = %f\n", tsvoboda1/iter);
+#ifdef HAVE___GMPN_REDC_2
+  tredc_2 *= 1000000.;
+  printf("mpn_redc_2 = %f\n", tredc_2/iter);
+#endif
+#ifdef HAVE___GMPN_REDC_N
+  tredc_n *= 1000000.;
+  printf("mpn_redc_n = %f\n", tredc_n/iter);
+#endif
+
+  /* modular multiplication and squaring */
+  printf("mulredc    = %f\n", t2/iter);
+#if defined(HAVE___GMPN_REDC_1)
+  t_mulredc_1 *= 1000000.;
+  printf("mul+redc_1 = %f\n", t_mulredc_1/iter);
+#endif
+#if defined(HAVE___GMPN_REDC_2)
+  t_mulredc_2 *= 1000000.;
+  printf("mul+redc_2 = %f\n", t_mulredc_2/iter);
 #endif
-  printf("Ratio %f, mulredc time/size = %f, mulredc time/size^2 = %f\n", 
-         t1/t2, t2/iter/N, t2/iter/N/N);
+#if defined(HAVE___GMPN_REDC_N)
+  t_mulredc_n *= 1000000.;
+  printf("mul+redc_n = %f\n", t_mulredc_n/iter);
+#endif
+#if defined(HAVE___GMPN_REDC_1)
+  t_sqrredc_1 *= 1000000.;
+  printf("sqr+redc_1 = %f\n", t_sqrredc_1/iter);
+#endif
+#if defined(HAVE___GMPN_REDC_2)
+  t_sqrredc_2 *= 1000000.;
+  printf("sqr+redc_2 = %f\n", t_sqrredc_2/iter);
+#endif
+#if defined(HAVE___GMPN_REDC_N)
+  t_sqrredc_n *= 1000000.;
+  printf("sqr+redc_n = %f\n", t_sqrredc_n/iter);
+#endif
+
+  /* multiplication of n limbs by one limb */
+  printf ("mulredc1   = %f\n", t3/LOOPCOUNT);
   
   free(tmp);
   free(x); free(y); free(z); free(m);
+  free (invm);
+  free (svoboda1);
 }
   
 
 int main(int argc, char** argv)
 {
   int i;
-  int minsize = 1, maxsize = 20;
+  int minsize = 1, maxsize = MAXSIZE;
 
   if (argc > 1)
     minsize = atoi (argv[1]);
   if (argc > 2)
     maxsize = atoi (argv[2]);
   
-    for (i = minsize; i <= maxsize; ++i) {
-      bench(i);
-    }
+  for (i = minsize; i <= maxsize; ++i)
+    bench(i);
+
+  printf ("/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */\n");
+  printf ("#define TUNE_MULREDC_TABLE {0");
+  for (i = 1; i <= maxsize; i++)
+    printf (",%d", tune_mul[i]);
+  printf ("}\n");
+  printf ("/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */\n");
+  printf ("#define TUNE_SQRREDC_TABLE {0");
+  for (i = 1; i <= maxsize; i++)
+    printf (",%d", tune_sqr[i]);
+  printf ("}\n");
 
   return 0;
 }
-
-
-#if 0
-
-W := 2^64;
-
-x0:= 12580274668139321508;
-x1:= 9205793975152560417;
-x2:= 7857372727033793057;
-x := x0 + W*(x1 + W*x2);
-
-y0:= 13688385828267279103;
-y1:= 10575011835742767258;
-y2:= 8802048318027595690;
-y := y0 + W*(y1 + W*y2);
-  
-m0:= 2981542467342508025;
-m1:= 5964669706257742025;
-m2:= 18446744073678090270;
-m := m0 + W*(m1 + W*m2);
-  
-invm := 9419286575570128311;
-
-
-
-#endif
diff --git a/build.vc10/Makefile.am b/build.vc10/Makefile.am
new file mode 100644
index 0000000..603bec4
--- /dev/null
+++ b/build.vc10/Makefile.am
@@ -0,0 +1,10 @@
+EXTRA_DIST = config.h ecm-params.h ecm-params.h.win32.amd  \
+             ecm-params.h.win32.intel ecm-params.h.x64.amd \
+             ecm-params.h.x64.intel ecm.sln file_copy.bat \
+             mp_lib.props mul_fft-params.h.win32.amd \
+             mul_fft-params.h.win32.intel mul_fft-params.h.x64.amd \
+             mul_fft-params.h.x64.intel readme.txt tests.py \
+             vsyasm.props vsyasm.targets vsyasm.xml bench_mulredc \
+             getrusage.h
+
+DIST_SUBDIRS = assembler ecm libecm tune bench_mulredc
diff --git a/build.vc9/Makefile.in b/build.vc10/Makefile.in
similarity index 97%
rename from build.vc9/Makefile.in
rename to build.vc10/Makefile.in
index 60025c6..369e22c 100644
--- a/build.vc9/Makefile.in
+++ b/build.vc10/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9
+subdir = build.vc10
 SUBDIRS =
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -215,14 +215,16 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = config.h ecm-params.h ecm.sln file_copy.bat readme.txt \
-             tests.py yasm.rules ecm-params.h.win32.amd \
+EXTRA_DIST = config.h ecm-params.h ecm-params.h.win32.amd  \
              ecm-params.h.win32.intel ecm-params.h.x64.amd \
-             ecm-params.h.x64.intel mul_fft-params.h.win32.amd \
+             ecm-params.h.x64.intel ecm.sln file_copy.bat \
+             mp_lib.props mul_fft-params.h.win32.amd \
              mul_fft-params.h.win32.intel mul_fft-params.h.x64.amd \
-             mul_fft-params.h.x64.intel mp_lib.vsprops 
+             mul_fft-params.h.x64.intel readme.txt tests.py \
+             vsyasm.props vsyasm.targets vsyasm.xml bench_mulredc \
+             getrusage.h
 
-DIST_SUBDIRS = assembler ecm libecm tune
+DIST_SUBDIRS = assembler ecm libecm tune bench_mulredc
 all: all-recursive
 
 .SUFFIXES:
@@ -235,9 +237,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc9/assembler/Makefile.am b/build.vc10/assembler/Makefile.am
similarity index 70%
rename from build.vc9/assembler/Makefile.am
rename to build.vc10/assembler/Makefile.am
index cbe0b22..3b2f7d8 100644
--- a/build.vc9/assembler/Makefile.am
+++ b/build.vc10/assembler/Makefile.am
@@ -1,3 +1,3 @@
 EXTRA_DIST = a_win32a_mulredc.asm a_win32a_redc.asm a_win32p_mulredc.asm \
              a_win32p_redc.asm a_x64_mulredc.asm a_x64_redc.asm \
-             test_mulredc.c mulredc.h
+             test_mulredc.c mulredc.h mulredc.asm redc.asm
diff --git a/build.vc9/assembler/Makefile.in b/build.vc10/assembler/Makefile.in
similarity index 97%
copy from build.vc9/assembler/Makefile.in
copy to build.vc10/assembler/Makefile.in
index bf240ef..b46aa48 100644
--- a/build.vc9/assembler/Makefile.in
+++ b/build.vc10/assembler/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9/assembler
+subdir = build.vc10/assembler
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -177,7 +177,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 EXTRA_DIST = a_win32a_mulredc.asm a_win32a_redc.asm a_win32p_mulredc.asm \
              a_win32p_redc.asm a_x64_mulredc.asm a_x64_redc.asm \
-             test_mulredc.c mulredc.h
+             test_mulredc.c mulredc.h mulredc.asm redc.asm
 
 all: all-am
 
@@ -191,9 +191,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/assembler/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/assembler/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/assembler/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/assembler/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc9/assembler/a_win32a_mulredc.asm b/build.vc10/assembler/a_win32a_mulredc.asm
similarity index 100%
rename from build.vc9/assembler/a_win32a_mulredc.asm
rename to build.vc10/assembler/a_win32a_mulredc.asm
diff --git a/build.vc9/assembler/a_win32a_redc.asm b/build.vc10/assembler/a_win32a_redc.asm
similarity index 100%
rename from build.vc9/assembler/a_win32a_redc.asm
rename to build.vc10/assembler/a_win32a_redc.asm
diff --git a/build.vc9/assembler/a_win32p_mulredc.asm b/build.vc10/assembler/a_win32p_mulredc.asm
similarity index 100%
rename from build.vc9/assembler/a_win32p_mulredc.asm
rename to build.vc10/assembler/a_win32p_mulredc.asm
diff --git a/build.vc9/assembler/a_win32p_redc.asm b/build.vc10/assembler/a_win32p_redc.asm
similarity index 100%
rename from build.vc9/assembler/a_win32p_redc.asm
rename to build.vc10/assembler/a_win32p_redc.asm
diff --git a/build.vc9/assembler/a_x64_mulredc.asm b/build.vc10/assembler/a_x64_mulredc.asm
similarity index 100%
rename from build.vc9/assembler/a_x64_mulredc.asm
rename to build.vc10/assembler/a_x64_mulredc.asm
diff --git a/build.vc9/assembler/a_x64_redc.asm b/build.vc10/assembler/a_x64_redc.asm
similarity index 100%
rename from build.vc9/assembler/a_x64_redc.asm
rename to build.vc10/assembler/a_x64_redc.asm
diff --git a/build.vc10/assembler/mulredc.asm b/build.vc10/assembler/mulredc.asm
new file mode 100644
index 0000000..dce818c
--- /dev/null
+++ b/build.vc10/assembler/mulredc.asm
@@ -0,0 +1,8 @@
+
+%ifdef _WIN64
+%include "a_x64_mulredc.asm"
+%elif AMD_ASM
+%include "a_win32a_mulredc.asm"
+%else
+%include "a_win32p_mulredc.asm"
+%endif
diff --git a/build.vc9/assembler/mulredc.h b/build.vc10/assembler/mulredc.h
similarity index 98%
rename from build.vc9/assembler/mulredc.h
rename to build.vc10/assembler/mulredc.h
index cf4408e..8902af3 100644
--- a/build.vc9/assembler/mulredc.h
+++ b/build.vc10/assembler/mulredc.h
@@ -1,33 +1,32 @@
-#ifndef __ASM_REDC_H__
-#define __ASM_REDC_H__
-
-#include <gmp.h>
-
-extern void ecm_redc3(mp_limb_t *cp, const mp_limb_t *np, mp_size_t nn, mp_limb_t Nprim);
-
-
-/* WARNING: the size-1 version doesn't take pointers in input */
-extern mp_limb_t mulredc1(mp_limb_t *z, mp_limb_t x, mp_limb_t y, mp_limb_t m, mp_limb_t inv_m);
-
-extern mp_limb_t mulredc2(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc3(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc4(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc5(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc6(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc7(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc8(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc9(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc10(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc11(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc12(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc13(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc14(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc15(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc16(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc17(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc18(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc19(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-extern mp_limb_t mulredc20(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
-
-
-#endif
+#ifndef __ASM_REDC_H__
+#define __ASM_REDC_H__
+
+#include <gmp.h>
+
+extern void ecm_redc3(mp_limb_t *cp, const mp_limb_t *np, mp_size_t nn, mp_limb_t Nprim);
+
+
+/* WARNING: the size-1 version doesn't take pointers in input */
+extern mp_limb_t mulredc1(mp_limb_t *z, mp_limb_t x, mp_limb_t y, mp_limb_t m, mp_limb_t inv_m);
+
+extern mp_limb_t mulredc2(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc3(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc4(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc5(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc6(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc7(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc8(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc9(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc10(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc11(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc12(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc13(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc14(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc15(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc16(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc17(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc18(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc19(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+extern mp_limb_t mulredc20(mp_limb_t *z, const mp_limb_t *x, const mp_limb_t *y, const mp_limb_t *m, mp_limb_t inv_m);
+
+#endif
diff --git a/build.vc10/assembler/redc.asm b/build.vc10/assembler/redc.asm
new file mode 100644
index 0000000..1653e1c
--- /dev/null
+++ b/build.vc10/assembler/redc.asm
@@ -0,0 +1,7 @@
+%ifdef _WIN64
+%include "a_x64_redc.asm"
+%elif AMD_ASM
+%include "a_win32a_redc.asm"
+%else
+%include "a_win32p_redc.asm"
+%endif
diff --git a/build.vc9/assembler/test_mulredc.c b/build.vc10/assembler/test_mulredc.c
similarity index 100%
rename from build.vc9/assembler/test_mulredc.c
rename to build.vc10/assembler/test_mulredc.c
diff --git a/build.vc10/bench_mulredc/.svn/entries b/build.vc10/bench_mulredc/.svn/entries
new file mode 100644
index 0000000..3d2b79a
--- /dev/null
+++ b/build.vc10/bench_mulredc/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+1806
+svn+ssh://zimmerma@scm.gforge.inria.fr/svn/ecm/trunk/build.vc10/bench_mulredc
+svn+ssh://zimmerma@scm.gforge.inria.fr/svn/ecm
+
+
+
+2012-02-13T21:06:19.227914Z
+1741
+brian_gladman
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+404564d9-a503-0410-82bf-e18ce2cf3989
+

+bench_mulredc.vcxproj.user
+file
+
+
+
+
+2012-02-22T09:52:32.130267Z
+02816bcc1da4abf7ab716035d355eb7c
+2012-02-13T21:06:19.227914Z
+1741
+brian_gladman
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+143
+

+bench_mulredc.vcxproj
+file
+
+
+
+
+2012-02-22T09:52:32.136269Z
+052d3efdacd6f8a437b8d2cd17fb85a9
+2012-02-13T21:06:19.227914Z
+1741
+brian_gladman
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9150
+

+Makefile.am
+file
+
+
+
+
+2012-02-22T09:52:32.141268Z
+007ea1b0b9e9fe52a3d903b57e6aa3e0
+2012-02-13T21:06:19.227914Z
+1741
+brian_gladman
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+65
+

+bench_mulredc.vcxproj.filters
+file
+
+
+
+
+2012-02-22T09:52:32.147267Z
+077f74d12c91ab2a093960a1e676bb9f
+2012-02-13T21:06:19.227914Z
+1741
+brian_gladman
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+935
+

diff --git a/build.vc10/bench_mulredc/.svn/text-base/Makefile.am.svn-base b/build.vc10/bench_mulredc/.svn/text-base/Makefile.am.svn-base
new file mode 100644
index 0000000..5a7c0bc
--- /dev/null
+++ b/build.vc10/bench_mulredc/.svn/text-base/Makefile.am.svn-base
@@ -0,0 +1 @@
+EXTRA_DIST = bench_mulredc.vcxproj bench_mulredc.vcxproj.filters
diff --git a/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.filters.svn-base b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.filters.svn-base
new file mode 100644
index 0000000..674b5ca
--- /dev/null
+++ b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.filters.svn-base
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\bench_mulredc.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\getrusage.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\getrusage.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.svn-base b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.svn-base
new file mode 100644
index 0000000..de65b4a
--- /dev/null
+++ b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.svn-base
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{4727DE12-787D-432D-B166-BF103B0C3C87}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>bench_mulredc</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WIN64;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>_WIN64;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\bench_mulredc.c" />
+    <ClCompile Include="..\getrusage.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\getrusage.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.user.svn-base b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.user.svn-base
new file mode 100644
index 0000000..695b5c7
--- /dev/null
+++ b/build.vc10/bench_mulredc/.svn/text-base/bench_mulredc.vcxproj.user.svn-base
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+</Project>
\ No newline at end of file
diff --git a/build.vc9/assembler/Makefile.in b/build.vc10/bench_mulredc/Makefile
similarity index 62%
rename from build.vc9/assembler/Makefile.in
rename to build.vc10/bench_mulredc/Makefile
index bf240ef..a7617d9 100644
--- a/build.vc9/assembler/Makefile.in
+++ b/build.vc10/bench_mulredc/Makefile
@@ -1,5 +1,5 @@
 # Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
+# build.vc10/bench_mulredc/Makefile.  Generated from Makefile.in by configure.
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
@@ -13,12 +13,12 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
- at SET_MAKE@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
+
+
+pkgdatadir = $(datadir)/ecm
+pkgincludedir = $(includedir)/ecm
+pkglibdir = $(libdir)/ecm
+pkglibexecdir = $(libexecdir)/ecm
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -31,9 +31,9 @@ POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-subdir = build.vc9/assembler
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+subdir = build.vc10/bench_mulredc
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -49,136 +49,133 @@ CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMTAR = @AMTAR@
-AR = @AR@
-ASMPATH = @ASMPATH@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCAS = @CCAS@
-CCASDEPMODE = @CCASDEPMODE@
-CCASFLAGS = @CCASFLAGS@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-FGREP = @FGREP@
-GMPLIB = @GMPLIB@
-GREP = @GREP@
-GSL_LD_FLAGS = @GSL_LD_FLAGS@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-M4 = @M4@
-MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
-MKDIR_P = @MKDIR_P@
-NM = @NM@
-NMEDIT = @NMEDIT@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OPENMP_CFLAGS = @OPENMP_CFLAGS@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-POW_LIB = @POW_LIB@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VALGRIND = @VALGRIND@
-VERSION = @VERSION@
-XSLDIR = @XSLDIR@
-XSLTPROC = @XSLTPROC@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-EXTRA_DIST = a_win32a_mulredc.asm a_win32a_redc.asm a_win32p_mulredc.asm \
-             a_win32p_redc.asm a_x64_mulredc.asm a_x64_redc.asm \
-             test_mulredc.c mulredc.h
-
+ACLOCAL = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run aclocal-1.11
+ALLOCA = 
+AMTAR = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run tar
+AR = ar
+ASMPATH = x86_64
+AUTOCONF = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run autoconf
+AUTOHEADER = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run autoheader
+AUTOMAKE = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run automake-1.11
+AWK = gawk
+CC = gcc -std=gnu99
+CCAS = gcc -std=gnu99
+CCASDEPMODE = depmode=gcc3
+CCASFLAGS = -O2 -pedantic -m64 -mtune=amdfam10 -march=amdfam10
+CCDEPMODE = depmode=gcc3
+CFLAGS = -W -Wall -Wundef -O2 -pedantic -m64 -mtune=amdfam10 -march=amdfam10
+CPP = gcc -std=gnu99 -E
+CPPFLAGS = -I/users/caramel/logiciels/gmp-5.0.4/x86_64/include -I/users/caramel/logiciels/gmp-5.0.4/x86_64/include
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DLLTOOL = false
+DSYMUTIL = 
+DUMPBIN = 
+ECHO_C = 
+ECHO_N = -n
+ECHO_T = 
+EGREP = /bin/grep -E
+EXEEXT = 
+FGREP = /bin/grep -F
+GMPLIB = /users/caramel/logiciels/gmp-5.0.4/x86_64/lib/libgmp.a
+GREP = /bin/grep
+GSL_LD_FLAGS = 
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+LD = /usr/bin/ld -m elf_x86_64
+LDFLAGS =  
+LIBOBJS = 
+LIBS = -lm -lm -lm -lm -lm  
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO = 
+LN_S = ln -s
+LTLIBOBJS = 
+M4 = m4
+MAKEINFO = ${SHELL} /users/caramel/zimmerma/svn/ecm/missing --run makeinfo
+MANIFEST_TOOL = :
+MKDIR_P = /bin/mkdir -p
+NM = /usr/bin/nm -B
+NMEDIT = 
+OBJDUMP = objdump
+OBJEXT = o
+OPENMP_CFLAGS = 
+OTOOL = 
+OTOOL64 = 
+PACKAGE = ecm
+PACKAGE_BUGREPORT = ecm-discuss at lists.gforge.inria.fr
+PACKAGE_NAME = ecm
+PACKAGE_STRING = ecm 6.4.1-rc2
+PACKAGE_TARNAME = ecm
+PACKAGE_URL = 
+PACKAGE_VERSION = 6.4.1-rc2
+PATH_SEPARATOR = :
+POW_LIB = 
+RANLIB = ranlib
+SED = /bin/sed
+SET_MAKE = 
+SHELL = /bin/bash
+STRIP = strip
+VALGRIND = valgrind -q --error-exitcode=1
+VERSION = 6.4.1-rc2
+XSLDIR = /usr/share/sgml/docbook/xsl-stylesheets-1.68.1-1.1
+XSLTPROC = 
+abs_builddir = /users/caramel/zimmerma/svn/ecm/build.vc10/bench_mulredc
+abs_srcdir = /users/caramel/zimmerma/svn/ecm/build.vc10/bench_mulredc
+abs_top_builddir = /users/caramel/zimmerma/svn/ecm
+abs_top_srcdir = /users/caramel/zimmerma/svn/ecm
+ac_ct_AR = ar
+ac_ct_CC = gcc -std=gnu99
+ac_ct_DUMPBIN = 
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias = 
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /users/caramel/zimmerma/svn/ecm/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = /bin/mkdir -p
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias = 
+top_build_prefix = ../../
+top_builddir = ../..
+top_srcdir = ../..
+EXTRA_DIST = bench_mulredc.vcxproj bench_mulredc.vcxproj.filters
 all: all-am
 
 .SUFFIXES:
@@ -191,9 +188,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/assembler/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/bench_mulredc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/assembler/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/bench_mulredc/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc10/bench_mulredc/Makefile.am b/build.vc10/bench_mulredc/Makefile.am
new file mode 100644
index 0000000..5a7c0bc
--- /dev/null
+++ b/build.vc10/bench_mulredc/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = bench_mulredc.vcxproj bench_mulredc.vcxproj.filters
diff --git a/build.vc9/ecm/Makefile.in b/build.vc10/bench_mulredc/Makefile.in
similarity index 97%
copy from build.vc9/ecm/Makefile.in
copy to build.vc10/bench_mulredc/Makefile.in
index 94b2f6a..911c514 100644
--- a/build.vc9/ecm/Makefile.in
+++ b/build.vc10/bench_mulredc/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9/ecm
+subdir = build.vc10/bench_mulredc
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -175,7 +175,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = ecm.vcproj
+EXTRA_DIST = bench_mulredc.vcxproj bench_mulredc.vcxproj.filters
 all: all-am
 
 .SUFFIXES:
@@ -188,9 +188,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/ecm/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/bench_mulredc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/ecm/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/bench_mulredc/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc10/bench_mulredc/bench_mulredc.vcxproj b/build.vc10/bench_mulredc/bench_mulredc.vcxproj
new file mode 100644
index 0000000..de65b4a
--- /dev/null
+++ b/build.vc10/bench_mulredc/bench_mulredc.vcxproj
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{4727DE12-787D-432D-B166-BF103B0C3C87}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>bench_mulredc</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <OutDir>$(SolutionDir)..bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir>$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WIN64;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>_WIN64;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\</AdditionalIncludeDirectories>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>psapi.lib;..\..\..\$(mp_dir)lib\$(IntDir)\mpir.lib;..\..\lib\$(IntDir)\libecm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\bench_mulredc.c" />
+    <ClCompile Include="..\getrusage.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\getrusage.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/bench_mulredc/bench_mulredc.vcxproj.filters b/build.vc10/bench_mulredc/bench_mulredc.vcxproj.filters
new file mode 100644
index 0000000..674b5ca
--- /dev/null
+++ b/build.vc10/bench_mulredc/bench_mulredc.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\bench_mulredc.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\getrusage.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\getrusage.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/bench_mulredc/bench_mulredc.vcxproj.user b/build.vc10/bench_mulredc/bench_mulredc.vcxproj.user
new file mode 100644
index 0000000..695b5c7
--- /dev/null
+++ b/build.vc10/bench_mulredc/bench_mulredc.vcxproj.user
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+</Project>
\ No newline at end of file
diff --git a/build.vc9/config.h b/build.vc10/config.h
similarity index 94%
rename from build.vc9/config.h
rename to build.vc10/config.h
index e78f74a..6c35677 100644
--- a/build.vc9/config.h
+++ b/build.vc10/config.h
@@ -1,216 +1,227 @@
-/* config.h.in.  Generated from configure.in by autoheader.  */
-
-#define VERSION "6.4"
-
-#define PACKAGE_BUGREPORT "ecm-discuss at lists.gforge.inria.fr"
-
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
-   systems. This function is required for `alloca.c' support on those systems.
-   */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#define C_ALLOCA 1
-
-/* Define to 1 if you have the `access' function. */
-#undef HAVE_ACCESS
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
-   */
-#undef HAVE_ALLOCA_H
-
-/* Define to 1 if you have the `ctime' function. */
-#define HAVE_CTIME 1
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#define HAVE_CTYPE_H 1
-
-/* Define to 1 if you have the `floor' function. */
-#define HAVE_FLOOR 1
-
-/* Define to 1 if you have the `fmod' function. */
-#define HAVE_FMOD 1
-
-/* Define to 1 if you have the `gethostname' function. */
-#define HAVE_GETHOSTNAME 1
-
-/* Define to 1 if you have the `getrusage' function. */
-#define HAVE_GETRUSAGE   1
-
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
-/* Define to 1 if you have the <gmp.h> header file. */
-#define HAVE_GMP_H 1
-
-/* Define to 1 if gwnum.a or gwnum.lib exist */
-#undef HAVE_GWNUM
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <io.h> header file. */
-#undef HAVE_IO_H
-
-/* Define to 1 if you have the `isascii' function. */
-#undef HAVE_ISASCII
-
-/* Define to 1 if you have the `isdigit' function. */
-#define HAVE_ISDIGIT 1
-
-/* Define to 1 if you have the `isspace' function. */
-#define HAVE_ISSPACE 1
-
-/* Define to 1 if you have the `isxdigit' function. */
-#define HAVE_ISXDIGIT 1
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define to 1 if you have the <malloc.h> header file. */
-#define HAVE_MALLOC_H 1
- 
-/* Define to 1 if you have the `malloc_usable_size' function. */
-#undef HAVE_MALLOC_USABLE_SIZE
-
-/* Define to 1 if you have the <math.h> header file. */
-#define HAVE_MATH_H 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `memset' function. */
-#define HAVE_MEMSET 1
-
-/* Define to 1 if you have the `nice' function. */
-#undef HAVE_NICE
-
-/* Define to 1 if you have the `pow' function. */
-#define HAVE_POW 1
-
-/* Define to 1 if you have the `signal' function. */
-#define HAVE_SIGNAL 1
-
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
-
-/* Define to 1 if you have the `sqrt' function. */
-#define HAVE_SQRT 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strchr' function. */
-#define HAVE_STRCHR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strlen' function. */
-#define HAVE_STRLEN 1
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strstr' function. */
-#undef HAVE_STRSTR
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the `time' function. */
-#undef HAVE_TIME
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `unlink' function. */
-#define HAVE_UNLINK 1
-
-/* Define to 1 if you have the <windows.h> header file. */
-#define HAVE_WINDOWS_H 1
-
-/* Define to 1 if you have the `__gmpn_add_nc' function. */
-#define HAVE___GMPN_ADD_NC 1
-
-/* Define to 1 if you have the `__gmpn_mod_34lsub1' function. */
-#define HAVE___GMPN_MOD_34LSUB1 1
-
-/* Define to 1 if you have the `__gmpn_mul_fft' function. */
-#define HAVE___GMPN_MUL_FFT 1
-
-/* Define to 1 if you want memory debugging */
-#undef MEMORY_DEBUG
-
-/* Define if the system has the type `long long'. */
-#define HAVE_LONG_LONG		1
-
-/* Define to 1 to use asm redc on x86 or x86_64 */
-#  define NATIVE_REDC   1         
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-/* If using the C implementation of alloca, define if you know the
-   direction of stack growth for your system; otherwise it will be
-   automatically deduced at runtime.
-	STACK_DIRECTION > 0 => grows toward higher addresses
-	STACK_DIRECTION < 0 => grows toward lower addresses
-	STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Define to 1 if you want assertions enabled */
-#undef WANT_ASSERT
-
-/* Define to 1 if you want shell command execution */
-#undef WANT_SHELLCMD
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* How to specify hot-spot attribute, if available */
-#define ATTRIBUTE_HOT 
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-#define inline __inline
-#endif
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
-
-#ifdef _MSC_VER
-#  define strncasecmp strnicmp
-#  define alloca  _alloca
-#endif
+/* config.h.in.  Generated from configure.in by autoheader.  */
+
+#define VERSION "6.4.1-rc2"
+
+#define VERSION_GPU "gpu_ecm-win"
+
+#define PACKAGE_BUGREPORT "ecm-discuss at lists.gforge.inria.fr"
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#define C_ALLOCA 1
+
+/* Define to 1 if you have the `access' function. */
+#undef HAVE_ACCESS
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the `ctime' function. */
+#define HAVE_CTIME 1
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the `floor' function. */
+#define HAVE_FLOOR 1
+
+/* Define to 1 if you have the `fmod' function. */
+#define HAVE_FMOD 1
+
+/* Define to 1 if you have the `gethostname' function. */
+#define HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the `getrusage' function. */
+#define HAVE_GETRUSAGE   1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <gmp.h> header file. */
+#define HAVE_GMP_H 1
+
+/* Define to 1 if gwnum.a or gwnum.lib exist */
+#undef HAVE_GWNUM
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <io.h> header file. */
+#undef HAVE_IO_H
+
+/* Define to 1 if you have the `isascii' function. */
+#undef HAVE_ISASCII
+
+/* Define to 1 if you have the `isdigit' function. */
+#define HAVE_ISDIGIT 1
+
+/* Define to 1 if you have the `isspace' function. */
+#define HAVE_ISSPACE 1
+
+/* Define to 1 if you have the `isxdigit' function. */
+#define HAVE_ISXDIGIT 1
+
+/* Define to 1 if you have the `m' library (-lm). */
+#undef HAVE_LIBM
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+ 
+/* Define to 1 if you have the `malloc_usable_size' function. */
+#undef HAVE_MALLOC_USABLE_SIZE
+
+/* Define to 1 if you have the <math.h> header file. */
+#define HAVE_MATH_H 1
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `nice' function. */
+#undef HAVE_NICE
+
+/* Define to 1 if you have the `pow' function. */
+#define HAVE_POW 1
+
+/* Define to 1 if you have the `signal' function. */
+#define HAVE_SIGNAL 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the `sqrt' function. */
+#define HAVE_SQRT 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strlen' function. */
+#define HAVE_STRLEN 1
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `time' function. */
+#undef HAVE_TIME
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `unlink' function. */
+#define HAVE_UNLINK 1
+
+/* Define to 1 if you have the <windows.h> header file. */
+#define HAVE_WINDOWS_H 1
+
+/* Define to 1 if you have the `__gmpn_add_nc' function. */
+#if defined( _WIN64 )
+#  define HAVE___GMPN_ADD_NC 1
+#endif
+
+/* Define to 1 if you have the `__gmpn_mod_34lsub1' function. */
+#define HAVE___GMPN_MOD_34LSUB1 1
+
+/* Define to 1 if you have the `__gmpn_mul_fft' function. */
+#define HAVE___GMPN_MUL_FFT 1
+
+/* Define to 1 if you want memory debugging */
+#undef MEMORY_DEBUG
+
+/* Define if the system has the type `long long'. */
+#define HAVE_LONG_LONG		1
+#define HAVE_LONG_LONG_INT  1
+
+/* Define to 1 to use asm redc on x86 or x86_64 */
+#  define NATIVE_REDC   1         
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if you want assertions enabled */
+#undef WANT_ASSERT
+
+/* Define to 1 if you want shell command execution */
+#undef WANT_SHELLCMD
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* How to specify hot-spot attribute, if available */
+#define ATTRIBUTE_HOT
+
+#define HAVE___GMPN_REDC_1 1
+
+#define HAVE_ASM_REDC3  1
+
+#define WINDOWS64_ABI   1
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#define inline __inline
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+#ifdef _MSC_VER
+#  define strncasecmp strnicmp
+#  define alloca  _alloca
+#endif
diff --git a/build.vc9/ecm-params.h.win32.amd b/build.vc10/ecm-params.h
similarity index 80%
copy from build.vc9/ecm-params.h.win32.amd
copy to build.vc10/ecm-params.h
index 77fe471..0dfe9a5 100644
--- a/build.vc9/ecm-params.h.win32.amd
+++ b/build.vc10/ecm-params.h
@@ -3,8 +3,6 @@
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 1, 7, 8, 1, 1, 8, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 16, 16, 1, 1, 16, 1}
 #define NTT_GFP_TWIDDLE_DIF_BREAKOVER 11
 #define NTT_GFP_TWIDDLE_DIT_BREAKOVER 11
-#define SPV_NTT_GFP_DIF_RECURSIVE_THRESHOLD 32768
-#define SPV_NTT_GFP_DIT_RECURSIVE_THRESHOLD 32768
 #define MUL_NTT_THRESHOLD 1024
 #define PREREVERTDIVISION_NTT_THRESHOLD 64
 #define POLYINVERT_NTT_THRESHOLD 512
diff --git a/build.vc9/ecm-params.h.win32.amd b/build.vc10/ecm-params.h.win32.amd
similarity index 90%
rename from build.vc9/ecm-params.h.win32.amd
rename to build.vc10/ecm-params.h.win32.amd
index 77fe471..98ff180 100644
--- a/build.vc9/ecm-params.h.win32.amd
+++ b/build.vc10/ecm-params.h.win32.amd
@@ -1,3 +1,4 @@
+/* this is the parameter file for Opteron */
 #define MPZMOD_THRESHOLD 170
 #define REDC_THRESHOLD 294
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 1, 7, 8, 1, 1, 8, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 16, 1, 1, 16, 16, 1, 1, 16, 1}
diff --git a/ecm-params.h.pentium-m b/build.vc10/ecm-params.h.win32.intel
similarity index 100%
copy from ecm-params.h.pentium-m
copy to build.vc10/ecm-params.h.win32.intel
diff --git a/ecm-params.h.athlon64 b/build.vc10/ecm-params.h.x64.amd
similarity index 97%
copy from ecm-params.h.athlon64
copy to build.vc10/ecm-params.h.x64.amd
index 053b612..6fae8e6 100644
--- a/ecm-params.h.athlon64
+++ b/build.vc10/ecm-params.h.x64.amd
@@ -1,15 +1,15 @@
-/* updated 03 Jan 2012 on frite.loria.fr (AMD Phenom(tm) II X2 B55 Processor)
-   for ecm-6.4 with GMP 5.0.2 */
-
-#define TUNE_MULREDC_THRESH 10
-#define TUNE_SQRREDC_THRESH 1
-#define MPZMOD_THRESHOLD 103
-#define REDC_THRESHOLD 512
-#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 8, 10, 11, 11, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 16, 18, 18, 18, 20}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 12
-#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
-#define MUL_NTT_THRESHOLD 256
-#define PREREVERTDIVISION_NTT_THRESHOLD 16
-#define POLYINVERT_NTT_THRESHOLD 512
-#define POLYEVALT_NTT_THRESHOLD 128
-#define MPZSPV_NORMALISE_STRIDE 512
+/* updated 03 Jan 2012 on frite.loria.fr (AMD Phenom(tm) II X2 B55 Processor)
+   for ecm-6.4 with GMP 5.0.2 */
+
+#define TUNE_MULREDC_THRESH 10
+#define TUNE_SQRREDC_THRESH 1
+#define MPZMOD_THRESHOLD 103
+#define REDC_THRESHOLD 512
+#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 8, 10, 11, 11, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 16, 18, 18, 18, 20}
+#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 12
+#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
+#define MUL_NTT_THRESHOLD 256
+#define PREREVERTDIVISION_NTT_THRESHOLD 16
+#define POLYINVERT_NTT_THRESHOLD 512
+#define POLYEVALT_NTT_THRESHOLD 128
+#define MPZSPV_NORMALISE_STRIDE 512
diff --git a/build.vc10/ecm-params.h.x64.intel b/build.vc10/ecm-params.h.x64.intel
new file mode 100644
index 0000000..ec6ab3a
--- /dev/null
+++ b/build.vc10/ecm-params.h.x64.intel
@@ -0,0 +1,16 @@
+/* created 06 Feb 2012 on confit.loria.fr (Intel(R) Core(TM) i5-2500 CPU)
+   for svn revision 1705 with GMP 5.0.3 and gcc 4.6.1 */
+
+#define TUNE_MULREDC_THRESH 21
+#define TUNE_SQRREDC_THRESH 9
+#define MPZMOD_THRESHOLD 77
+#define REDC_THRESHOLD 512
+#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 11, 12, 12, 13, 14, 13, 14, 14, 16, 16, 16, 16, 16, 16}
+#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 17
+#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
+#define MUL_NTT_THRESHOLD 256
+#define PREREVERTDIVISION_NTT_THRESHOLD 8
+#define POLYINVERT_NTT_THRESHOLD 128
+#define POLYEVALT_NTT_THRESHOLD 64
+#define MPZSPV_NORMALISE_STRIDE 256
+
diff --git a/build.vc10/ecm.sln b/build.vc10/ecm.sln
new file mode 100644
index 0000000..71444c7
--- /dev/null
+++ b/build.vc10/ecm.sln
@@ -0,0 +1,58 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libecm", "libecm\libecm.vcxproj", "{CD555681-D65B-4173-A29C-B8BF06A4871B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecm", "ecm\ecm.vcxproj", "{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tune", "tune\tune.vcxproj", "{80E08750-5C6C-492E-BB1E-7200978AE125}"
+	ProjectSection(ProjectDependencies) = postProject
+		{CD555681-D65B-4173-A29C-B8BF06A4871B} = {CD555681-D65B-4173-A29C-B8BF06A4871B}
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187} = {C0E2EA85-996A-4B5F-AD30-590FAF5B7187}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bench_mulredc", "bench_mulredc\bench_mulredc.vcxproj", "{4727DE12-787D-432D-B166-BF103B0C3C87}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Debug|x64 = Debug|x64
+		Release|Win32 = Release|Win32
+		Release|x64 = Release|x64
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug|Win32.Build.0 = Debug|Win32
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug|x64.ActiveCfg = Debug|x64
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug|x64.Build.0 = Debug|x64
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release|Win32.ActiveCfg = Release|Win32
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release|Win32.Build.0 = Release|Win32
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release|x64.ActiveCfg = Release|x64
+		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release|x64.Build.0 = Release|x64
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug|Win32.Build.0 = Debug|Win32
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug|x64.ActiveCfg = Debug|x64
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug|x64.Build.0 = Debug|x64
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release|Win32.ActiveCfg = Release|Win32
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release|Win32.Build.0 = Release|Win32
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release|x64.ActiveCfg = Release|x64
+		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release|x64.Build.0 = Release|x64
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug|Win32.ActiveCfg = Release|x64
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug|x64.ActiveCfg = Release|x64
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug|x64.Build.0 = Release|x64
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release|Win32.ActiveCfg = Release|Win32
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release|Win32.Build.0 = Release|Win32
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release|x64.ActiveCfg = Release|x64
+		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release|x64.Build.0 = Release|x64
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Debug|Win32.Build.0 = Debug|Win32
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Debug|x64.ActiveCfg = Debug|x64
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Debug|x64.Build.0 = Debug|x64
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Release|Win32.ActiveCfg = Release|Win32
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Release|Win32.Build.0 = Release|Win32
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Release|x64.ActiveCfg = Release|x64
+		{4727DE12-787D-432D-B166-BF103B0C3C87}.Release|x64.Build.0 = Release|x64
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/build.vc10/ecm/Makefile.am b/build.vc10/ecm/Makefile.am
new file mode 100644
index 0000000..2f05e85
--- /dev/null
+++ b/build.vc10/ecm/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = ecm.vcxproj ecm.vcxproj.filters
diff --git a/build.vc9/tune/Makefile.in b/build.vc10/ecm/Makefile.in
similarity index 98%
rename from build.vc9/tune/Makefile.in
rename to build.vc10/ecm/Makefile.in
index e17e832..c3e062f 100644
--- a/build.vc9/tune/Makefile.in
+++ b/build.vc10/ecm/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9/tune
+subdir = build.vc10/ecm
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -175,7 +175,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = tune.vcproj
+EXTRA_DIST = ecm.vcxproj ecm.vcxproj.filters
 all: all-am
 
 .SUFFIXES:
@@ -188,9 +188,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/tune/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/ecm/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/tune/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/ecm/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc10/ecm/ecm.vcxproj b/build.vc10/ecm/ecm.vcxproj
new file mode 100644
index 0000000..0305e23
--- /dev/null
+++ b/build.vc10/ecm/ecm.vcxproj
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}</ProjectGuid>
+    <RootNamespace>ecm</RootNamespace>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+    <Import Project="..\vsyasm.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\bin\$(Platform)\Release\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\Release\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;OUTSIDE_LIBECM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <OpenMPSupport>true</OpenMPSupport>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);advapi32.lib;ws2_32.lib</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_CONSOLE;OUTSIDE_LIBECM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <OpenMPSupport>true</OpenMPSupport>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>ws2_32.lib;..\..\..\$(mp_dir)lib\$(Platform)\release\$(mp_lib);%(AdditionalDependencies)</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <TargetMachine>MachineX64</TargetMachine>
+      <StackReserveSize>8388608</StackReserveSize>
+      <StackCommitSize>65536</StackCommitSize>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;OUTSIDE_LIBECM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <OpenMPSupport>true</OpenMPSupport>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);advapi32.lib;ws2_32.lib</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_WIN64;_DEBUG;_CONSOLE;OUTSIDE_LIBECM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <OpenMPSupport>true</OpenMPSupport>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);advapi32.lib;ws2_32.lib</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <TargetMachine>MachineX64</TargetMachine>
+      <StackReserveSize>8388608</StackReserveSize>
+      <StackCommitSize>65536</StackCommitSize>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);advapi32.lib;ws2_32.lib</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxi.c" />
+    <ClCompile Include="..\..\b1_ainc.c" />
+    <ClCompile Include="..\..\candi.c" />
+    <ClCompile Include="..\..\eval.c" />
+    <ClCompile Include="..\..\getprime.c" />
+    <ClCompile Include="..\..\main.c" />
+    <ClCompile Include="..\..\random.c" />
+    <ClCompile Include="..\..\resume.c" />
+    <ClCompile Include="..\..\trial.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\champions.h" />
+    <ClInclude Include="..\..\config.h" />
+    <ClInclude Include="..\..\ecm-ecm.h" />
+    <ClInclude Include="..\..\ecm-gmp.h" />
+    <ClInclude Include="..\..\ecm-impl.h" />
+    <ClInclude Include="..\..\ecm.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\libecm\libecm.vcxproj">
+      <Project>{cd555681-d65b-4173-a29c-b8bf06a4871b}</Project>
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+    <Import Project="..\vsyasm.targets" />
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/ecm/ecm.vcxproj.filters b/build.vc10/ecm/ecm.vcxproj.filters
new file mode 100644
index 0000000..866be5b
--- /dev/null
+++ b/build.vc10/ecm/ecm.vcxproj.filters
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxi.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\b1_ainc.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\candi.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\eval.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\getprime.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\main.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\random.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\resume.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\trial.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-gmp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-impl.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\champions.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc9/file_copy.bat b/build.vc10/file_copy.bat
similarity index 100%
rename from build.vc9/file_copy.bat
rename to build.vc10/file_copy.bat
diff --git a/build.vc10/getrusage.h b/build.vc10/getrusage.h
new file mode 100644
index 0000000..f449c43
--- /dev/null
+++ b/build.vc10/getrusage.h
@@ -0,0 +1,46 @@
+
+#ifndef _GETRUSAGE_H
+#define _GETRUSAGE_H
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+#define ENODATA         61
+#define	RUSAGE_SELF	     0
+#define	RUSAGE_CHILDREN	-1
+
+typedef struct
+{
+    long            tv_sec;
+    long            tv_usec;
+} tval;
+
+typedef struct rusage
+{
+    tval  ru_utime;   /* user time used                      */
+    tval  ru_stime;   /* system time used                    */
+    long     ru_maxrss;  /* integral max resident set size      */
+    long     ru_ixrss;   /* integral shared text memory size    */
+    long     ru_idrss;   /* integral unshared data size         */
+    long     ru_isrss;   /* integral unshared stack size        */
+    long     ru_minflt;  /* page reclaims                       */
+    long     ru_majflt;  /* page faults                         */
+    long     ru_nswap;   /* swaps                               */
+    long     ru_inblock; /* block input operations              */
+    long     ru_oublock; /* block output operations             */
+    long     ru_msgsnd;  /* messages sent                       */
+    long     ru_msgrcv;  /* messages received                   */
+    long     ru_nsignals;/* signals received                    */
+    long     ru_nvcsw;   /* voluntary context switches          */
+    long     ru_nivcsw;  /* involuntary context switches        */
+} rusage;
+
+int getrusage(int who, rusage *usage);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/build.vc10/libecm/Makefile.am b/build.vc10/libecm/Makefile.am
new file mode 100644
index 0000000..bdadb81
--- /dev/null
+++ b/build.vc10/libecm/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = libecm.vcxproj libecm.vcxproj.filters
+ 
diff --git a/build.vc9/libecm/Makefile.in b/build.vc10/libecm/Makefile.in
similarity index 97%
rename from build.vc9/libecm/Makefile.in
rename to build.vc10/libecm/Makefile.in
index 03ee36f..1ba5754 100644
--- a/build.vc9/libecm/Makefile.in
+++ b/build.vc10/libecm/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9/libecm
+subdir = build.vc10/libecm
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -175,7 +175,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = libecm.vcproj
+EXTRA_DIST = libecm.vcxproj libecm.vcxproj.filters
 all: all-am
 
 .SUFFIXES:
@@ -188,9 +188,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/libecm/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/libecm/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/libecm/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/libecm/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc10/libecm/libecm.vcxproj b/build.vc10/libecm/libecm.vcxproj
new file mode 100644
index 0000000..37e7d98
--- /dev/null
+++ b/build.vc10/libecm/libecm.vcxproj
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{CD555681-D65B-4173-A29C-B8BF06A4871B}</ProjectGuid>
+    <RootNamespace>libecm</RootNamespace>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <UseOfAtl>Static</UseOfAtl>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+    <Import Project="..\vsyasm.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\lib\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ecmlib</TargetName>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <PreBuildEvent>
+      <Command>cd $(SolutionDir)
+call file_copy ecm-params.h.win32.intel ..\ecm-params.h
+call file_copy mul_fft-params.h.win32.intel ..\mul_fft-params.h
+call file_copy config.h ..\config.h
+</Command>
+    </PreBuildEvent>
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;SSE2;USE_ASM_REDC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <CompileAs>Default</CompileAs>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <PreBuildEvent>
+      <Command>cd $(SolutionDir)
+call file_copy ecm-params.h.x64.intel ..\ecm-params.h
+call file_copy mul_fft-params.h.x64.intel ..\mul_fft-params.h
+call file_copy config.h ..\config.h
+</Command>
+    </PreBuildEvent>
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_LIB;USE_ASM_REDC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <CompileAs>Default</CompileAs>
+    </ClCompile>
+    <Lib />
+    <Lib />
+    <YASM>
+      <Defines>_WIN64</Defines>
+    </YASM>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <PreBuildEvent>
+      <Command>cd $(SolutionDir)
+call file_copy ecm-params.h.win32.intel ..\ecm-params.h
+call file_copy mul_fft-params.h.win32.intel ..\mul_fft-params.h
+call file_copy config.h ..\config.h
+</Command>
+    </PreBuildEvent>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;SSE2;USE_ASM_REDC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <CompileAs>Default</CompileAs>
+    </ClCompile>
+    <Lib />
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <PreBuildEvent>
+      <Command>cd $(SolutionDir)
+call file_copy ecm-params.h.x64.intel ..\ecm-params.h
+call file_copy mul_fft-params.h.x64.intel ..\mul_fft-params.h
+call file_copy config.h ..\config.h
+</Command>
+    </PreBuildEvent>
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_WIN64;_DEBUG;_LIB;USE_ASM_REDC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <CompileAs>Default</CompileAs>
+    </ClCompile>
+    <Lib />
+    <Lib />
+    <YASM>
+      <Defines>_WIN64</Defines>
+    </YASM>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <YASM Include="..\assembler\mulredc.asm" />
+    <YASM Include="..\assembler\redc.asm" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxarith.c" />
+    <ClCompile Include="..\..\auxlib.c" />
+    <ClCompile Include="..\..\batch.c" />
+    <ClCompile Include="..\..\bestd.c" />
+    <ClCompile Include="..\..\ecm.c" />
+    <ClCompile Include="..\..\ecm2.c" />
+    <ClCompile Include="..\..\ecm_ntt.c" />
+    <ClCompile Include="..\..\ellparam_batch.c" />
+    <ClCompile Include="..\..\factor.c" />
+    <ClCompile Include="..\..\getprime.c" />
+    <ClCompile Include="..\..\ks-multiply.c" />
+    <ClCompile Include="..\..\listz.c" />
+    <ClCompile Include="..\..\lucas.c" />
+    <ClCompile Include="..\..\median.c" />
+    <ClCompile Include="..\..\mpmod.c" />
+    <ClCompile Include="..\..\mpzspm.c" />
+    <ClCompile Include="..\..\mpzspv.c" />
+    <ClCompile Include="..\..\mul_fft.c">
+      <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+      <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Full</Optimization>
+    </ClCompile>
+    <ClCompile Include="..\..\mul_lo.c" />
+    <ClCompile Include="..\..\ntt_gfp.c" />
+    <ClCompile Include="..\..\pm1.c" />
+    <ClCompile Include="..\..\pm1fs2.c" />
+    <ClCompile Include="..\..\polyeval.c" />
+    <ClCompile Include="..\..\pp1.c" />
+    <ClCompile Include="..\..\random.c" />
+    <ClCompile Include="..\..\rho.c" />
+    <ClCompile Include="..\..\schoen_strass.c" />
+    <ClCompile Include="..\..\sets_long.c" />
+    <ClCompile Include="..\..\sp.c">
+      <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Full</Optimization>
+    </ClCompile>
+    <ClCompile Include="..\..\spm.c">
+      <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Full</Optimization>
+    </ClCompile>
+    <ClCompile Include="..\..\spv.c">
+      <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Full</Optimization>
+    </ClCompile>
+    <ClCompile Include="..\..\stage2.c" />
+    <ClCompile Include="..\..\toomcook.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\champions.h" />
+    <ClInclude Include="..\config.h" />
+    <ClInclude Include="..\..\ecm-ecm.h" />
+    <ClInclude Include="..\..\ecm-gmp.h" />
+    <ClInclude Include="..\..\ecm-impl.h" />
+    <ClInclude Include="..\..\ecm-params.h" />
+    <ClInclude Include="..\..\ecm.h" />
+    <ClInclude Include="..\..\longlong.h" />
+    <ClInclude Include="..\..\sp.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+    <Import Project="..\vsyasm.targets" />
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/libecm/libecm.vcxproj.filters b/build.vc10/libecm/libecm.vcxproj.filters
new file mode 100644
index 0000000..2f8b80c
--- /dev/null
+++ b/build.vc10/libecm/libecm.vcxproj.filters
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Source Files\Assembler">
+      <UniqueIdentifier>{2f18179f-5dba-420c-8dc7-bc7f8228a1b2}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <YASM Include="..\assembler\mulredc.asm">
+      <Filter>Source Files\Assembler</Filter>
+    </YASM>
+    <YASM Include="..\assembler\redc.asm">
+      <Filter>Source Files\Assembler</Filter>
+    </YASM>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxarith.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\auxlib.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\bestd.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ecm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ecm2.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ecm_ntt.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\factor.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\getprime.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ks-multiply.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\listz.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\lucas.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\median.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpmod.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpzspm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpzspv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mul_fft.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mul_lo.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ntt_gfp.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\pm1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\pm1fs2.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\polyeval.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\pp1.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\random.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\rho.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\schoen_strass.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\sets_long.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\sp.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\spm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\spv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\stage2.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\toomcook.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\batch.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ellparam_batch.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-gmp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-impl.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-params.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\longlong.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\sp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\champions.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/mp_lib.props b/build.vc10/mp_lib.props
new file mode 100644
index 0000000..5478595
--- /dev/null
+++ b/build.vc10/mp_lib.props
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Label="UserMacros">
+    <mp_dir>mpir\</mp_dir>
+    <mp_lib>mpir.lib</mp_lib>
+  </PropertyGroup>
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <BuildMacro Include="mp_dir">
+      <Value>$(mp_dir)</Value>
+      <EnvironmentVariable>true</EnvironmentVariable>
+    </BuildMacro>
+    <BuildMacro Include="mp_lib">
+      <Value>$(mp_lib)</Value>
+      <EnvironmentVariable>true</EnvironmentVariable>
+    </BuildMacro>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc9/mul_fft-params.h.win32.amd b/build.vc10/mul_fft-params.h.win32.amd
similarity index 100%
rename from build.vc9/mul_fft-params.h.win32.amd
rename to build.vc10/mul_fft-params.h.win32.amd
diff --git a/build.vc9/mul_fft-params.h.win32.intel b/build.vc10/mul_fft-params.h.win32.intel
similarity index 100%
rename from build.vc9/mul_fft-params.h.win32.intel
rename to build.vc10/mul_fft-params.h.win32.intel
diff --git a/build.vc9/mul_fft-params.h.x64.amd b/build.vc10/mul_fft-params.h.x64.amd
similarity index 100%
rename from build.vc9/mul_fft-params.h.x64.amd
rename to build.vc10/mul_fft-params.h.x64.amd
diff --git a/build.vc9/mul_fft-params.h.x64.intel b/build.vc10/mul_fft-params.h.x64.intel
similarity index 100%
rename from build.vc9/mul_fft-params.h.x64.intel
rename to build.vc10/mul_fft-params.h.x64.intel
diff --git a/build.vc9/readme.txt b/build.vc10/readme.txt
similarity index 72%
rename from build.vc9/readme.txt
rename to build.vc10/readme.txt
index 36ce222..b0cb18a 100644
--- a/build.vc9/readme.txt
+++ b/build.vc10/readme.txt
@@ -1,5 +1,5 @@
 
-Building GMP-ECM with Microsoft Visual C++ 2008 (version 9)
+Building GMP-ECM with Microsoft Visual C++ 2010 (version 10)
 ===========================================================
 
 If you wish to build the assembler code support you will need to 
@@ -7,22 +7,16 @@ install the YASM assembler that is available at:
 
   http://www.tortall.net/projects/yasm/
 
-You should ensure that the binary is named yasm.exe and put it in 
-the same directory as your Visual C++ compiler, which is typically:
+THe version you need is vsyasm, which should be put it in the same
+directory as your Visual C++ compiler, which is typically:
 
-C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
+C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
 
-You also need to install the enclosed yasm.rules file in a suitable 
-path, for example:
-
-C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults
-
-so that it is recognised by the Visual Studio 2008 IDE.
 
 The Multi-Precision Library - GMP and MPIR
 ==========================================
 
-GMP-ECM works with either GMP or MPIR, a fork of GMP.  To build and run
+GMP-ECM works with either GMP or MPIR, a fork of GMP. To build and run
 GMP-ECM using Visual Studio you first need to obtain and build either 
 GMP or MPIR.   MPIR has a fully integrated Visual Studio build system
 for Windows but GMP does not.  
@@ -40,7 +34,7 @@ GMP can be built from the GMP source code available here:
   
 using the Visual Studio build files I provide here:
 
-  http://fp.gladman.plus.com/computing/gmp4win.htm 
+  http://www.gladman.me.uk/computing/gmp4win.php
   
 But these are based on GMP 4.2.x and are no longer being maintained.
 
@@ -71,17 +65,17 @@ are in a common parent directory as follows:
 
   Parent Directory
     MPIR (or GMP)
-      build.vc9    -- MPIR (or GMP) build files
+      build.vc10    -- MPIR (or GMP) build files
       ...
     GMP-ECM
-      buid.vc9	   -- ECM build files 
+      buid.vc10     -- ECM build files 
       
 The root directories for GMP and GMP-ECM are assumed to have these names
 irrespective of which version is being used (they used to be followed by 
 version numbers but this meant that the build projects had to be updated
 too frequently). 
 
-There are three build projects in build.vc9:
+There are three build projects in build.vc10:
 
     ecm     - the ECM application 
     ecmlib  - the ECM library
@@ -99,18 +93,27 @@ and each of these has the following configurations:
     x64\debug-intel     (not tune)
 
 When a version of ecm and ecmlib are built the library and the application
-are put in the directory matching the configuation that has been built:
+are put in the directory matching the configuration that has been built:
 
-   build.vc9\win32\release
-   build.vc9\win32\debug
-   build.vc9\x64\release
-   build.vc9\x64\debug
+    GMP-ECM
+      build.vc10    -- ECM build files 
+      lib           -- ECM static library files
+      dll           -- ECM dynamic library files
+      bin           -- ECM executable files
+      
+within these lib, dll and bin directories, the outputs are located in
+sub-directories determined by the platform and configuration:
+ 
+   win32\release
+   win32\debug
+   x64\release
+   x64\debug
 
 If you don't want assembler support you need to change the define:      
 
 #define NATIVE_REDC   1         
 
-in config.h (in the build.vc9 subdirectory) to: 
+in config.h (in the build.vc10 subdirectory) to: 
 
 #undef NATIVE_REDC
 
@@ -130,4 +133,5 @@ Tests
 The file tests.py is a python script that runs the ECM tests. It runs the
 x64/release-amd version by default but can be edited to test other builds.
 
-    Brian Gladman, 11th August 2009
+    Brian Gladman, 3rd January 2012
+
diff --git a/build.vc9/tests.py b/build.vc10/tests.py
similarity index 94%
rename from build.vc9/tests.py
rename to build.vc10/tests.py
index 65f5096..ba27f30 100644
--- a/build.vc9/tests.py
+++ b/build.vc10/tests.py
@@ -7,9 +7,14 @@ import platform
 from re import match
 from subprocess import Popen, PIPE, STDOUT
 from tempfile import *
+from time import clock
 
-test_dir = ".\\x64\\Release\\"
-# test_dir = ".\\win32\\Release\\"
+class Timer() :
+  def __enter__(self): self.start = clock()
+  def __exit__(self, *args): print(' time {:.3f} milliseconds'.format(1000 * (clock() - self.start)))
+
+test_dir = '..\\bin\\x64\\Release\\'
+# test_dir = '..\\bin\\win32\\Release\\'
 
 ecm = [
   ("2050449353925555290706354283", "-sigma 7 -k 1 30 0-1e6", 14),
@@ -162,16 +167,18 @@ def do_tests(tests) :
         if type(tt[2]) == int and rv[0] != tt[2] :
             print("*** ERROR ***", rv[0], tt[2])
         elif type(tt[2]) == tuple and \
-                 rv[0] != tt[2][0] and rv[0] != tt[2][2] :
+                 rv[0] != tt[2][0] and rv[0] != tt[2][1] :
             print("*** ERROR ***", rv[0], tt[2])
         if out :
             op = rv[1].rsplit('\r\n')
             for i in op :
                 print(i)
-out = True
-do_tests(ecm)
-do_tests(pm1)
-do_tests(pp1)
-do_tests(pp1_2)
-do_tests(c200)
-do_tests(test)
+
+with Timer():
+  out = True
+  do_tests(ecm)
+  do_tests(pm1)
+  do_tests(pp1)
+  do_tests(pp1_2)
+  do_tests(c200)
+  do_tests(test)
diff --git a/build.vc10/tune/Makefile.am b/build.vc10/tune/Makefile.am
new file mode 100644
index 0000000..fe8ca5e
--- /dev/null
+++ b/build.vc10/tune/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = tune.vcxproj tune.vcxproj.filters
diff --git a/build.vc9/ecm/Makefile.in b/build.vc10/tune/Makefile.in
similarity index 98%
rename from build.vc9/ecm/Makefile.in
rename to build.vc10/tune/Makefile.in
index 94b2f6a..fb74fd5 100644
--- a/build.vc9/ecm/Makefile.in
+++ b/build.vc10/tune/Makefile.in
@@ -33,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = build.vc9/ecm
+subdir = build.vc10/tune
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -175,7 +175,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = ecm.vcproj
+EXTRA_DIST = tune.vcxproj tune.vcxproj.filters
 all: all-am
 
 .SUFFIXES:
@@ -188,9 +188,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc9/ecm/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu build.vc10/tune/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu build.vc9/ecm/Makefile
+	  $(AUTOMAKE) --gnu build.vc10/tune/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
diff --git a/build.vc10/tune/tune.vcxproj b/build.vc10/tune/tune.vcxproj
new file mode 100644
index 0000000..f8386dd
--- /dev/null
+++ b/build.vc10/tune/tune.vcxproj
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{80E08750-5C6C-492E-BB1E-7200978AE125}</ProjectGuid>
+    <RootNamespace>tune</RootNamespace>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>Unicode</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+    <Import Project="..\vsyasm.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\mp_lib.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)..\bin\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <Optimization>MaxSpeed</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;TUNE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);%(AdditionalDependencies)</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+    <PostBuildEvent>
+      <Command>
+      </Command>
+    </PostBuildEvent>
+    <YASM>
+      <Defines>
+      </Defines>
+    </YASM>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>MaxSpeed</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\..\$(mp_dir)lib\$(IntDir);..\..\;..\assembler;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_CONSOLE;TUNE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>..\..\..\$(mp_dir)lib\$(IntDir)$(mp_lib);%(AdditionalDependencies)</AdditionalDependencies>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Console</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <TargetMachine>MachineX64</TargetMachine>
+    </Link>
+    <PostBuildEvent>
+      <Command>
+      </Command>
+    </PostBuildEvent>
+    <YASM>
+      <Defines>_WIN64</Defines>
+    </YASM>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <YASM Include="..\assembler\mulredc.asm" />
+    <YASM Include="..\assembler\redc.asm" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxarith.c" />
+    <ClCompile Include="..\..\auxlib.c" />
+    <ClCompile Include="..\..\ecm_ntt.c" />
+    <ClCompile Include="..\..\ks-multiply.c" />
+    <ClCompile Include="..\..\listz.c" />
+    <ClCompile Include="..\..\median.c" />
+    <ClCompile Include="..\..\mpmod.c">
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">TUNE_MULREDC_THRESH#0;TUNE_SQRREDC_THRESH#0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TUNE_MULREDC_THRESH#0;TUNE_SQRREDC_THRESH#0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <ClCompile Include="..\..\mpzspm.c" />
+    <ClCompile Include="..\..\mpzspv.c" />
+    <ClCompile Include="..\..\mul_fft.c" />
+    <ClCompile Include="..\..\mul_lo.c" />
+    <ClCompile Include="..\..\ntt_gfp.c" />
+    <ClCompile Include="..\..\polyeval.c" />
+    <ClCompile Include="..\..\random.c" />
+    <ClCompile Include="..\..\schoen_strass.c" />
+    <ClCompile Include="..\..\sp.c" />
+    <ClCompile Include="..\..\spm.c" />
+    <ClCompile Include="..\..\spv.c" />
+    <ClCompile Include="..\..\toomcook.c" />
+    <ClCompile Include="..\..\tune.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\ecm-params.h" />
+    <ClInclude Include="..\config.h" />
+    <ClInclude Include="..\..\ecm-ecm.h" />
+    <ClInclude Include="..\..\ecm-gmp.h" />
+    <ClInclude Include="..\..\ecm-impl.h" />
+    <ClInclude Include="..\..\ecm.h" />
+    <ClInclude Include="..\..\longlong.h" />
+    <ClInclude Include="..\..\sp.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\libecm\libecm.vcxproj">
+      <Project>{cd555681-d65b-4173-a29c-b8bf06a4871b}</Project>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+    <Import Project="..\vsyasm.targets" />
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/tune/tune.vcxproj.filters b/build.vc10/tune/tune.vcxproj.filters
new file mode 100644
index 0000000..b927f8c
--- /dev/null
+++ b/build.vc10/tune/tune.vcxproj.filters
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Source Files\Assembler">
+      <UniqueIdentifier>{38f1a18f-40fc-4eed-a68e-e79b58327b6c}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <YASM Include="..\assembler\mulredc.asm">
+      <Filter>Source Files\Assembler</Filter>
+    </YASM>
+    <YASM Include="..\assembler\redc.asm">
+      <Filter>Source Files\Assembler</Filter>
+    </YASM>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\auxarith.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\auxlib.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ecm_ntt.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ks-multiply.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\listz.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\median.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpmod.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpzspm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mpzspv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mul_fft.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\mul_lo.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\ntt_gfp.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\polyeval.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\random.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\schoen_strass.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\sp.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\spm.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\spv.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\toomcook.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\tune.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-gmp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-impl.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\longlong.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\sp.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\ecm-params.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/vsyasm.props b/build.vc10/vsyasm.props
new file mode 100644
index 0000000..66308c4
--- /dev/null
+++ b/build.vc10/vsyasm.props
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup
+    Condition="'$(YASMBeforeTargets)' == '' and '$(YASMAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
+    <YASMBeforeTargets>Midl</YASMBeforeTargets>
+    <YASMAfterTargets>CustomBuild</YASMAfterTargets>
+  </PropertyGroup>
+  <PropertyGroup>
+    <YASMDependsOn
+      Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(YASMDependsOn)</YASMDependsOn>
+  </PropertyGroup>
+  <PropertyGroup>
+    <YasmPath Condition= "'$(YASMPATH)' == ''">C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\</YasmPath>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <YASM>
+      <Debug>False</Debug>
+      <ObjectFile>$(IntDir)</ObjectFile>
+      <PreProc>0</PreProc>
+      <Parser>0</Parser>
+      <CommandLineTemplate>"$(YasmPath)"vsyasm.exe -Xvc -f $(Platform) [AllOptions] [AdditionalOptions] [Inputs]</CommandLineTemplate>
+      <Outputs>%(ObjectFile)</Outputs>
+      <ExecutionDescription>Assembling %(Filename)%(Extension)</ExecutionDescription>
+      <ShowOnlyRuleProperties>false</ShowOnlyRuleProperties>
+    </YASM>
+  </ItemDefinitionGroup>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/vsyasm.targets b/build.vc10/vsyasm.targets
new file mode 100644
index 0000000..c86180d
--- /dev/null
+++ b/build.vc10/vsyasm.targets
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <PropertyPageSchema
+      Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml" />
+    <AvailableItemName
+      Include="YASM">
+      <Targets>_YASM</Targets>
+    </AvailableItemName>
+  </ItemGroup>
+  <UsingTask
+    TaskName="YASM"
+    TaskFactory="XamlTaskFactory"
+    AssemblyName="Microsoft.Build.Tasks.v4.0">
+    <Task>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml</Task>
+  </UsingTask>
+  <Target
+    Name="_YASM"
+    BeforeTargets="$(YASMBeforeTargets)"
+    AfterTargets="$(YASMAfterTargets)"
+    Condition="'@(YASM)' != ''"
+    DependsOnTargets="$(YASMDependsOn);ComputeYASMOutput"
+    Outputs="@(YASM->'%(ObjectFile)')"
+    Inputs="@(YASM);%(YASM.AdditionalDependencies);$(MSBuildProjectFile)">
+    <ItemGroup
+      Condition="'@(SelectedFiles)' != ''">
+      <YASM
+        Remove="@(YASM)"
+        Condition="'%(Identity)' != '@(SelectedFiles)'" />
+    </ItemGroup>
+    <ItemGroup>
+      <YASM_tlog
+        Include="%(YASM.ObjectFile)"
+        Condition="'%(YASM.ObjectFile)' != '' and '%(YASM.ExcludedFromBuild)' != 'true'">
+        <Source>@(YASM, '|')</Source>
+      </YASM_tlog>
+    </ItemGroup>
+    <Message
+      Importance="High"
+      Text="%(YASM.ExecutionDescription)" />
+    <WriteLinesToFile
+      Condition="'@(YASM_tlog)' != '' and '%(YASM_tlog.ExcludedFromBuild)' != 'true'"
+      File="$(IntDir)$(ProjectName).write.1.tlog"
+      Lines="^%(YASM_tlog.Source);@(YASM_tlog->'%(Fullpath)')" />
+    <YASM
+      Condition="'@(YASM)' != '' and '%(YASM.ExcludedFromBuild)' != 'true'"
+      CommandLineTemplate="%(YASM.CommandLineTemplate)"
+      Debug="%(YASM.Debug)"
+      PreIncludeFile="%(YASM.PreIncludeFile)"
+      IncludePaths="%(YASM.IncludePaths)"
+      Defines="%(YASM.Defines)"
+      UnDefines="%(YASM.UnDefines)"
+      ObjectFile="%(YASM.ObjectFile)"
+      ListFile="%(YASM.ListFile)"
+      MapFile="%(YASM.MapFile)"
+      ErrorFile="%(YASM.ErrorFile)"
+      SymbolPrefix="%(YASM.SymbolPrefix)"
+      SymbolSuffix="%(YASM.SymbolSuffix)"
+      PreProc="%(YASM.PreProc)"
+      Parser="%(YASM.Parser)"
+      AdditionalOptions="%(YASM.AdditionalOptions)"
+      Inputs="@(YASM)" />
+  </Target>
+  <PropertyGroup>
+    <ComputeLinkInputsTargets>
+            $(ComputeLinkInputsTargets);
+            ComputeYASMOutput;
+          </ComputeLinkInputsTargets>
+    <ComputeLibInputsTargets>
+            $(ComputeLibInputsTargets);
+            ComputeYASMOutput;
+          </ComputeLibInputsTargets>
+  </PropertyGroup>
+  <Target
+    Name="ComputeYASMOutput"
+    Condition="'@(YASM)' != ''">
+    <ItemGroup>
+      <YASMDirsToMake
+        Condition="'@(YASM)' != '' and '%(YASM.ExcludedFromBuild)' != 'true' and !HasTrailingSlash('%(YASM.ObjectFile)')"
+        Include="%(YASM.ObjectFile)" />
+      <Link
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+      <Lib
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+      <ImpLib
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+    </ItemGroup>
+    <ItemGroup>
+      <YASMDirsToMake
+        Condition="'@(YASM)' != '' and '%(YASM.ExcludedFromBuild)' != 'true' and HasTrailingSlash('%(YASM.ObjectFile)')"
+        Include="@(YASM->'%(ObjectFile)%(Filename).obj')" />
+      <Link
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+      <Lib
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+      <ImpLib
+        Include="%(YASMDirsToMake.Identity)"
+        Condition="'%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib'" />
+    </ItemGroup>
+    <MakeDir
+      Directories="@(YASMDirsToMake->'%(RootDir)%(Directory)')" />
+  </Target>
+</Project>
\ No newline at end of file
diff --git a/build.vc10/vsyasm.xml b/build.vc10/vsyasm.xml
new file mode 100644
index 0000000..860bce8
--- /dev/null
+++ b/build.vc10/vsyasm.xml
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:transformCallback="Microsoft.Cpp.Dev10.ConvertPropertyCallback">
+  <Rule
+    Name="YASM"
+    PageTemplate="tool"
+    DisplayName="Yasm Assembler"
+    Order="200">
+      
+    <Rule.DataSource>
+      <DataSource
+        Persistence="ProjectFile"
+        ItemType="YASM" />
+    </Rule.DataSource>
+      
+    <Rule.Categories>
+        
+      <Category
+        Name="General">
+        <Category.DisplayName>
+          <sys:String>General</sys:String>
+        </Category.DisplayName>
+      </Category>
+
+      <Category
+        Name="Symbols">
+          <Category.DisplayName>
+              <sys:String>Symbols</sys:String>
+          </Category.DisplayName>
+      </Category>
+
+      <Category
+        Name="Files">
+          <Category.DisplayName>
+              <sys:String>Files</sys:String>
+          </Category.DisplayName>
+      </Category>
+        
+      <Category
+        Name="Command Line"
+        Subtype="CommandLine">
+        <Category.DisplayName>
+          <sys:String>Command Line</sys:String>
+        </Category.DisplayName>
+      </Category>
+        
+    </Rule.Categories>
+
+    <StringListProperty
+      Name="Inputs"
+      Category="Command Line"
+      IsRequired="true"
+      Switch=" ">
+      <StringListProperty.DataSource>
+        <DataSource
+          Persistence="ProjectFile"
+          ItemType="YASM"
+          SourceType="Item" />
+      </StringListProperty.DataSource>
+    </StringListProperty>
+    
+    <BoolProperty
+      Name="Debug"
+      Subcategory="Configuration"
+      HelpContext="0"
+      DisplayName="Debug Information"
+      Description="Generate debugging information"
+      Switch="-g cv8" />
+
+    <StringListProperty
+      Name="IncludePaths"
+      Subcategory="Configuration"
+      HelpContext="0"
+      DisplayName="Include Paths"
+      Description="Set the paths for any additional include files"
+      Switch="-i "[value]"" />
+
+    <StringListProperty
+      Name="Defines"
+      Category="Symbols"
+      Subcategory="Pre-Defined Symbols"
+      HelpContext="0"
+      DisplayName="Defined Symbols"
+      Description="Specify pre-defined symbols ('symbol' or 'symbol = value') "
+      Switch="-d "[value]"" />
+    
+    <StringListProperty
+      Name="UnDefines"
+      Category="Symbols"
+      Subcategory="Pre-Defined Symbols"
+      HelpContext="0"
+      DisplayName="Remove Symbols"
+      Description="Remove pre-defined symbols "
+      Switch="-u "[value]"" />
+    
+    <StringProperty
+      Name="ObjectFile"
+      Subcategory="Output"
+      HelpContext="0"
+      DisplayName="Object File Name"
+      Description="Select the output file name"
+      Switch="-o "[value]"" />
+    
+    <StringProperty
+      Name="ListFile"
+      Category="Files"
+      Subcategory="Output"
+      HelpContext="0"
+      DisplayName="List File Name"
+      Description="Select an output listing by setting its file name"
+      Switch="-l "[value]"" />
+    
+    <StringProperty
+      Name="PreIncludeFile"
+      Category="Files"
+      Subcategory="Configuration"
+      HelpContext="0"
+      DisplayName="Pre Include File"
+      Description="Select a pre-included file by setting its name"
+      Switch="-P "[value]"" />
+      
+    <StringProperty
+      Name="MapFile"
+      Category="Files"
+      Subcategory="Output"
+      HelpContext="0"
+      DisplayName="Map File Name"
+      Description="Select a map output by setting its file name"
+      Switch="--mapdir= "[value]"" />
+
+    <StringProperty
+      Name="ErrorFile"
+      Category="Files"
+      Subcategory="Output"
+      HelpContext="0"
+      DisplayName="Error File Name"
+      Description="Send error/warning messages to a file by setting its name"
+      Switch="-E "[value]"" />
+
+    <StringProperty
+      Name="SymbolPrefix"
+      Category="Symbols"
+      Subcategory="Symbols"
+      HelpContext="0"
+      DisplayName="External Symbol Prefix"
+      Description="Prepend symbol to all external symbols"
+      Switch="--prefix "[value]"" />
+
+    <StringProperty
+      Name="SymbolSuffix"
+      Category="Symbols"
+      Subcategory="Symbols"
+      HelpContext="0"
+      DisplayName="External Symbol Suffix"
+      Description="Append symbol to all external symbols"
+      Switch="--suffix "[value]"" />
+
+    <EnumProperty
+      Name="PreProc"
+      Subcategory="Configuration"
+      HelpContext="0"
+      DisplayName="Pre-Processor"
+      Description="Select the pre-processor ('nasm' or 'raw')">
+      <EnumValue
+        Name="0"
+        DisplayName="Nasm "
+        Switch="-rnasm" />
+      <EnumValue
+        Name="1"
+        DisplayName="Raw"
+        Switch="-rraw" />
+    </EnumProperty>
+    
+    <EnumProperty
+      Name="Parser"
+      Subcategory="Configuration"
+      HelpContext="0"
+      DisplayName="Parser"
+      Description="Select the parser for Intel ('nasm') or AT&T ( 'gas') syntax">
+      <EnumValue
+        Name="0"
+        DisplayName="Nasm"
+        Switch="-pnasm" />
+      <EnumValue
+        Name="1"
+        DisplayName="Gas"
+        Switch="-pgas" />
+    </EnumProperty>
+    
+    <StringProperty
+      Name="CommandLineTemplate"
+      DisplayName="Command Line"
+      Visible="False"
+      IncludeInCommandLine="False" />
+    
+    <DynamicEnumProperty
+      Name="YASMBeforeTargets"
+      Category="General"
+      EnumProvider="Targets"
+      IncludeInCommandLine="False">
+      <DynamicEnumProperty.DisplayName>
+        <sys:String>Execute Before</sys:String>
+      </DynamicEnumProperty.DisplayName>
+      <DynamicEnumProperty.Description>
+        <sys:String>Specifies the targets for the build customization to run before.</sys:String>
+      </DynamicEnumProperty.Description>
+      <DynamicEnumProperty.ProviderSettings>
+        <NameValuePair
+          Name="Exclude"
+          Value="^YASMBeforeTargets|^Compute" />
+      </DynamicEnumProperty.ProviderSettings>
+      <DynamicEnumProperty.DataSource>
+        <DataSource
+          Persistence="ProjectFile"
+          HasConfigurationCondition="true" />
+      </DynamicEnumProperty.DataSource>
+    </DynamicEnumProperty>
+    
+    <DynamicEnumProperty
+      Name="YASMAfterTargets"
+      Category="General"
+      EnumProvider="Targets"
+      IncludeInCommandLine="False">
+      <DynamicEnumProperty.DisplayName>
+        <sys:String>Execute After</sys:String>
+      </DynamicEnumProperty.DisplayName>
+      <DynamicEnumProperty.Description>
+        <sys:String>Specifies the targets for the build customization to run after.</sys:String>
+      </DynamicEnumProperty.Description>
+      <DynamicEnumProperty.ProviderSettings>
+        <NameValuePair
+          Name="Exclude"
+          Value="^YASMAfterTargets|^Compute" />
+      </DynamicEnumProperty.ProviderSettings>
+      <DynamicEnumProperty.DataSource>
+        <DataSource
+          Persistence="ProjectFile"
+          ItemType=""
+          HasConfigurationCondition="true" />
+      </DynamicEnumProperty.DataSource>
+    </DynamicEnumProperty>
+    
+    <StringListProperty
+      Name="Outputs"
+      DisplayName="Outputs"
+      Visible="False"
+      IncludeInCommandLine="False" />
+    
+    <StringProperty
+      Name="ExecutionDescription"
+      DisplayName="Execution Description"
+      Visible="False"
+      IncludeInCommandLine="False" />
+    
+    <StringListProperty
+      Name="AdditionalDependencies"
+      DisplayName="Additional Dependencies"
+      IncludeInCommandLine="False"
+      Visible="true" />
+    
+    <StringProperty
+      Subtype="AdditionalOptions"
+      Name="AdditionalOptions"
+      Category="Command Line">
+      <StringProperty.DisplayName>
+        <sys:String>Additional Options</sys:String>
+      </StringProperty.DisplayName>
+      <StringProperty.Description>
+        <sys:String>Additional Options</sys:String>
+      </StringProperty.Description>
+    </StringProperty>
+  </Rule>
+  
+  <ItemType
+    Name="YASM"
+    DisplayName="Yasm Assembler" />
+  <FileExtension
+    Name="*.asm"
+    ContentType="YASM" />
+  <ContentType
+    Name="YASM"
+    DisplayName="Yasm Assembler"
+    ItemType="YASM" />
+</ProjectSchemaDefinitions>
\ No newline at end of file
diff --git a/build.vc9/Makefile.am b/build.vc9/Makefile.am
deleted file mode 100644
index d5409be..0000000
--- a/build.vc9/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-EXTRA_DIST = config.h ecm-params.h ecm.sln file_copy.bat readme.txt \
-             tests.py yasm.rules ecm-params.h.win32.amd \
-             ecm-params.h.win32.intel ecm-params.h.x64.amd \
-             ecm-params.h.x64.intel mul_fft-params.h.win32.amd \
-             mul_fft-params.h.win32.intel mul_fft-params.h.x64.amd \
-             mul_fft-params.h.x64.intel mp_lib.vsprops 
-
-DIST_SUBDIRS = assembler ecm libecm tune
diff --git a/build.vc9/ecm-params.h b/build.vc9/ecm-params.h
deleted file mode 100644
index 9617fe5..0000000
--- a/build.vc9/ecm-params.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#define MPZMOD_THRESHOLD 93
-#define REDC_THRESHOLD 512
-#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 16
-#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
-#define MUL_NTT_THRESHOLD 262144
-#define PREREVERTDIVISION_NTT_THRESHOLD 64
-#define POLYINVERT_NTT_THRESHOLD 1024
-#define POLYEVALT_NTT_THRESHOLD 256
-#define MPZSPV_NORMALISE_STRIDE 64
diff --git a/build.vc9/ecm-params.h.win32.intel b/build.vc9/ecm-params.h.win32.intel
deleted file mode 100644
index 10a2d1e..0000000
--- a/build.vc9/ecm-params.h.win32.intel
+++ /dev/null
@@ -1,10 +0,0 @@
-#define MPZMOD_THRESHOLD 110
-#define REDC_THRESHOLD 512
-#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 7, 0, 1, 1, 1, 1, 12, 1, 12, 1, 1, 1, 1, 1, 1, 1, 13, 1, 1, 1, 1, 1}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 11
-#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 11
-#define MUL_NTT_THRESHOLD 512
-#define PREREVERTDIVISION_NTT_THRESHOLD 64
-#define POLYINVERT_NTT_THRESHOLD 512
-#define POLYEVALT_NTT_THRESHOLD 512
-#define MPZSPV_NORMALISE_STRIDE 256
diff --git a/build.vc9/ecm-params.h.x64.amd b/build.vc9/ecm-params.h.x64.amd
deleted file mode 100644
index be5abb4..0000000
--- a/build.vc9/ecm-params.h.x64.amd
+++ /dev/null
@@ -1,12 +0,0 @@
-#define TUNE_MULREDC_THRESH 16
-#define TUNE_SQRREDC_THRESH 11
-#define MPZMOD_THRESHOLD 128
-#define REDC_THRESHOLD 512
-#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 2, 1, 0, 4, 5, 0, 7, 9, 1, 1, 7, 11, 11, 1, 16, 1, 15, 16, 17, 16, 0, 17, 20, 22, 17, 16, 20, 15, 24}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 11
-#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 11
-#define MUL_NTT_THRESHOLD 256
-#define PREREVERTDIVISION_NTT_THRESHOLD 16
-#define POLYINVERT_NTT_THRESHOLD 256
-#define POLYEVALT_NTT_THRESHOLD 128
-#define MPZSPV_NORMALISE_STRIDE 128
diff --git a/build.vc9/ecm-params.h.x64.intel b/build.vc9/ecm-params.h.x64.intel
deleted file mode 100644
index 6ff9f8a..0000000
--- a/build.vc9/ecm-params.h.x64.intel
+++ /dev/null
@@ -1,22 +0,0 @@
-/* contributed by tom at womack dot net */
-
-/* things that were consistent */
-#define TUNE_MULREDC_THRESH 20
-#define TUNE_SQRREDC_THRESH 9
-#define PREREVERTDIVISION_NTT_THRESHOLD 16
-#define POLYINVERT_NTT_THRESHOLD 256
-#define POLYEVALT_NTT_THRESHOLD 256
-#define MUL_NTT_THRESHOLD 256
-
-/* things that are not granular (round to 250/500 ?) */
-#define MPZMOD_THRESHOLD 249 /* range 231-264 */
-#define REDC_THRESHOLD 506   /* range 505-509 */
-
-/* things that broke 2-3 */
-/* this came out as 256 twice */
-#define MPZSPV_NORMALISE_STRIDE 128
-
-/* the table (individual modes) */
-#define MPN_MUL_LO_THRESHOLD_TABLE {0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 11
-#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 11
diff --git a/build.vc9/ecm.sln b/build.vc9/ecm.sln
deleted file mode 100644
index 81c93dc..0000000
--- a/build.vc9/ecm.sln
+++ /dev/null
@@ -1,72 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libecm", "libecm\libecm.vcproj", "{CD555681-D65B-4173-A29C-B8BF06A4871B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecm", "ecm\ecm.vcproj", "{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}"
-	ProjectSection(ProjectDependencies) = postProject
-		{CD555681-D65B-4173-A29C-B8BF06A4871B} = {CD555681-D65B-4173-A29C-B8BF06A4871B}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tune", "tune\tune.vcproj", "{80E08750-5C6C-492E-BB1E-7200978AE125}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug-AMD|Win32 = Debug-AMD|Win32
-		Debug-AMD|x64 = Debug-AMD|x64
-		Debug-Intel|Win32 = Debug-Intel|Win32
-		Debug-Intel|x64 = Debug-Intel|x64
-		Release-AMD|Win32 = Release-AMD|Win32
-		Release-AMD|x64 = Release-AMD|x64
-		Release-Intel|Win32 = Release-Intel|Win32
-		Release-Intel|x64 = Release-Intel|x64
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-AMD|Win32.ActiveCfg = Debug-AMD|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-AMD|Win32.Build.0 = Debug-AMD|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-AMD|x64.ActiveCfg = Debug-AMD|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-AMD|x64.Build.0 = Debug-AMD|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-Intel|Win32.ActiveCfg = Debug-Intel|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-Intel|Win32.Build.0 = Debug-Intel|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-Intel|x64.ActiveCfg = Debug-Intel|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Debug-Intel|x64.Build.0 = Debug-Intel|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-AMD|Win32.ActiveCfg = Release-AMD|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-AMD|Win32.Build.0 = Release-AMD|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-AMD|x64.ActiveCfg = Release-AMD|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-AMD|x64.Build.0 = Release-AMD|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-Intel|Win32.ActiveCfg = Release-Intel|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-Intel|Win32.Build.0 = Release-Intel|Win32
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-Intel|x64.ActiveCfg = Release-Intel|x64
-		{CD555681-D65B-4173-A29C-B8BF06A4871B}.Release-Intel|x64.Build.0 = Release-Intel|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-AMD|Win32.ActiveCfg = Debug-AMD|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-AMD|Win32.Build.0 = Debug-AMD|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-AMD|x64.ActiveCfg = Debug-AMD|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-AMD|x64.Build.0 = Debug-AMD|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-Intel|Win32.ActiveCfg = Debug-Intel|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-Intel|Win32.Build.0 = Debug-Intel|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-Intel|x64.ActiveCfg = Debug-Intel|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Debug-Intel|x64.Build.0 = Debug-Intel|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-AMD|Win32.ActiveCfg = Release-AMD|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-AMD|Win32.Build.0 = Release-AMD|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-AMD|x64.ActiveCfg = Release-AMD|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-AMD|x64.Build.0 = Release-AMD|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-Intel|Win32.ActiveCfg = Release-Intel|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-Intel|Win32.Build.0 = Release-Intel|Win32
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-Intel|x64.ActiveCfg = Release-Intel|x64
-		{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}.Release-Intel|x64.Build.0 = Release-Intel|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug-AMD|Win32.ActiveCfg = Release-AMD|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug-AMD|x64.ActiveCfg = Release-AMD|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug-Intel|Win32.ActiveCfg = Release-Intel|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Debug-Intel|x64.ActiveCfg = Release-Intel|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-AMD|Win32.ActiveCfg = Release-AMD|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-AMD|Win32.Build.0 = Release-AMD|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-AMD|x64.ActiveCfg = Release-AMD|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-AMD|x64.Build.0 = Release-AMD|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-Intel|Win32.ActiveCfg = Release-Intel|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-Intel|Win32.Build.0 = Release-Intel|Win32
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-Intel|x64.ActiveCfg = Release-Intel|x64
-		{80E08750-5C6C-492E-BB1E-7200978AE125}.Release-Intel|x64.Build.0 = Release-Intel|x64
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/build.vc9/ecm/Makefile.am b/build.vc9/ecm/Makefile.am
deleted file mode 100644
index 5ab6211..0000000
--- a/build.vc9/ecm/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = ecm.vcproj
diff --git a/build.vc9/ecm/ecm.vcproj b/build.vc9/ecm/ecm.vcproj
deleted file mode 100644
index 20283ab..0000000
--- a/build.vc9/ecm/ecm.vcproj
+++ /dev/null
@@ -1,733 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9.00"
-	Name="ecm"
-	ProjectGUID="{C0E2EA85-996A-4B5F-AD30-590FAF5B7187}"
-	RootNamespace="ecm"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="131072"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-		<Platform
-			Name="x64"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug-AMD|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\debug\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="2"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-AMD|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_WIN64;_DEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\debug\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="2"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-AMD|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-AMD|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_WIN64;NDEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-Intel|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-Intel|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_WIN64;NDEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-Intel|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\debug\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="2"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-Intel|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=""..\..\..\$(mp_lib)""
-				PreprocessorDefinitions="WIN32;_WIN64;_DEBUG;_CONSOLE;OUTSIDE_LIBECM"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib ..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\debug\$(mp_lib).lib"
-				OutputFile="$(OutDir)\ecm.exe"
-				LinkIncremental="2"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\..\auxi.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\b1_ainc.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\candi.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\eval.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\getprime.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\main.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\random.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\resume.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\trial.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath="..\..\config.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-ecm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-gmp.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-impl.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/build.vc9/libecm/Makefile.am b/build.vc9/libecm/Makefile.am
deleted file mode 100644
index 5fddceb..0000000
--- a/build.vc9/libecm/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = libecm.vcproj
diff --git a/build.vc9/libecm/libecm.vcproj b/build.vc9/libecm/libecm.vcproj
deleted file mode 100644
index 530af06..0000000
--- a/build.vc9/libecm/libecm.vcproj
+++ /dev/null
@@ -1,1192 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9.00"
-	Name="libecm"
-	ProjectGUID="{CD555681-D65B-4173-A29C-B8BF06A4871B}"
-	RootNamespace="libecm"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="131072"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-		<Platform
-			Name="x64"
-		/>
-	</Platforms>
-	<ToolFiles>
-		<DefaultToolFile
-			FileName="yasm.rules"
-		/>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release-AMD|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.win32.amd ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.win32.amd ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;SSE2"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-AMD|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.x64.amd ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.x64.amd ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-Intel|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.win32.intel ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.win32.intel ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;SSE2"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-Intel|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.x64.intel ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.x64.intel ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-AMD|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.win32.amd ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.win32.amd ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;SSE2"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-AMD|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.x64.amd ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.x64.amd ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-Intel|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.win32.intel ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.win32.intel ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;SSE2"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Debug-Intel|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Debug"
-			IntermediateDirectory="$(PlatformName)\Debug"
-			ConfigurationType="4"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\mp_lib.vsprops"
-			CharacterSet="2"
-			EnableManagedIncrementalBuild="0"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				CommandLine="cd $(SolutionDir)&#x0D;&#x0A;call file_copy ecm-params.h.x64.intel ..\ecm-params.h&#x0D;&#x0A;call file_copy mul_fft-params.h.x64.intel ..\mul_fft-params.h&#x0D;&#x0A;call file_copy config.h ..\config.h&#x0D;&#x0A;"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-				CompileAs="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\ecm.lib"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\assembler\a_win32a_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32a_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32p_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32p_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_x64_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_x64_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-AMD|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug-Intel|x64"
-					>
-					<Tool
-						Name="YASM"
-						Debug="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\auxarith.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\auxlib.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\bestd.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm2.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm_ntt.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\factor.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\getprime.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ks-multiply.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\listz.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\lucas.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\median.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpmod.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpzspm.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpzspv.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mul_fft.c"
-				>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="2"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\mul_lo.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ntt_gfp.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\pm1.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\pm1fs2.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\polyeval.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\pp1.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\random.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\rho.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\schoen_strass.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\sets_long.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\sp.c"
-				>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\spm.c"
-				>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\spv.c"
-				>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						Optimization="3"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\stage2.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\toomcook.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath="..\config.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-ecm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-gmp.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-impl.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-params.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\longlong.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\sp.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/build.vc9/mp_lib.vsprops b/build.vc9/mp_lib.vsprops
deleted file mode 100644
index 546bb77..0000000
--- a/build.vc9/mp_lib.vsprops
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioPropertySheet
-	ProjectType="Visual C++"
-	Version="8.00"
-	Name="mp_lib"
-	>
-	<UserMacro
-		Name="mp_lib"
-		Value="mpir"
-		InheritsFromParent="true"
-		Delimiter=";"
-		PerformEnvironmentSet="true"
-	/>
-</VisualStudioPropertySheet>
diff --git a/build.vc9/tune/Makefile.am b/build.vc9/tune/Makefile.am
deleted file mode 100644
index 5dd93ad..0000000
--- a/build.vc9/tune/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = tune.vcproj
diff --git a/build.vc9/tune/tune.vcproj b/build.vc9/tune/tune.vcproj
deleted file mode 100644
index 37699b8..0000000
--- a/build.vc9/tune/tune.vcproj
+++ /dev/null
@@ -1,646 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9.00"
-	Name="tune"
-	ProjectGUID="{80E08750-5C6C-492E-BB1E-7200978AE125}"
-	RootNamespace="tune"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="196613"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-		<Platform
-			Name="x64"
-		/>
-	</Platforms>
-	<ToolFiles>
-		<DefaultToolFile
-			FileName="yasm.rules"
-		/>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Release-Intel|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="..\mp_lib.vsprops"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TUNE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine=""$(TargetPath)" >..\ecm-params.h.win32.intel.new"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-Intel|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="..\mp_lib.vsprops"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TUNE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine=""$(TargetPath)" >..\ecm-params.h.x64.intel.new"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-AMD|Win32"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="..\mp_lib.vsprops"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TUNE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine=""$(TargetPath)" >..\ecm-params.h.win32.amd.new"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release-AMD|x64"
-			OutputDirectory="$(SolutionDir)$(PlatformName)\Release"
-			IntermediateDirectory="$(PlatformName)\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="..\mp_lib.vsprops"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="YASM"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TargetEnvironment="3"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				AdditionalIncludeDirectories="..\..\;..\..\..\$(mp_lib);..\assembler"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;TUNE"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="..\..\..\$(mp_lib)\build.vc9\lib\$(PlatformName)\release\$(mp_lib).lib"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="17"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-				CommandLine=""$(TargetPath)" >..\ecm-params.h.x64.amd.new"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\assembler\a_win32a_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32a_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32p_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_win32p_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-						Defines="true"
-						IncludePaths="true"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_x64_mulredc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\assembler\a_x64_redc.asm"
-				>
-				<FileConfiguration
-					Name="Release-Intel|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release-AMD|Win32"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="YASM"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\auxarith.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\auxlib.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm_ntt.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ks-multiply.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\listz.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\median.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpmod.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpzspm.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mpzspv.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mul_fft.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\mul_lo.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ntt_gfp.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\polyeval.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\random.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\schoen_strass.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\sp.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\spm.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\spv.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\toomcook.c"
-				>
-			</File>
-			<File
-				RelativePath="..\..\tune.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath="..\config.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-ecm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-gmp.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm-impl.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\ecm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\longlong.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\sp.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
diff --git a/build.vc9/yasm.rules b/build.vc9/yasm.rules
deleted file mode 100644
index f2e2ecc..0000000
--- a/build.vc9/yasm.rules
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<VisualStudioToolFile
-	Name="Yasm"
-	Version="8.00"
-	>
-	<Rules>
-		<CustomBuildRule
-			Name="YASM"
-			DisplayName="Yasm Assembler"
-			CommandLine="yasm -Xvc -f $(PlatformName) [AllOptions] [AdditionalOptions] [Inputs]"
-			Outputs="[$ObjectFileName]"
-			FileExtensions="*.asm"
-			ExecutionDescription="Assembling $(InputFileName)"
-			ShowOnlyRuleProperties="false"
-			>
-			<Properties>
-				<StringProperty
-					Name="Defines"
-					DisplayName="Definitions"
-					Category="Pre-Defined Symbols"
-					Description="Specify pre-defined symbols ('symbol' or 'symbol = value') "
-					Switch="-D [value]"
-					Delimited="true"
-					Inheritable="true"
-				/>
-				<StringProperty
-					Name="IncludePaths"
-					DisplayName="Include Paths"
-					Category="Configuration"
-					Description="Set the paths for any additional include files"
-					Switch="-i "[value]""
-					Delimited="true"
-					Inheritable="true"
-				/>
-				<StringProperty
-					Name="UnDefines"
-					DisplayName="Remove Definitions"
-					Category="Pre-Defined Symbols"
-					Description="Remove pre-defined symbols "
-					Switch="-u [value]"
-					Delimited="true"
-					Inheritable="true"
-				/>
-				<StringProperty
-					Name="ObjectFileName"
-					DisplayName="Object File Name"
-					Category="Output"
-					Description="Select the output file name"
-					Switch="-o "[value]""
-					DefaultValue=""$(IntDir)\$(InputName).obj""
-				/>
-				<StringProperty
-					Name="ListFileName"
-					DisplayName="List File Name"
-					Category="Output"
-					Description="Select an output listing by setting its file name"
-					Switch="-l "[value]""
-				/>
-				<StringProperty
-					Name="PreIncludeFile"
-					DisplayName="Pre Include File"
-					Category="Configuration"
-					Description="Select a pre-included file by setting its name"
-					Switch="-P "[value]""
-				/>
-				<BooleanProperty
-					Name="Debug"
-					DisplayName="Debug Information"
-					Category="Output"
-					Description="Generate debugging information"
-					Switch="-g cv8"
-				/>
-				<EnumProperty
-					Name="PreProc"
-					DisplayName="Pre-Processor"
-					Category="Configuration"
-					Description="Select the pre-processor ('nasm' or 'raw')"
-					>
-					<Values>
-						<EnumValue
-							Value="0"
-							Switch="-rnasm"
-							DisplayName="Nasm "
-						/>
-						<EnumValue
-							Value="1"
-							Switch="-rraw"
-							DisplayName="Raw"
-						/>
-					</Values>
-				</EnumProperty>
-				<EnumProperty
-					Name="Parser"
-					DisplayName="Parser"
-					Category="Configuration"
-					Description="Select the parser for Intel ('nasm') or AT&T ( 'gas') syntax"
-					>
-					<Values>
-						<EnumValue
-							Value="0"
-							Switch="-pnasm"
-							DisplayName="Nasm"
-						/>
-						<EnumValue
-							Value="1"
-							Switch="-pgas"
-							DisplayName="Gas"
-						/>
-					</Values>
-				</EnumProperty>
-			</Properties>
-		</CustomBuildRule>
-	</Rules>
-</VisualStudioToolFile>
diff --git a/config.h.in b/config.h.in
index 292ed61..508f5ef 100644
--- a/config.h.in
+++ b/config.h.in
@@ -39,12 +39,6 @@
 /* Define to 1 if you have the `fileno' function. */
 #undef HAVE_FILENO
 
-/* Define to 1 if you have the `floor' function. */
-#undef HAVE_FLOOR
-
-/* Define to 1 if you have the `fmod' function. */
-#undef HAVE_FMOD
-
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
 
@@ -111,15 +105,12 @@
 /* Define to 1 if you have the `memset' function. */
 #undef HAVE_MEMSET
 
-/* Define to 1 if you have the `mpn_sqr' function. */
-#undef HAVE_MPN_SQR
+/* Define to 1 if GMP is MPIR */
+#undef HAVE_MPIR
 
 /* Define to 1 if you have the `nice' function. */
 #undef HAVE_NICE
 
-/* Define to 1 if you have the `pow' function. */
-#undef HAVE_POW
-
 /* Define to 1 if you have the `setpriority' function. */
 #undef HAVE_SETPRIORITY
 
@@ -129,9 +120,6 @@
 /* Define to 1 if you have the <signal.h> header file. */
 #undef HAVE_SIGNAL_H
 
-/* Define to 1 if you have the `sqrt' function. */
-#undef HAVE_SQRT
-
 /* Define to 1 to enable SSE2 instructions in NTT code */
 #undef HAVE_SSE2
 
@@ -198,6 +186,9 @@
 /* Define to 1 if you have the `__gmpn_redc_2' function. */
 #undef HAVE___GMPN_REDC_2
 
+/* Define to 1 if you have the `__gmpn_redc_n' function. */
+#undef HAVE___GMPN_REDC_N
+
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
@@ -205,6 +196,9 @@
 /* Define to 1 if you want memory debugging */
 #undef MEMORY_DEBUG
 
+/* Define to 1 if you want Svoboda mulredc */
+#undef MULREDC_SVOBODA
+
 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
 #undef NO_MINUS_C_MINUS_O
 
@@ -255,8 +249,8 @@
 /* Define to 1 if you want shell command execution */
 #undef WANT_SHELLCMD
 
-/* Define to 1 if x86_64 ecm_redc3() and mulredc*() functions should be called
-   with Windows ABI */
+/* Define to 1 if x86_64 mulredc*() functions should be called with Windows
+   ABI */
 #undef WINDOWS64_ABI
 
 /* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
diff --git a/configure b/configure
index 1982001..29d30b9 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for ecm 6.4.
+# Generated by GNU Autoconf 2.68 for ecm 6.4.1-rc2.
 #
 # Report bugs to <ecm-discuss at lists.gforge.inria.fr>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ecm'
 PACKAGE_TARNAME='ecm'
-PACKAGE_VERSION='6.4'
-PACKAGE_STRING='ecm 6.4'
+PACKAGE_VERSION='6.4.1-rc2'
+PACKAGE_STRING='ecm 6.4.1-rc2'
 PACKAGE_BUGREPORT='ecm-discuss at lists.gforge.inria.fr'
 PACKAGE_URL=''
 
@@ -760,6 +760,7 @@ enable_openmp
 enable_sse2
 enable_asm_redc
 enable_memory_debug
+enable_mulredc_svoboda
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1323,7 +1324,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ecm 6.4 to adapt to many kinds of systems.
+\`configure' configures ecm 6.4.1-rc2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1393,7 +1394,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ecm 6.4:";;
+     short | recursive ) echo "Configuration of ecm 6.4.1-rc2:";;
    esac
   cat <<\_ACEOF
 
@@ -1410,6 +1411,8 @@ Optional Features:
   --enable-asm-redc       use an asm redc (default=yes on x86_64 and
                           powerpc64, no on others)
   --enable-memory-debug   enable memory debugging [[default=no]]
+  --enable-mulredc-svoboda
+                          enable Svoboda mulredc [[default=no]]
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --enable-shared[=PKGS]  build shared libraries [default=no]
@@ -1511,7 +1514,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ecm configure 6.4
+ecm configure 6.4.1-rc2
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2061,7 +2064,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ecm $as_me 6.4, which was
+It was created by ecm $as_me 6.4.1-rc2, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2885,7 +2888,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ecm'
- VERSION='6.4'
+ VERSION='6.4.1-rc2'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2947,7 +2950,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=ecm
- VERSION=6.4
+ VERSION=6.4.1-rc2
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3314,7 +3317,7 @@ fi
 if test "${enable_assert+set}" = set; then :
   enableval=$enable_assert;
 else
-  enable_assert=np
+  enable_assert=no
 fi
 
 if test "x$enable_assert" = xyes; then
@@ -3382,6 +3385,20 @@ else
 fi
 
 
+# Check whether --enable-mulredc-svoboda was given.
+if test "${enable_mulredc_svoboda+set}" = set; then :
+  enableval=$enable_mulredc_svoboda;
+fi
+
+if test "x$enable_mulredc_svoboda" = xyes; then
+
+$as_echo "#define MULREDC_SVOBODA 1" >>confdefs.h
+
+
+echo 'define(<MULREDC_SVOBODA>, <1>)' >>$gmp_tmpconfigm4
+
+fi
+
 
 
 ac_ext=c
@@ -13529,6 +13546,194 @@ fi
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5
+$as_echo_n "checking for pow in -lm... " >&6; }
+if ${ac_cv_lib_m_pow+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pow ();
+int
+main ()
+{
+return pow ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_m_pow=yes
+else
+  ac_cv_lib_m_pow=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5
+$as_echo "$ac_cv_lib_m_pow" >&6; }
+if test "x$ac_cv_lib_m_pow" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+else
+  as_fn_error $? "required function missing" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for floor in -lm" >&5
+$as_echo_n "checking for floor in -lm... " >&6; }
+if ${ac_cv_lib_m_floor+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char floor ();
+int
+main ()
+{
+return floor ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_m_floor=yes
+else
+  ac_cv_lib_m_floor=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_floor" >&5
+$as_echo "$ac_cv_lib_m_floor" >&6; }
+if test "x$ac_cv_lib_m_floor" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+else
+  as_fn_error $? "required function missing" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5
+$as_echo_n "checking for sqrt in -lm... " >&6; }
+if ${ac_cv_lib_m_sqrt+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sqrt ();
+int
+main ()
+{
+return sqrt ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_m_sqrt=yes
+else
+  ac_cv_lib_m_sqrt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sqrt" >&5
+$as_echo "$ac_cv_lib_m_sqrt" >&6; }
+if test "x$ac_cv_lib_m_sqrt" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+else
+  as_fn_error $? "required function missing" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmod in -lm" >&5
+$as_echo_n "checking for fmod in -lm... " >&6; }
+if ${ac_cv_lib_m_fmod+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char fmod ();
+int
+main ()
+{
+return fmod ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_m_fmod=yes
+else
+  ac_cv_lib_m_fmod=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_fmod" >&5
+$as_echo "$ac_cv_lib_m_fmod" >&6; }
+if test "x$ac_cv_lib_m_fmod" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBM 1
+_ACEOF
+
+  LIBS="-lm $LIBS"
+
+else
+  as_fn_error $? "required function missing" "$LINENO" 5
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5
 $as_echo_n "checking for cos in -lm... " >&6; }
 if ${ac_cv_lib_m_cos+:} false; then :
@@ -13574,6 +13779,7 @@ _ACEOF
 
 fi
 
+
 GSL_LD_FLAGS=
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cblas_dgemm in -lgslcblas" >&5
 $as_echo_n "checking for cblas_dgemm in -lgslcblas... " >&6; }
@@ -13661,20 +13867,6 @@ fi
 fi
 
 
-for ac_func in floor sqrt pow fmod
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  as_fn_error $? "required function missing" "$LINENO" 5
-fi
-done
-
 for ac_func in isascii memset strchr strlen strncasecmp strstr
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -13804,7 +13996,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 #include <gmp.h>
-#if (__GNU_MP_VERSION < 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR < 1))
+#if (__GNU_MP_VERSION <= 4)
 #error
 #IRIXdoesnotexitaterrordirective
 #endif
@@ -13816,7 +14008,26 @@ $as_echo "yes" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-   as_fn_error $? "GMP 4.1.0 or newer is required" "$LINENO" 5
+   as_fn_error $? "GMP 5.0.0 or newer is required" "$LINENO" 5
+
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPIR" >&5
+$as_echo_n "checking for MPIR... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <gmp.h>
+#ifndef __MPIR_VERSION
+#error
+#IRIXdoesnotexitaterrordirective
+#endif
+
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+$as_echo "#define HAVE_MPIR 1" >>confdefs.h
 
 fi
 rm -f conftest.err conftest.i conftest.$ac_ext
@@ -13931,54 +14142,19 @@ _ACEOF
 fi
 done
 
-for ac_func in __gmpn_mullo_n
+for ac_func in __gmpn_mullo_n __gmpn_redc_n
 do :
-  ac_fn_c_check_func "$LINENO" "__gmpn_mullo_n" "ac_cv_func___gmpn_mullo_n"
-if test "x$ac_cv_func___gmpn_mullo_n" = xyes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE___GMPN_MULLO_N 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
 done
 
 
-# mpn_sqr() is renamed to __gmpn_sqr() in GMP 5.0.x, but may not be
-# in future versions. AC_CHECK_FUNCS() does not allow including header
-# files. Thus, a custom test for mpn_sqr()
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpn_sqr" >&5
-$as_echo_n "checking for mpn_sqr... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifdef HAVE_GMP_H
-#include <gmp.h>
-#endif
-int
-main ()
-{
-
-  mpn_sqr ((mp_ptr) 0, (mp_ptr) 0, (mp_size_t) 0);
-  return 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define HAVE_MPN_SQR 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
 LIBS="$LIBS_BACKUP"
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler knows __attribute__((hot))" >&5
@@ -14144,6 +14320,8 @@ if test x"$config_arch" = xathlon64; then
   if test -f /proc/cpuinfo; then
     if $EGREP -q "Core\(TM\)2" /proc/cpuinfo; then
       config_arch=core2
+    elif $EGREP -q "Core\(TM\) i5" /proc/cpuinfo; then
+      config_arch=corei5
     fi;
   else
     # No /proc/cpuinfo, tell user about ecm-params.h.core2
@@ -14189,7 +14367,7 @@ fi
 echo "')" >> $gmp_configm4
 echo "define(\`__CONFIG_M4_INCLUDED__')" >> $gmp_configm4
 
-ac_config_files="$ac_config_files Makefile athlon/Makefile pentium4/Makefile x86_64/Makefile powerpc64/Makefile build.vc9/Makefile build.vc9/assembler/Makefile build.vc9/ecm/Makefile build.vc9/libecm/Makefile build.vc9/tune/Makefile"
+ac_config_files="$ac_config_files Makefile athlon/Makefile pentium4/Makefile x86_64/Makefile powerpc64/Makefile build.vc10/Makefile build.vc10/assembler/Makefile build.vc10/ecm/Makefile build.vc10/libecm/Makefile build.vc10/tune/Makefile build.vc10/bench_mulredc/Makefile"
 
 ac_config_links="$ac_config_links ecm-params.h:ecm-params.h.$config_arch"
 
@@ -14771,7 +14949,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ecm $as_me 6.4, which was
+This file was extended by ecm $as_me 6.4.1-rc2, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14841,7 +15019,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ecm config.status 6.4
+ecm config.status 6.4.1-rc2
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
@@ -15255,11 +15433,12 @@ do
     "pentium4/Makefile") CONFIG_FILES="$CONFIG_FILES pentium4/Makefile" ;;
     "x86_64/Makefile") CONFIG_FILES="$CONFIG_FILES x86_64/Makefile" ;;
     "powerpc64/Makefile") CONFIG_FILES="$CONFIG_FILES powerpc64/Makefile" ;;
-    "build.vc9/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc9/Makefile" ;;
-    "build.vc9/assembler/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc9/assembler/Makefile" ;;
-    "build.vc9/ecm/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc9/ecm/Makefile" ;;
-    "build.vc9/libecm/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc9/libecm/Makefile" ;;
-    "build.vc9/tune/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc9/tune/Makefile" ;;
+    "build.vc10/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/Makefile" ;;
+    "build.vc10/assembler/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/assembler/Makefile" ;;
+    "build.vc10/ecm/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/ecm/Makefile" ;;
+    "build.vc10/libecm/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/libecm/Makefile" ;;
+    "build.vc10/tune/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/tune/Makefile" ;;
+    "build.vc10/bench_mulredc/Makefile") CONFIG_FILES="$CONFIG_FILES build.vc10/bench_mulredc/Makefile" ;;
     "ecm-params.h") CONFIG_LINKS="$CONFIG_LINKS ecm-params.h:ecm-params.h.$config_arch" ;;
     "mul_fft-params.h") CONFIG_LINKS="$CONFIG_LINKS mul_fft-params.h:"$MUL_FFT_PARAMS"" ;;
 
diff --git a/configure.in b/configure.in
index 36ad164..b292ce3 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-m4_define([ECM_VERSION], [6.4])
+m4_define([ECM_VERSION], [6.4.1-rc2])
 
 AC_PREREQ([2.57])
 AC_INIT([ecm], ECM_VERSION, [ecm-discuss at lists.gforge.inria.fr])
@@ -47,9 +47,9 @@ fi
 ############################
 
 dnl Assertions are enabled by default for beta/rc releases. The last parameter
-dnl of AC_ARG_ENABLE() sets the default value.
+dnl of AC_ARG_ENABLE() sets the default value (change also default=...).
 AC_ARG_ENABLE([assert],
-[AS_HELP_STRING([--enable-assert], [enable ASSERT checking [[default=no]]])],[],[enable_assert=np])
+[AS_HELP_STRING([--enable-assert], [enable ASSERT checking [[default=no]]])],[],[enable_assert=no])
 if test "x$enable_assert" = xyes; then
   AC_DEFINE([WANT_ASSERT],1,[Define to 1 if you want assertions enabled])
   GMP_DEFINE([WANT_ASSERT], 1)
@@ -80,6 +80,13 @@ if test "x$enable_memory_debug" = xyes; then
 fi
 AM_CONDITIONAL([MEMORY_DEBUG], [test "x$enable_memory_debug" = xyes])
 
+AC_ARG_ENABLE([mulredc-svoboda],
+[AS_HELP_STRING([--enable-mulredc-svoboda], [enable Svoboda mulredc [[default=no]]])])
+if test "x$enable_mulredc_svoboda" = xyes; then
+  AC_DEFINE([MULREDC_SVOBODA],1,[Define to 1 if you want Svoboda mulredc])
+  GMP_DEFINE([MULREDC_SVOBODA], 1)
+fi
+
 
 
 dnl Use C language for test programs
@@ -250,7 +257,7 @@ if test "x$enable_asm_redc" = xyes; then
 
   case $host in
     *-*-mingw32) GMP_DEFINE([WINDOWS64_ABI], 1)
-                 AC_DEFINE([WINDOWS64_ABI], 1,[Define to 1 if x86_64 ecm_redc3() and mulredc*() functions should be called with Windows ABI]);;
+                 AC_DEFINE([WINDOWS64_ABI], 1,[Define to 1 if x86_64 mulredc*() functions should be called with Windows ABI]);;
     *) ;;
   esac
 
@@ -361,10 +368,16 @@ AC_CHECK_HEADERS([ctype.h sys/types.h sys/resource.h])
 dnl Checks for library functions that are not in GMP
 AC_FUNC_STRTOD
 
+dnl Check functions in the math library
+AC_CHECK_LIB(m,pow,,AC_MSG_ERROR(required function missing))
+AC_CHECK_LIB(m,floor,,AC_MSG_ERROR(required function missing))
+AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR(required function missing))
+AC_CHECK_LIB(m,fmod,,AC_MSG_ERROR(required function missing))
+AC_CHECK_LIB(m,cos)
+
 dnl Check for GSL but don't add it to LIBS, since only rho uses it and
 dnl we don't want all other binaries to depend on it. 
 dnl If found, pass link flags to Makefile via GSL_LD_FLAGS
-AC_CHECK_LIB([m],[cos])
 GSL_LD_FLAGS=
 dnl Check if "-lgslcblas" works. If yes, check if "-lgsl -lgslcblas" works.
 dnl If both work, put "-lgsl -lgslcblas" in GSL_LD_FLAGS
@@ -376,7 +389,6 @@ AC_CHECK_LIB([gslcblas],[cblas_dgemm], dnl
    dnl Here comes the "OTHER-LIBRARIES" field for AC_CHECK_LIB [gsl]:
    [-lgslcblas])])
 
-AC_CHECK_FUNCS([floor sqrt pow fmod], [], [AC_MSG_ERROR([required function missing])])
 AC_CHECK_FUNCS([isascii memset strchr strlen strncasecmp strstr], [], [AC_MSG_ERROR([required function missing])])
 AC_CHECK_FUNCS([access unlink], [], [AC_MSG_ERROR([required function missing])])
 AC_CHECK_FUNCS([isspace isdigit isxdigit], [], [AC_MSG_ERROR([required function missing])])
@@ -426,16 +438,27 @@ dnl we start looking for libgmp.a
 AC_MSG_CHECKING([for recent GMP])
 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
 #include <gmp.h>
-#if (__GNU_MP_VERSION < 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR < 1))
+#if (__GNU_MP_VERSION <= 4)
 #error
 #IRIXdoesnotexitaterrordirective
 #endif
 ]])],
   [AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
-   AC_MSG_ERROR([GMP 4.1.0 or newer is required])]
+   AC_MSG_ERROR([GMP 5.0.0 or newer is required])]
 )
 
+dnl Figure out if GMP is MPIR
+AC_MSG_CHECKING([for MPIR])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
+#include <gmp.h>
+#ifndef __MPIR_VERSION
+#error
+#IRIXdoesnotexitaterrordirective
+#endif
+]])],
+  [AC_DEFINE([HAVE_MPIR],1,[Define to 1 if GMP is MPIR])])
+
 dnl Now choose how to link the GMP library. If we can, we'd prefer to
 dnl link it statically since that makes for faster function calls. To
 dnl link it statically, we mustn't build a dynamic GMP-ECM library and
@@ -510,22 +533,7 @@ return strcmp (buffer, gmp_version);
 )
 
 AC_CHECK_FUNCS([__gmpn_add_nc __gmpn_mod_34lsub1 __gmpn_redc_1 __gmpn_redc_2])
-AC_CHECK_FUNCS([__gmpn_mullo_n])
-
-# mpn_sqr() is renamed to __gmpn_sqr() in GMP 5.0.x, but may not be 
-# in future versions. AC_CHECK_FUNCS() does not allow including header 
-# files. Thus, a custom test for mpn_sqr()
-AC_MSG_CHECKING([for mpn_sqr])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#ifdef HAVE_GMP_H
-#include <gmp.h>
-#endif]],[[
-  mpn_sqr ((mp_ptr) 0, (mp_ptr) 0, (mp_size_t) 0);
-  return 0;
-]])], [AC_MSG_RESULT(yes)
-       AC_DEFINE([HAVE_MPN_SQR], 1, [Define to 1 if you have the `mpn_sqr' function.])],
-   [AC_MSG_RESULT(no)]
-)
+AC_CHECK_FUNCS([__gmpn_mullo_n __gmpn_redc_n])
 
 LIBS="$LIBS_BACKUP"
 
@@ -597,6 +605,8 @@ if test x"$config_arch" = xathlon64; then
   if test -f /proc/cpuinfo; then
     if $EGREP -q "Core\(TM\)2" /proc/cpuinfo; then
       config_arch=core2
+    elif $EGREP -q "Core\(TM\) i5" /proc/cpuinfo; then
+      config_arch=corei5
     fi;
   else
     # No /proc/cpuinfo, tell user about ecm-params.h.core2
@@ -620,7 +630,7 @@ fi
 LIBS="$LIBS $GWLIB"
 
 GMP_FINISH
-AC_CONFIG_FILES([Makefile athlon/Makefile pentium4/Makefile x86_64/Makefile powerpc64/Makefile build.vc9/Makefile build.vc9/assembler/Makefile build.vc9/ecm/Makefile build.vc9/libecm/Makefile build.vc9/tune/Makefile])
+AC_CONFIG_FILES([Makefile athlon/Makefile pentium4/Makefile x86_64/Makefile powerpc64/Makefile build.vc10/Makefile build.vc10/assembler/Makefile build.vc10/ecm/Makefile build.vc10/libecm/Makefile build.vc10/tune/Makefile build.vc10/bench_mulredc/Makefile])
 AC_CONFIG_LINKS([ecm-params.h:ecm-params.h.$config_arch])
 MUL_FFT_PARAMS="mul_fft-params.h.$config_arch"
 if ! test -f "$MUL_FFT_PARAMS"
diff --git a/ecm-ecm.h b/ecm-ecm.h
index 7b4c3e1..e1c4500 100644
--- a/ecm-ecm.h
+++ b/ecm-ecm.h
@@ -68,7 +68,8 @@ typedef struct
 
 /* auxi.c */
 unsigned int nb_digits  (const mpz_t);
-unsigned int get_random_ui (void);
+int probab_prime_p (mpz_t, int);
+int read_number (mpcandi_t*, FILE*, int);
 
 /* Various logging levels */
 /* OUTPUT_ALWAYS means print always, regardless of verbose value */
@@ -139,8 +140,6 @@ int write_resumefile_line (char *, int, double, mpz_t, mpz_t, mpz_t, mpcandi_t *
                            mpz_t, const char *);
 
 /* main.c */
-int read_number (mpcandi_t *n, FILE *, int primetest);
-int probab_prime_p (mpz_t, int);
 int kbnc_z (double *k, unsigned long *b, unsigned long *n, signed long *c,
             mpz_t z);
 int kbnc_str (double *k, unsigned long *b, unsigned long *n, signed long *c,
@@ -148,6 +147,8 @@ int kbnc_str (double *k, unsigned long *b, unsigned long *n, signed long *c,
 
 /* batch.c */
 void compute_s (mpz_t, unsigned long);
+int write_s_in_file (char *, mpz_t);
+void read_s_from_file (mpz_t, char *); 
 
 /* eval.c */
 int eval (mpcandi_t *n, FILE *fd, int bPrp);
@@ -167,6 +168,9 @@ void mpgocandi_t_init(mpgocandi_t *go);
 void mpgocandi_t_free(mpgocandi_t *go);
 int  mpgocandi_fixup_with_N(mpgocandi_t *go, mpcandi_t *n);
 
+/* random.c */
+unsigned int get_random_ui (void);
+
 /* random2.c */
 void pp1_random_seed  (mpz_t, mpz_t, gmp_randstate_t);
 void pm1_random_seed  (mpz_t, mpz_t, gmp_randstate_t);
diff --git a/ecm-gmp.h b/ecm-gmp.h
index fa03e50..f059791 100644
--- a/ecm-gmp.h
+++ b/ecm-gmp.h
@@ -78,7 +78,6 @@ MA 02110-1301, USA. */
 #ifndef MPN_ZERO
 #define MPN_ZERO(dst, n)			\
   do {						\
-    ASSERT ((n) >= 0);				\
     if ((n) != 0)				\
       {						\
 	mp_ptr __dst = (dst);			\
@@ -132,6 +131,10 @@ __GMP_DECLSPEC mp_limb_t __gmpn_add_nc (mp_ptr, mp_srcptr, mp_srcptr,
   void __gmpn_redc_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
 #endif
 
+#if defined(HAVE___GMPN_REDC_N)
+  void __gmpn_redc_n (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);
+#endif
+
 #if defined(HAVE___GMPN_MULLO_N)
   void __gmpn_mullo_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
 #endif
diff --git a/ecm-impl.h b/ecm-impl.h
index bcd3d58..b533d5e 100644
--- a/ecm-impl.h
+++ b/ecm-impl.h
@@ -117,11 +117,6 @@ extern FILE *ECM_STDOUT, *ECM_STDERR;
 #endif
 #endif
 
-/* Whether we build the polynomials in stage 2 as described in the literature 
-   as products of (x - x_i) (NEGATED_ROOTS 0), or as 
-   (x + x_i) (NEGATED_ROOTS 1) */
-#define NEGATED_ROOTS 0
-
 /* default B2 choice: pow (B1 * METHOD_COST / 6.0, DEFAULT_B2_EXPONENT) */
 #define DEFAULT_B2_EXPONENT 1.43
 #define PM1_COST 1.0 / 6.0
@@ -146,6 +141,9 @@ extern FILE *ECM_STDOUT, *ECM_STDERR;
 #define KS 5
 #define NTT 6
 
+/* maximal limb size of assembly mulredc */
+#define MULREDC_ASSEMBLY_MAX 20
+
 #include "sp.h"
 
 /* compile with -DMULT=2 to override default */
@@ -322,8 +320,8 @@ typedef struct
   int Fermat;         /* If repr = 1 (base 2 number): If modulus is 2^(2^m)+1, 
                          i.e. bits = 2^m, then Fermat = 2^m, 0 otherwise.
                          If repr != 1, undefined */
-  mp_limb_t Nprim[2]; /* For MODMULN */
-  mpz_t orig_modulus; /* The original modulus */
+  mp_limb_t *Nprim;   /* For MODMULN */
+  mpz_t orig_modulus; /* The original modulus N */
   mpz_t aux_modulus;  /* Used only for MPZ and REDC:
 			 - the auxiliary modulus value (i.e. normalized 
                            modulus, or -1/N (mod 2^bits) for REDC,
@@ -564,6 +562,9 @@ unsigned int ks_wrapmul (listz_t, unsigned int, listz_t, unsigned int,
                          listz_t, unsigned int, mpz_t);
 
 /* mpmod.c */
+/* Define MPRESN_NO_ADJUSTMENT if mpresn_add, mpresn_sub and mpresn_addsub
+   should perform no adjustment step. This yields constraints on N. */
+// #define MPRESN_NO_ADJUSTMENT
 #define isbase2 __ECM(isbase2)
 int isbase2 (const mpz_t, const double);
 #define mpmod_init __ECM(mpmod_init)
@@ -578,8 +579,8 @@ void mpmod_init_MODMULN (mpmod_t, const mpz_t);
 void mpmod_init_REDC (mpmod_t, const mpz_t);
 #define mpmod_clear __ECM(mpmod_clear)
 void mpmod_clear (mpmod_t);
-#define mpmod_copy __ECM(mpmod_copy)
-void mpmod_copy (mpmod_t, const mpmod_t);
+#define mpmod_init_set __ECM(mpmod_init_set)
+void mpmod_init_set (mpmod_t, const mpmod_t);
 #define mpmod_pausegw __ECM(mpmod_pausegw)
 void mpmod_pausegw (const mpmod_t modulus);
 #define mpmod_contgw __ECM(mpmod_contgw)
@@ -642,6 +643,22 @@ void mpres_out_str (FILE *, const unsigned int, const mpres_t, mpmod_t);
 int  mpres_is_zero (const mpres_t, mpmod_t);
 #define mpres_set(a,b,n) mpz_set (a, b)
 #define mpres_swap(a,b,n) mpz_swap (a, b)
+#define mpresn_mul __ECM(mpresn_mul)
+void mpresn_mul (mpres_t, const mpres_t, const mpres_t, mpmod_t);
+#define mpresn_addsub __ECM(mpresn_addsub)
+void mpresn_addsub (mpres_t, mpres_t, const mpres_t, const mpres_t, mpmod_t);
+#define mpresn_pad __ECM(mpresn_pad)
+void mpresn_pad (mpres_t R, mpmod_t N);
+#define mpresn_unpad __ECM(mpresn_unpad)
+void mpresn_unpad (mpres_t R);
+#define mpresn_sqr __ECM(mpresn_sqr)
+void mpresn_sqr (mpres_t, const mpres_t, mpmod_t);
+#define mpresn_add __ECM(mpresn_add)
+void mpresn_add (mpres_t, const mpres_t, const mpres_t, mpmod_t);
+#define mpresn_sub __ECM(mpresn_sub)
+void mpresn_sub (mpres_t, const mpres_t, const mpres_t, mpmod_t);
+#define mpresn_mul_1 __ECM(mpresn_mul_ui)
+void mpresn_mul_1 (mpres_t, const mpres_t, const mp_limb_t, mpmod_t);
 
 /* mul_lo.c */
 #define ecm_mul_lo_n __ECM(ecm_mul_lo_n)
@@ -746,7 +763,14 @@ int  mpn_fft_best_k (mp_size_t, int);
 mp_size_t mpn_fft_next_size (mp_size_t, int);
 
 /* batch.c */
-int ecm_stage1_batch (mpz_t, mpres_t, mpres_t, mpmod_t, double, double *, mpz_t);
+void compute_s (mpz_t, unsigned long);
+int write_s_in_file (char *, mpz_t);
+void read_s_from_file (mpz_t, char *); 
+int ecm_stage1_batch (mpz_t, mpres_t, mpres_t, mpmod_t, double, double *, 
+                                                                int,  mpz_t);
+
+/* ellparam_batch.c */
+int get_curve_from_ell_parametrization (mpz_t, mpres_t, mpz_t, mpmod_t);
 
 /* sets_long.c */
 /* A set of long ints */
diff --git a/ecm-params.h b/ecm-params.h
index 6a887a1..c7ce9ce 100644
--- a/ecm-params.h
+++ b/ecm-params.h
@@ -1,15 +1,25 @@
-/* produced 3 Jan 2012 on tarte.loria.fr with GMP 5.0.2 for ecm-6.4
-   (Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz) */
+/* updated 09 Mar 2012 on frite.loria.fr (AMD Phenom(tm) II X2 B55 Processor)
+   for ecm svn 1724 with GMP 5.0.4 */
 
-#define TUNE_MULREDC_THRESH 20
-#define TUNE_SQRREDC_THRESH 3
-#define MPZMOD_THRESHOLD 81
-#define REDC_THRESHOLD 491
-#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 1, 1, 10, 10, 1, 12, 12, 12, 16, 12, 13, 14, 15, 16, 17, 18, 19}
-#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 16
+#ifndef HAVE_MPIR
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,1,2,1,1,1,2}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,2,2,1,2,2,1,2,1,2,1,1,1,2}
+#else /* tuning parameters for MPIR 2.5.0 */
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
+#endif
+
+#define MPZMOD_THRESHOLD 103
+#define REDC_THRESHOLD 512
+#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 8, 10, 11, 11, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 16, 18, 18, 18, 20}
+#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 12
 #define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
-#define MUL_NTT_THRESHOLD 512
+#define MUL_NTT_THRESHOLD 256
 #define PREREVERTDIVISION_NTT_THRESHOLD 16
-#define POLYINVERT_NTT_THRESHOLD 128
-#define POLYEVALT_NTT_THRESHOLD 256
-#define MPZSPV_NORMALISE_STRIDE 64
+#define POLYINVERT_NTT_THRESHOLD 512
+#define POLYEVALT_NTT_THRESHOLD 128
+#define MPZSPV_NORMALISE_STRIDE 512
diff --git a/ecm-params.h.alpha-ev56 b/ecm-params.h.alpha-ev56
index 1f9d211..4719049 100644
--- a/ecm-params.h.alpha-ev56
+++ b/ecm-params.h.alpha-ev56
@@ -1,7 +1,5 @@
 /* parameters kindly provided by Torbjorn Granlund, and produced with
    ecm-6.3-rc3 on alphaev56-unknown-freebsd6.4 */
-#define TUNE_MULREDC_THRESH 1
-#define TUNE_SQRREDC_THRESH 7
 #define MPZMOD_THRESHOLD 58
 #define REDC_THRESHOLD 493
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
diff --git a/ecm-params.h.armv5tel b/ecm-params.h.armv5tel
index 3a5bf36..1909486 100644
--- a/ecm-params.h.armv5tel
+++ b/ecm-params.h.armv5tel
@@ -1,8 +1,6 @@
 /* those parameters were obtained on gcc50.fsffrance.org with ecm-6.3-rc3,
    gmp-5.0.1, and gcc 4.3.2 -O2 -pedantic -fomit-frame-pointer
    (armv5tel-unknown-linux-gnueabi) */
-#define TUNE_MULREDC_THRESH 2
-#define TUNE_SQRREDC_THRESH 3
 #define MPZMOD_THRESHOLD 140
 #define REDC_THRESHOLD 512
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
diff --git a/ecm-params.h.athlon64 b/ecm-params.h.athlon64
index 053b612..c7ce9ce 100644
--- a/ecm-params.h.athlon64
+++ b/ecm-params.h.athlon64
@@ -1,8 +1,18 @@
-/* updated 03 Jan 2012 on frite.loria.fr (AMD Phenom(tm) II X2 B55 Processor)
-   for ecm-6.4 with GMP 5.0.2 */
+/* updated 09 Mar 2012 on frite.loria.fr (AMD Phenom(tm) II X2 B55 Processor)
+   for ecm svn 1724 with GMP 5.0.4 */
+
+#ifndef HAVE_MPIR
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,1,2,1,1,1,2}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,2,2,1,2,2,1,2,1,2,1,1,1,2}
+#else /* tuning parameters for MPIR 2.5.0 */
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
+#endif
 
-#define TUNE_MULREDC_THRESH 10
-#define TUNE_SQRREDC_THRESH 1
 #define MPZMOD_THRESHOLD 103
 #define REDC_THRESHOLD 512
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 8, 10, 11, 11, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 16, 18, 18, 18, 20}
diff --git a/ecm-params.h.core2 b/ecm-params.h.core2
index 6a887a1..ac639f7 100644
--- a/ecm-params.h.core2
+++ b/ecm-params.h.core2
@@ -1,8 +1,18 @@
-/* produced 3 Jan 2012 on tarte.loria.fr with GMP 5.0.2 for ecm-6.4
-   (Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz) */
+/* produced 11 Feb 2012 on coing.loria.fr with GMP 5.0.4 for ecm svn 1723
+   (Intel(R) Core(TM)2 Duo CPU     U9600  @ 1.60GHz) */
+
+#ifndef HAVE_MPIR
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,1,1,2,2,2,2,2,2,2,2,2,2,2}
+#else /* tuning parameters for MPIR 2.5.0 */
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1}
+#endif
 
-#define TUNE_MULREDC_THRESH 20
-#define TUNE_SQRREDC_THRESH 3
 #define MPZMOD_THRESHOLD 81
 #define REDC_THRESHOLD 491
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 1, 1, 10, 10, 1, 12, 12, 12, 16, 12, 13, 14, 15, 16, 17, 18, 19}
diff --git a/ecm-params.h.corei5 b/ecm-params.h.corei5
new file mode 100644
index 0000000..6383ab0
--- /dev/null
+++ b/ecm-params.h.corei5
@@ -0,0 +1,26 @@
+/* updated 09 Mar 2012 on confit.loria.fr (Intel(R) Core(TM) i5-2500 CPU)
+   for svn revision 1724 with GMP 5.0.4 and gcc 4.6.1 */
+
+#ifndef HAVE_MPIR
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2}
+#else /* tuning parameters for MPIR 2.5.0 */
+/* 0:mulredc 1:mul+redc_1 2:mul+redc_2 3:mul+redc_n */
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,1,1}
+/* 0:mulredc 1:sqr+redc_1 2:sqr+redc_2 3:sqr+redc_n */
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}
+#endif
+
+#define MPZMOD_THRESHOLD 77
+#define REDC_THRESHOLD 512
+#define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 11, 12, 12, 13, 14, 13, 14, 14, 16, 16, 16, 16, 16, 16}
+#define NTT_GFP_TWIDDLE_DIF_BREAKOVER 17
+#define NTT_GFP_TWIDDLE_DIT_BREAKOVER 17
+#define MUL_NTT_THRESHOLD 256
+#define PREREVERTDIVISION_NTT_THRESHOLD 8
+#define POLYINVERT_NTT_THRESHOLD 128
+#define POLYEVALT_NTT_THRESHOLD 64
+#define MPZSPV_NORMALISE_STRIDE 256
+
diff --git a/ecm-params.h.hppa2.0 b/ecm-params.h.hppa2.0
index 4e994c4..cbaf2ce 100644
--- a/ecm-params.h.hppa2.0
+++ b/ecm-params.h.hppa2.0
@@ -2,8 +2,6 @@
    gmp-5.0.1, and gcc 4.4.1 -O2 -pedantic -mpa-risc-1-1
    (note that GMP must be configured with ABI=1.0, see
    http://gmplib.org/list-archives/gmp-bugs/2009-August/001585.html */
-#define TUNE_MULREDC_THRESH 3
-#define TUNE_SQRREDC_THRESH 4
 #define MPZMOD_THRESHOLD 185
 #define REDC_THRESHOLD 512
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
diff --git a/ecm-params.h.ia64 b/ecm-params.h.ia64
index 311437f..ec6e80e 100644
--- a/ecm-params.h.ia64
+++ b/ecm-params.h.ia64
@@ -1,8 +1,6 @@
 /* those parameters were obtained on gcc60.fsffrance.org with ecm-6.3-rc3
    gmp-5.0.1, and gcc 4.3.2 -O2 -pedantic -mtune=itanium2
    (ia64-unknown-linux-gnu) */
-#define TUNE_MULREDC_THRESH 1
-#define TUNE_SQRREDC_THRESH 2
 #define MPZMOD_THRESHOLD 151
 #define REDC_THRESHOLD 509
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 14, 15, 18, 1, 1, 19, 14, 20, 16, 21, 24, 21, 20, 20}
diff --git a/ecm-params.h.mips64el b/ecm-params.h.mips64el
index 986b478..d87979e 100644
--- a/ecm-params.h.mips64el
+++ b/ecm-params.h.mips64el
@@ -1,7 +1,5 @@
 /* those parameters were obtained on gcc42.fsffrance.org with ecm-6.3-rc3
    gmp-5.0.1, and gcc 4.3.1 -O2 -mabi=n32 (mips64el-unknown-linux-gnu) */
-#define TUNE_MULREDC_THRESH 1
-#define TUNE_SQRREDC_THRESH 8
 #define MPZMOD_THRESHOLD 81
 #define REDC_THRESHOLD 512
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
diff --git a/ecm-params.h.pentium-m b/ecm-params.h.pentium-m
index 083e60a..0064422 100644
--- a/ecm-params.h.pentium-m
+++ b/ecm-params.h.pentium-m
@@ -1,7 +1,5 @@
 /* those parameters were obtained on toto.loria.fr with ecm-6.3-rc3
    gmp-5.0.1, and gcc 4.0.2 -m32 -O2 -pedantic -fomit-frame-pointer -mtune=pentium3 -march=pentium3 */
-#define TUNE_MULREDC_THRESH 1
-#define TUNE_SQRREDC_THRESH 1
 #define MPZMOD_THRESHOLD 98
 #define REDC_THRESHOLD 398
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 12, 12, 1, 14, 12, 13, 1, 15, 16, 15, 16, 19, 20, 22}
diff --git a/ecm-params.h.pentium4 b/ecm-params.h.pentium4
index 272f987..336b2c6 100644
--- a/ecm-params.h.pentium4
+++ b/ecm-params.h.pentium4
@@ -1,8 +1,6 @@
 /* those parameters were generated on 3 Jan 2012 on macaron.loria.fr
    (Intel(R) Pentium(R) 4 CPU 3.20GHz) for ecm-6.4 with GMP 5.0.2 */
 
-#define TUNE_MULREDC_THRESH 1
-#define TUNE_SQRREDC_THRESH 3
 #define MPZMOD_THRESHOLD 84
 #define REDC_THRESHOLD 119
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
diff --git a/ecm-params.h.powerpc970 b/ecm-params.h.powerpc970
old mode 100755
new mode 100644
index 3dbf608..359fbba
--- a/ecm-params.h.powerpc970
+++ b/ecm-params.h.powerpc970
@@ -1,7 +1,5 @@
 /* these values were determined on gcc40.fsffrance.org with ecm-6.3-rc3,
    gmp-5.0.1, and gcc 4.1.2, CFLAGS="-m64  -mtune=970 -O3" */
-#define TUNE_MULREDC_THRESH 12
-#define TUNE_SQRREDC_THRESH 10
 #define MPZMOD_THRESHOLD 74
 #define REDC_THRESHOLD 480
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 11, 12, 1, 1, 11, 1, 1, 1, 1, 1, 1, 18, 18, 18, 18, 20, 22}
diff --git a/ecm-params.h.sparc64 b/ecm-params.h.sparc64
index bdf0fca..0bacae3 100644
--- a/ecm-params.h.sparc64
+++ b/ecm-params.h.sparc64
@@ -1,8 +1,6 @@
 /* those parameters were obtained on gcc54.fsffrance.org with ecm-6.3-rc3
    gmp-5.0.1, and gcc 4.1.2 -O2 -pedantic -m64 -mptr64 -mcpu=ultrasparc
    (sparc64-unknown-linux-gnu) */
-#define TUNE_MULREDC_THRESH 8
-#define TUNE_SQRREDC_THRESH 1
 #define MPZMOD_THRESHOLD 84
 #define REDC_THRESHOLD 84
 #define MPN_MUL_LO_THRESHOLD_TABLE {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 11, 13, 11, 12, 13, 13, 15, 16, 15, 17, 15, 16, 19, 18, 19, 20, 19, 23}
diff --git a/ecm.c b/ecm.c
index 2d091dd..828efcb 100644
--- a/ecm.c
+++ b/ecm.c
@@ -34,8 +34,17 @@
 
 /* the following factor takes into account the smaller expected smoothness
    for Montgomery's curves (batch mode) with respect to Suyama's curves */
-#define BATCH_EXTRA_SMOOTHNESS (1.0 / 3.0)
-
+#if GMP_NUMB_BITS >= 64
+/* For GMP_NUMB_BITS >= 64 we use A=4d-2 with d a square (see main.c). In that
+   case, Cyril Bouvier and Razvan Barbulescu have shown that the average
+   expected torsion is that of a generic Suyama curve multiplied by the
+   constant 2^(1/3)/(3*3^(1/128)) */
+#define BATCH1_EXTRA_SMOOTHNESS 0.416384512396064
+#else
+/* For A=4d-2 for d a random integer, the average expected torsion is that
+   of a generic Suyama curve multiplied by the constant 1/(3*3^(1/128)) */
+#define BATCH1_EXTRA_SMOOTHNESS 0.330484606500389
+#endif
 /******************************************************************************
 *                                                                             *
 *                            Elliptic Curve Method                            *
@@ -74,18 +83,18 @@ get_curve_from_sigma (mpz_t f, mpres_t A, mpres_t x, mpz_t sigma, mpmod_t n)
 
   mpres_set_z  (u, sigma, n);
   mpres_mul_ui (v, u, 4, n);   /* v = (4*sigma) mod n */
-  mpres_mul (t, u, u, n);
+  mpres_sqr (t, u, n);
   mpres_sub_ui (u, t, 5, n);       /* u = (sigma^2-5) mod n */
-  mpres_mul (t, u, u, n);
+  mpres_sqr (t, u, n);
   mpres_mul (x, t, u, n);          /* x = (u^3) mod n */
-  mpres_mul (t, v, v, n);
+  mpres_sqr (t, v, n);
   mpres_mul (z, t, v, n);          /* z = (v^3) mod n */
   mpres_mul (t, x, v, n);
   mpres_mul_ui (b, t, 4, n);       /* b = (4*x*v) mod n */
   mpres_mul_ui (t, u, 3, n);
   mpres_sub (u, v, u, n);          /* u' = v-u */
   mpres_add (v, t, v, n);          /* v' = (3*u+v) mod n */
-  mpres_mul (t, u, u, n);
+  mpres_sqr (t, u, n);
   mpres_mul (u, t, u, n);          /* u'' = ((v-u)^3) mod n */
   mpres_mul (A, u, v, n);          /* a = (u'' * v') mod n = 
                                       ((v-u)^3 * (3*u+v)) mod n */
@@ -155,7 +164,7 @@ montgomery_to_weierstrass (mpz_t f, mpres_t x, mpres_t y, mpres_t A, mpmod_t n)
   mpres_mul (x, x, y, n);    /* (3x+a)/(3g) */
 
   /* update A */
-  mpres_mul (A, A, A, n);    /* a^2 */
+  mpres_sqr (A, A, n);    /* a^2 */
   mpres_sub_ui (A, A, 3, n);
   mpres_neg (A, A, n);       /* 3-a^2 */
   mpres_mul (A, A, y, n);    /* (3-a^2)/(3g^2) */
@@ -195,8 +204,8 @@ add3 (mpres_t x3, mpres_t z3, mpres_t x2, mpres_t z2, mpres_t x1, mpres_t z1,
   mpres_add (w, u, v, n);        /* w = 2*(x1*x2-z1*z2) */
   mpres_sub (v, u, v, n);        /* v = 2*(x2*z1-x1*z2) */
 
-  mpres_mul (w, w, w, n);        /* w = 4*(x1*x2-z1*z2)^2 */
-  mpres_mul (v, v, v, n);        /* v = 4*(x2*z1-x1*z2)^2 */
+  mpres_sqr (w, w, n);           /* w = 4*(x1*x2-z1*z2)^2 */
+  mpres_sqr (v, v, n);           /* v = 4*(x2*z1-x1*z2)^2 */
 
   if (x == x3) /* same variable: in-place variant */
     {
@@ -227,9 +236,9 @@ duplicate (mpres_t x2, mpres_t z2, mpres_t x1, mpres_t z1, mpmod_t n,
            mpres_t b, mpres_t u, mpres_t v, mpres_t w)
 {
   mpres_add (u, x1, z1, n);
-  mpres_mul (u, u, u, n);   /* u = (x1+z1)^2 mod n */
+  mpres_sqr (u, u, n);      /* u = (x1+z1)^2 mod n */
   mpres_sub (v, x1, z1, n);
-  mpres_mul (v, v, v, n);   /* v = (x1-z1)^2 mod n */
+  mpres_sqr (v, v, n);      /* v = (x1-z1)^2 mod n */
   mpres_mul (x2, u, v, n);  /* x2 = u*v = (x1^2 - z1^2)^2 mod n */
   mpres_sub (w, u, v, n);   /* w = u-v = 4*x1*z1 */
   mpres_mul (u, w, b, n);   /* u = w*b = ((A+2)/4*(4*x1*z1)) mod n */
@@ -625,7 +634,7 @@ ecm_stage1 (mpz_t f, mpres_t x, mpres_t A, mpmod_t n, double B1,
   mpres_set_ui (z, 1, n);
 
   mpres_add_ui (b, A, 2, n);
-  mpres_div_2exp (b, b, 2, n); /* b == (A0+2)*B/4, where B=2^(k*GMP_NUMB_LIMB)
+  mpres_div_2exp (b, b, 2, n); /* b == (A0+2)*B/4, where B=2^(k*GMP_NUMB_BITS)
                                   for MODMULN or REDC, B=1 otherwise */
   /* preload group order */
   if (go != NULL)
@@ -752,7 +761,7 @@ print_expcurves (double B1, const mpz_t B2, unsigned long dF, unsigned long k,
       prob = ecmprob (B1, mpz_get_d (B2),
                       /* in batch mode, the extra smoothness is smaller */
                       pow (10., i - .5) /
-                      ((batch) ? BATCH_EXTRA_SMOOTHNESS : 1.0),
+                      ((batch == 1) ? BATCH1_EXTRA_SMOOTHNESS : 1.0),
                       (double) dF * dF * k, S);
       if (prob > 1. / 10000000)
         outputf (OUTPUT_VERBOSE, "%.0f%c", floor (1. / prob + .5), sep);
@@ -782,7 +791,7 @@ print_exptime (double B1, const mpz_t B2, unsigned long dF, unsigned long k,
       prob = ecmprob (B1, mpz_get_d (B2),
                       /* in batch mode, the extra smoothness is smaller */
                       pow (10., i - .5) /
-                      ((batch) ? BATCH_EXTRA_SMOOTHNESS : 1.0),
+                      ((batch == 1) ? BATCH1_EXTRA_SMOOTHNESS : 1.0),
                       (double) dF * dF * k, S);
       exptime = (prob > 0.) ? tottime / prob : HUGE_VAL;
       outputf (OUTPUT_TRACE, "Digits: %d, Total time: %.0f, probability: "
@@ -901,6 +910,20 @@ ecm (mpz_t f, mpz_t x, mpz_t sigma, mpz_t n, mpz_t go, double *B1done,
   ECM_STDOUT = (os == NULL) ? stdout : os;
   ECM_STDERR = (es == NULL) ? stdout : es;
 
+#ifdef MPRESN_NO_ADJUSTMENT
+  /* When no adjustment is made in mpresn_ functions, N should be smaller
+     than B^n/16 */
+  if (mpz_sizeinbase (n, 2) > mpz_size (n) * GMP_NUMB_BITS - 4)
+    {
+      outputf (OUTPUT_ERROR, "Error, N should be smaller than B^n/16\n");
+      return ECM_ERROR;
+    }
+#endif
+
+  /* In batch mode, we force MODMULN */
+  if (batch)
+    repr = ECM_MOD_MODMULN;
+
   /* if n is even, return 2 */
   if (mpz_divisible_2exp_p (n, 1))
     {
@@ -1035,6 +1058,49 @@ ecm (mpz_t f, mpz_t x, mpz_t sigma, mpz_t n, mpz_t go, double *B1done,
       if (youpi != ECM_NO_FACTOR_FOUND)
 	  goto end_of_ecm;
     }
+  else if (sigma_is_A == 1 && batch == 1)
+    {
+      if (mpz_sgn (sigma) == 0)
+        {
+          int i;
+
+          /* We choose a positive integer d' smaller than B=2^GMP_NUMB_BITS
+             and consider d = d'/B and A = 4d-2 */
+          do
+            mpz_urandomb (sigma, rng, 32);  /* generates d' <> 0 */
+          while (mpz_sgn (sigma) == 0);
+          ASSERT((GMP_NUMB_BITS % 2) == 0);
+          if (GMP_NUMB_BITS >= 64)
+            mpz_mul (sigma, sigma, sigma);      /* ensures d' (and thus d) is
+                                                   a square, which increases
+                                                   the success probability */
+          /* divide d' by B to get d */
+          for (i = 0; i < GMP_NUMB_BITS; i++)
+            {
+              if (mpz_tstbit (sigma, 0) == 1)
+                mpz_add (sigma, sigma, n);
+              mpz_div_2exp (sigma, sigma, 1);
+            }
+          mpz_mul_2exp (sigma, sigma, 2);           /* 4d */
+          mpz_sub_ui (sigma, sigma, 2);             /* 4d-2 */
+        }
+      
+      mpres_set_z (P.A, sigma, modulus);
+    }
+  else if (sigma_is_A == 1 && batch == 2)
+    {
+      if (mpz_sgn (sigma) == 0)
+        {
+          mpz_urandomb (sigma, rng, 32);
+          mpz_add_ui (sigma, sigma, 2);
+          youpi = get_curve_from_ell_parametrization (f, P.A, sigma, modulus);
+          mpres_get_z (sigma, P.A, modulus);
+          if (youpi != ECM_NO_FACTOR_FOUND)
+	          goto end_of_ecm;
+        }
+      else    /* sigma contains the A value */
+          mpres_set_z (P.A, sigma, modulus);
+    }
   else if (sigma_is_A == 1)
     {
       /* sigma contains the A value */
@@ -1092,9 +1158,9 @@ ecm (mpz_t f, mpz_t x, mpz_t sigma, mpz_t n, mpz_t go, double *B1done,
       mpz_init (t);
       MEMORY_UNTAG;
       mpres_get_z (t, P.A, modulus);
-      outputf (OUTPUT_RESVERBOSE, "a=%Zd\n", t);
+      outputf (OUTPUT_RESVERBOSE, "A=%Zd\n", t);
       mpres_get_z (t, P.x, modulus);
-      outputf (OUTPUT_RESVERBOSE, "starting point: x=%Zd\n", t);
+      outputf (OUTPUT_RESVERBOSE, "starting point: x0=%Zd\n", t);
       mpz_clear (t);
     }
 
@@ -1118,7 +1184,7 @@ ecm (mpz_t f, mpz_t x, mpz_t sigma, mpz_t n, mpz_t go, double *B1done,
 #ifdef HAVE_GWNUM
   /* We will only use GWNUM for numbers of the form k*b^n+c */
 
-  if (gw_b != 0 && B1 >= *B1done && batch != 1)
+  if (gw_b != 0 && B1 >= *B1done && batch == 0)
       youpi = gw_ecm_stage1 (f, &P, modulus, B1, B1done, go, gw_k, gw_b, gw_n, gw_c);
 
   /* At this point B1 == *B1done unless interrupted, or no GWNUM ecm_stage1
@@ -1130,9 +1196,10 @@ ecm (mpz_t f, mpz_t x, mpz_t sigma, mpz_t n, mpz_t go, double *B1done,
 
   if (B1 > *B1done)
     {
-      if (batch == 1)
+      if (batch != 0)
         /* FIXME: go, stop_asap and chkfilename are ignored in batch mode */
-        youpi = ecm_stage1_batch (f, P.x, sigma, modulus, B1, B1done, batch_s);
+        youpi = ecm_stage1_batch (f, P.x, P.A, modulus, B1, B1done, batch, 
+                                                            batch_s);
       else
         youpi = ecm_stage1 (f, P.x, P.A, modulus, B1, B1done, go, stop_asap,
                             chkfilename);
diff --git a/ecm2.c b/ecm2.c
index 782f1b2..526859a 100644
--- a/ecm2.c
+++ b/ecm2.c
@@ -180,7 +180,7 @@ multiplyW2n (mpz_t p, point *R, curve *S, mpz_t *q, const unsigned int n,
                 
                 mpres_sub (u, s.y, R[i].y, modulus);   /* U    = y2 - y1 */
                 mpres_mul (T[l], T[l], u, modulus);    /* T[l] = (y2-y1)/(x2-x1) = lambda */
-                mpres_mul (u, T[l], T[l], modulus);    /* U    = lambda^2 */
+                mpres_sqr (u, T[l], modulus);          /* U    = lambda^2 */
                 mpres_sub (u, u, R[i].x, modulus);     /* U    = lambda^2 - x1 */
                 mpres_sub (R[i].x, u, s.x, modulus);   /* x3   = lambda^2 - x1 - x2 */
                 mpres_sub (u, s.x, R[i].x, modulus);   /* U    = x2 - x3 */
@@ -213,11 +213,11 @@ multiplyW2n (mpz_t p, point *R, curve *S, mpz_t *q, const unsigned int n,
 #endif          
 
                                                /* 1/(2*s.y) is in T[k] */
-          mpres_mul (u, s.x, s.x, modulus);    /* U = X^2 */
+          mpres_sqr (u, s.x, modulus);         /* U = X^2 */
           mpres_mul_ui (u, u, 3, modulus);     /* U = 3*X^2 */
           mpres_add (u, u, S->A, modulus);     /* U = 3*X^2 + A */
           mpres_mul (T[k], T[k], u, modulus);  /* T = (3*X^2 + A) / (2*Y) = lambda */
-          mpres_mul (u, T[k], T[k], modulus);  /* U = lambda^2 */
+          mpres_sqr (u, T[k], modulus);        /* U = lambda^2 */
           mpres_sub (u, u, s.x, modulus);      /* U = lambda^2 - X */
           mpres_sub (u, u, s.x, modulus);      /* U = lambda^2 - 2*X = s.x' */
           mpres_sub (v, s.x, u, modulus);      /* V = s.x - s.x' */
@@ -387,11 +387,11 @@ addWnm (mpz_t p, point *X, curve *S, mpmod_t modulus, unsigned int m,
                 /* T_k = 1/(v_0 * ... * v_l) * v_l = 1/(v_0 * ... * v_{l-1}) */
               }
             
-            mpres_mul (T[k + 1], X1->x, X1->x, modulus);
+            mpres_sqr (T[k + 1], X1->x, modulus);
             mpres_mul_ui (T[k + 1], T[k + 1], 3, modulus);
             mpres_add (T[k + 1], T[k + 1], S->A, modulus);
             mpres_mul (T[l], T[k + 1], T[l], modulus); /* T[l] = lambda */
-            mpres_mul (T[k + 1], T[l], T[l], modulus);       /* T1   = lambda^2 */
+            mpres_sqr (T[k + 1], T[l], modulus);       /* T1   = lambda^2 */
             mpres_sub (T[k + 1], T[k + 1], X1->x, modulus);  /* T1   = lambda^2 - x1 */
             mpres_sub (X1->x, T[k + 1], X2->x, modulus);     /* X1.x = lambda^2 - x1 - x2 = x3 */
             mpres_sub (T[k + 1], X2->x, X1->x, modulus);     /* T1   = x2 - x3 */
@@ -408,7 +408,7 @@ addWnm (mpz_t p, point *X, curve *S, mpmod_t modulus, unsigned int m,
 
             mpres_sub (T[k + 1], X2->y, X1->y, modulus);     /* T1   = y2 - y1 */
             mpres_mul (T[l], T[l], T[k + 1], modulus);       /* Tl   = (y2 - y1) / (x2 - x1) = lambda */
-            mpres_mul (T[k + 1], T[l], T[l], modulus);       /* T1   = lambda^2 */
+            mpres_sqr (T[k + 1], T[l], modulus);          /* T1   = lambda^2 */
             mpres_sub (T[k + 1], T[k + 1], X1->x, modulus);  /* T1   = lambda^2 - x1 */
             mpres_sub (X1->x, T[k + 1], X2->x, modulus);     /* X1.x = lambda^2 - x1 - x2 = x3 */
             mpres_sub (T[k + 1], X2->x, X1->x, modulus);     /* T1   = x2 - x3 */
diff --git a/ecm_ntt.c b/ecm_ntt.c
index 8b36c38..79e4795 100644
--- a/ecm_ntt.c
+++ b/ecm_ntt.c
@@ -128,11 +128,8 @@ ntt_PolyFromRoots_Tree (mpzv_t r, mpzv_t a, spv_size_t len, mpzv_t t,
 	 the possibly negated roots), and advance the destination level 
 	 of the tree to the next level */
       src = *dst;
-#if NEGATED_ROOTS == 1
+      /* we consider x + root[i], which means we consider negated roots */
       list_set (*dst--, a, len);
-#else
-      list_neg (*dst--, a, len, mpzspm->modulus);
-#endif
     }
   
   m = (dolvl == -1) ? 1 : 1 << (ceil_log2 (len) - 1 - dolvl);
diff --git a/ellparam_batch.c b/ellparam_batch.c
new file mode 100644
index 0000000..16ca06e
--- /dev/null
+++ b/ellparam_batch.c
@@ -0,0 +1,232 @@
+#include "ecm-gmp.h"
+#include "ecm-impl.h"
+
+#if 0
+/* this function is useful in debug mode to print residues */
+static void
+mpres_print (mpres_t x, char* name, mpmod_t n)
+{
+  mp_size_t m, xn;
+  mpres_t t;
+  mpres_init(t, n);
+  mpz_set_ui(t, 1);
+  mpres_mul (t, x, t, n);
+
+  xn = SIZ(t);
+  m = ABSIZ(t);
+  MPN_NORMALIZE(PTR(t), m);
+  SIZ(t) = xn >= 0 ? m : -m;
+  gmp_printf ("%s=%Zd\n", name, t);
+  SIZ(t) = xn;
+  mpres_clear (t, n);
+}
+#endif
+
+static void 
+dbl_param (mpres_t x, mpres_t y, mpres_t z, mpres_t t, mpres_t u, mpres_t v,
+                                                                  mpmod_t n)
+{
+  mpres_mul (z, y, z, n); /* Y1*Z1  */
+  mpres_mul_ui (z, z, 2, n); /* Z3 = 2*Y1*Z1  */
+
+  mpres_sqr (u, x, n); /* A = X1*X1  */
+  mpres_sqr (t, y, n); /* B = Y1*Y1  */
+  mpres_sqr (y, t, n); /* C = B^2  */
+  mpres_add (v, x, t, n); /* X1+B  */
+  mpres_sqr (v, v, n); /* (X1+B)^2  */
+  mpres_sub (v, v, u, n); /* (X1+B)^2-A  */
+  mpres_sub (v, v, y, n); /* (X1+B)^2-A-C  */
+  mpres_mul_ui (v, v, 2, n); /* D = 2*((X1+B)^2-A-C)  */
+  mpres_mul_ui (u, u, 3, n); /* E = 3*A  */
+  mpres_sqr (t, u, n); /* F = E^2  */
+
+
+  mpres_mul_ui (x, v, 2, n); /* 2*D  */
+  mpres_sub (x, t, x, n); /* X3 = F-2*D  */
+
+  mpres_sub (v, v, x, n); /* D-X3  */
+  mpres_mul_ui (y, y, 8, n); /* 8*C  */
+  mpres_mul (t, u, v, n); /* E*(D-X3)  */
+  mpres_sub (y, t, y, n); /* Y3 = E*(D-X3)-8*C */
+}
+
+/*Add sgn*P=(-3:sgn*3:1) to Q=(x:y:z) */
+static void 
+add_param (mpres_t x, mpres_t y, mpres_t z, int sgn, mpres_t t, mpres_t u, 
+                                          mpres_t v, mpres_t w, mpmod_t n)
+{
+  mpres_sqr (t, z, n); /* Z1Z1 = Z1^2   */
+	mpres_mul_ui (u, t, 3, n); 
+	mpres_neg (u, u, n); /* U2 = X2*Z1Z1 with X2=-3 */
+	mpres_mul (v, z, t, n); /* Z1*Z1Z1  */
+	mpres_mul_ui (v, v, 3, n); /* S2 = Y2*Z1*Z1Z1 with Y2=sgn*3  */
+	if (sgn == -1) 
+    mpres_neg (v, v, n); /* S2 = Y2*Z1*Z1Z1 with Y2=sgn*3 */
+	mpres_sub (u, u, x, n); /* H = U2-X1  */
+	mpres_sqr (w, u, n); /* HH = H^2  */
+
+	mpres_add (z, z, u, n); /* Z1+H  */
+	mpres_sqr (z, z, n); /* (Z1+H)^2  */
+	mpres_sub (z, z, t, n); /* (Z1+H)^2-Z1Z1   */
+	mpres_sub (z, z, w, n); /* Z3 = (Z1+H)^2-Z1Z1-HH  */
+
+
+	mpres_mul_ui (t, w, 4, n); /* I = 4*HH  */
+	mpres_mul (u, u, t, n); /* J = H*I  */
+	mpres_sub (v, v, y, n); /* S2-Y1  */
+	mpres_mul_ui (v, v, 2, n); /* r = 2*(S2-Y1) */
+	mpres_mul (t, x, t, n); /* V = X1*I */
+	mpres_sqr (x, v, n); /* r^2 */
+	mpres_mul_ui (w, t, 2, n); /* 2*V  */
+	mpres_sub (x, x, u, n); /* r^2-J  */
+	mpres_sub (x, x, w, n); /* X3 = r^2-J-2*V  */
+
+	mpres_sub (w, t, x, n); /* V-X3 */
+	mpres_mul (y, y, u, n); /* Y1*J */
+	mpres_mul_ui (y, y, 2, n); /* 2*Y1*J   */
+	mpres_mul (w, v, w, n); /* r*(V-X3)  */
+	mpres_sub (y, w, y, n); /* Y3=r*(V-X3)-2*Y1*J  */
+}
+
+static void
+addchain_param (mpres_t x, mpres_t y, mpres_t z, unsigned int s, mpres_t t,
+                                    mpres_t u, mpres_t v, mpres_t w, mpmod_t n)
+{
+  if (s == 1)
+    {
+      mpres_set_si (x, -3, n);
+      mpres_set_ui (y, 3, n);
+      mpres_set_ui (z, 1, n);
+    }
+  else if (s == 3)
+    {
+      addchain_param(x, y, z, s-1, t, u, v, w, n);
+      add_param (x, y, z, +1, t, u, v, w, n);
+    }
+  else if (s % 2 == 0)
+    {
+      addchain_param(x, y, z, s/2, t, u, v, w, n);
+      dbl_param (x, y, z, t, u, v, n);
+    }
+  else if (s % 4 == 1)
+    {
+      addchain_param(x, y, z, s-1, t, u, v, w, n);
+      add_param (x, y, z, +1, t, u, v, w, n);
+    }
+  else /* (s % 4 == 3) and s != 3 */
+    {
+      addchain_param(x, y, z, s+1, t, u, v, w, n);
+      add_param (x, y, z, -1, t, u, v, w, n);
+    }
+}
+
+/*Parametrization for BATCHMODE 2: generate curves with a point of order 3 and
+  starting point (2:1) 
+  Compute k*P on y^2=x^3+36 with P=(-3,3); need k>1
+  x3 = (3*x+y+6)/(2*(y-3)) and A=-(3*x3^4+6*x3^2-1)/(4*x3^3)*/
+int 
+get_curve_from_ell_parametrization (mpz_t f, mpres_t A, mpz_t k, mpmod_t n)
+{
+  mpres_t t, u, v, w, x, y, z;
+  unsigned int s;
+
+  MEMORY_TAG;
+  mpres_init (t, n);
+  MEMORY_TAG;
+  mpres_init (u, n);
+  MEMORY_TAG;
+  mpres_init (v, n);
+  MEMORY_TAG;
+  mpres_init (w, n);
+  MEMORY_TAG;
+  mpres_init (x, n);
+  MEMORY_TAG;
+  mpres_init (y, n);
+  MEMORY_TAG;
+  mpres_init (z, n);
+  MEMORY_UNTAG;
+
+  s = mpz_get_ui (k);
+
+  addchain_param (x, y, z, s, t, u, v, w, n); 
+
+  /* Now (x:y:z) = k*P */
+
+  if (!mpres_invert(u, z, n)) 
+    {
+      mpres_gcd (f, z, n);
+      mpres_clear (t, n);
+      mpres_clear (u, n);
+      mpres_clear (v, n);
+      mpres_clear (w, n);
+      mpres_clear (x, n);
+      mpres_clear (y, n);
+      mpres_clear (z, n);
+      return ECM_FACTOR_FOUND_STEP1;
+    }
+
+  mpres_sqr (v, u, n);
+  mpres_mul (u, v, u, n);
+  mpres_mul (x, x, v, n);  
+  mpres_mul (y, y, u, n);  
+
+  mpres_sub_ui (t, y, 3, n);
+  mpres_mul_ui (t, t, 2, n);
+
+  if (!mpres_invert(u, t, n)) 
+    {
+      mpres_gcd (f, t, n);
+      mpres_clear (t, n);
+      mpres_clear (u, n);
+      mpres_clear (v, n);
+      mpres_clear (w, n);
+      mpres_clear (x, n);
+      mpres_clear (y, n);
+      mpres_clear (z, n);
+      return ECM_FACTOR_FOUND_STEP1;
+    }
+  
+  mpres_mul_ui (w, x, 3, n);
+  mpres_add (w, w, y, n);
+  mpres_add_ui (w, w, 6, n);
+  mpres_mul (x, w, u, n);   /* Now x contains x_3 */  
+
+  /* A=-(3*x3^4+6*x3^2-1)/(4*x3^3) */
+  mpres_sqr (u, x, n);
+  mpres_mul (v, u, x, n);
+  mpres_sqr (w, u, n);
+
+  mpres_mul_ui (u, u, 6, n);
+  mpres_neg (u, u, n);
+  mpres_mul_ui (v, v, 4, n);
+  mpres_mul_ui (w, w, 3, n);
+  mpres_neg (w, w, n);
+
+  if (!mpres_invert(t, v, n)) 
+    {
+      mpres_gcd (f, v, n);
+      mpres_clear (t, n);
+      mpres_clear (u, n);
+      mpres_clear (v, n);
+      mpres_clear (w, n);
+      mpres_clear (x, n);
+      mpres_clear (y, n);
+      mpres_clear (z, n);
+      return ECM_FACTOR_FOUND_STEP1;
+    }
+
+  mpres_add (w, w, u, n);
+  mpres_add_ui (w, w, 1, n);
+  mpres_mul (A, w, t, n);
+  mpz_mod (A, A, n->orig_modulus); 
+
+  mpres_clear (t, n);
+  mpres_clear (u, n);
+  mpres_clear (v, n);
+  mpres_clear (w, n);
+  mpres_clear (x, n);
+  mpres_clear (y, n);
+  mpres_clear (z, n);
+
+  return ECM_NO_FACTOR_FOUND;
+}
diff --git a/getprime.c b/getprime.c
index e947bda..5188711 100644
--- a/getprime.c
+++ b/getprime.c
@@ -323,7 +323,7 @@ main (int argc, char *argv[])
   
   for (p = getprime (); p <= B2; p = getprime (), pi++)
     printf("%1.0f\n", p);
-  /* printf ("pi(%1.0f) - pi(%1.0f - 1) = %lu\n", B1, B2, pi); */
+  /* printf ("pi(%1.0f) - pi(%1.0f - 1) = %lu\n", B2, B1, pi); */
 
   getprime_clear ();
 
diff --git a/listz.c b/listz.c
index 4888e31..8c28839 100644
--- a/listz.c
+++ b/listz.c
@@ -606,10 +606,10 @@ list_mulmod (listz_t a2, listz_t a, listz_t b, listz_t c, unsigned int k,
   list_mod (a2, a, 2 * k - 1, n);
 }
 
-/* puts in G[0]..G[k-1] the coefficients from (x-a[0])...(x-a[k-1])
+/* puts in G[0]..G[k-1] the coefficients from (x+a[0])...(x+a[k-1])
    Warning: doesn't fill the coefficient 1 of G[k], which is implicit.
    Needs k + list_mul_mem(k/2) cells in T.
-   G == a is permissible. T must not overlap with anything else
+   G == a is allowed. T must not overlap with anything else.
 */
 void
 PolyFromRoots (listz_t G, listz_t a, unsigned int k, listz_t T, mpz_t n)
@@ -617,76 +617,25 @@ PolyFromRoots (listz_t G, listz_t a, unsigned int k, listz_t T, mpz_t n)
   unsigned int l, m;
 
   ASSERT (T != G && T != a);
+  ASSERT (k >= 1);
 
-  if (k <= 1)
+  if (k == 1)
     {
-      if (k == 1)
-	{
-#if NEGATED_ROOTS == 1
-	  mpz_mod (G[0], a[0], n);
-#else
-	  mpz_neg (T[0], a[0]);
-	  mpz_mod (G[0], T[0], n);
-#endif
-	}
+      /* we consider x + a[0], which mean we consider negated roots */
+      mpz_mod (G[0], a[0], n);
       return;
     }
 
-#if 0
-  /* (x-a[0]) * (x-a[1]) = x^2 - (a[0]+a[1]) * x + a[0]*a[1]
-     however we construct (x+a[0]) * (x+a[1]) instead, i.e. the
-     polynomial with the opposite roots. This has no consequence if
-     we do it for all polynomials: if F(x) and G(x) have a common root,
-     then so do F(-x) and G(-x). This saves one negation.
-     
-     NOT ANY MORE! We added the mpz_neg()'s  so building the poly from
-     its roots works as one would expect in the FastPM1Stage2 algorithm!
-  */
-  if (k == 2)
-    {
-      mpz_mul (T[0], a[0], a[1]);
-      mpz_add (T[1], a[1], a[0]); /* mpz_add may allocate extra limb */
-#if NEGATED_ROOTS == 0
-      mpz_neg (T[1], T[1]);
-#endif
-      mpz_mod (G[1], T[1], n);
-      mpz_mod (G[0], T[0], n);
-      return;
-    }
-#endif
-  
-  m = k / 2; /* m == 1 */
-  l = k - m; /* l == 2 */
+  m = k / 2; /* m >= 1 */
+  l = k - m; /* l >= 1 */
   
   PolyFromRoots (G, a, l, T, n);
   PolyFromRoots (G + l, a + l, m, T, n);
-#if 0
-  {
-    unsigned int i;
-    outputf (OUTPUT_RESVERBOSE, "N=%Zd;", n);
-    outputf (OUTPUT_RESVERBOSE, "(x^%u ", l);
-    for (i = 0; i < l; i++)
-      outputf (OUTPUT_RESVERBOSE, "+ (Mod(%Zd, N) * x^%u) ", G[i], i);
-    outputf (OUTPUT_RESVERBOSE, ") * ( x^%u", m);
-    for (i = 0; i < m; i++)
-      outputf (OUTPUT_RESVERBOSE, "+ (Mod(%Zd, N) * x^%u) ", G[i + l], i);
-    outputf (OUTPUT_RESVERBOSE, ")  ");
-  }
-#endif
   list_mul (T, G, l, 1, G + l, m, 1, T + k);
   list_mod (G, T, k, n);
-#if 0
-  {
-    unsigned int i;
-    outputf (OUTPUT_RESVERBOSE, " == ( x^%u ", k);
-    for (i = 0; i < k; i++)
-      outputf (OUTPUT_RESVERBOSE, "+ (Mod(%Zd, N) * x^%u) ", G[i], i);
-    outputf (OUTPUT_RESVERBOSE, ")\n");
-  } 
-#endif
 }
 
-/* puts in G[0]..G[k-1] the coefficients from (x-a[0])...(x-a[k-1])
+/* puts in G[0]..G[k-1] the coefficients from (x+a[0])...(x+a[k-1])
    Warning: doesn't fill the coefficient 1 of G[k], which is implicit.
    Needs k + list_mul_mem(k/2) cells in T.
    The product tree is stored in:
@@ -696,8 +645,11 @@ PolyFromRoots (listz_t G, listz_t a, unsigned int k, listz_t T, mpz_t n)
    Tree[lgk-1][0..k-1] (degree 1)
    (then we should have initially Tree[lgk-1] = a).
 
-   depth is the depth (0 at root), dolvl signals that only this level of
-   the tree should be computed (-1: all levels)
+   The parameter dolvl signals that only level 'dolvl' of
+   the tree should be computed (dolvl < 0 means all levels).
+
+   Either Tree <> NULL and TreeFile == NULL, and we write the tree to memory,
+   or Tree == NULL and TreeFile <> NULL, and we write the tree to disk.
 */
 int
 PolyFromRoots_Tree (listz_t G, listz_t a, unsigned int k, listz_t T, 
@@ -707,22 +659,16 @@ PolyFromRoots_Tree (listz_t G, listz_t a, unsigned int k, listz_t T,
   unsigned int l, m;
   listz_t H1, *NextTree;
 
-  if (k <= 1)
+  ASSERT (k >= 1);
+
+  if (k == 1)
     {
-      if (k == 1)
-        {
-#if NEGATED_ROOTS == 1
-	  mpz_mod (G[0], a[0], n);
-#else
-	  mpz_neg (a[0], a[0]);
-	  mpz_mod (G[0], a[0], n);
-          mpz_neg (a[0], a[0]);
-#endif
-        }
+      /* we consider x + a[0], which mean we consider negated roots */
+      mpz_mod (G[0], a[0], n);
       return 0;
     }
 
-  if (Tree == NULL)
+  if (Tree == NULL) /* -treefile case */
     {
       H1 = G;
       NextTree = NULL;
@@ -733,41 +679,17 @@ PolyFromRoots_Tree (listz_t G, listz_t a, unsigned int k, listz_t T,
       NextTree = Tree + 1;
     }
 
-#if 0
-  /* (x-a[0]) * (x-a[1]) = x^2 - (a[0]+a[1]) * x + a[0]*a[1]
-     however we construct (x+a[0]) * (x+a[1]) instead, i.e. the
-     polynomial with the opposite roots. This has no consequence if
-     we do it for all polynomials: if F(x) and G(x) have a common root,
-     then so do F(-x) and G(-x). This saves one negation.
-       
-       NOT ANY MORE! We added the mpz_neg() below so building the poly from
-       its roots works as one would expect in the FastPM1Stage2 algorithm!
-  */
-  if (k == 2)
-    {
-      mpz_set (H1[0], a[0]);
-      mpz_set (H1[1], a[1]);
-      mpz_mul (T[0], a[0], a[1]);
-      mpz_add (G[1], a[1], a[0]);
-#if NEGATED_ROOTS == 0
-      mpz_neg (G[1], G[1]);
-#endif
-      mpz_mod (G[1], G[1], n);
-      mpz_mod (G[0], T[0], n);
-      return 0;
-    }
-#endif
-
   m = k / 2;
   l = k - m;
   
-  if (dolvl < 0 || dolvl > 0)
+  if (dolvl != 0) /* either dolvl < 0 and we need to compute all levels,
+                     or dolvl > 0 and we need first to compute lower levels */
     {
       PolyFromRoots_Tree (H1, a, l, T, dolvl - 1, n, NextTree, TreeFile, sh);
       PolyFromRoots_Tree (H1 + l, a + l, m, T, dolvl - 1, n, NextTree, 
                           TreeFile, sh + l);
     }
-  if (dolvl < 0 || dolvl == 0)
+  if (dolvl <= 0)
     {
       /* Write this level to disk, if requested */
       if (TreeFile != NULL)
diff --git a/lucas.c b/lucas.c
index ab6e16b..c47a0f5 100644
--- a/lucas.c
+++ b/lucas.c
@@ -40,7 +40,7 @@
 static void
 pp1_duplicate (mpres_t P, mpres_t Q, mpmod_t n)
 {
-  mpres_mul (P, Q, Q, n);
+  mpres_sqr (P, Q, n);
   mpres_sub_ui (P, P, 2, n);
 }
 
diff --git a/main.c b/main.c
index 737921a..5937c79 100644
--- a/main.c
+++ b/main.c
@@ -64,91 +64,6 @@ static  char *prpcmd = NULL;
 static int exit_asap_value = 0;
 static int exit_asap_signalnr = 0; /* Remembers which signal we received */
 
-/* Tries to read a number from a line from fd and stores it in r.
-   Keeps reading lines until a number is found. Lines beginning with "#"
-     are skipped.
-   Returns 1 if a number was successfully read, 0 if no number can be read
-     (i.e. at EOF)
-   Function is now simpler.  Much of the logic (other than skipping # lines
-     is now contained within eval() function.
-*/
-
-int
-read_number (mpcandi_t *n, FILE *fd, int primetest)
-{
-  int c;
-
-new_line:
-  c = fgetc (fd);
-
-  /* Skip comment lines beginning with '#' */
-  if (c == '#')
-    {
-      do
-        c = fgetc (fd);
-      while (c != EOF && !IS_NEWLINE(c));
-      if (IS_NEWLINE(c))
-        goto new_line;
-    }
-
-  if (c == EOF)
-    return 0;
-
-  ungetc (c, fd);
-  if (!eval (n, fd, primetest))
-    goto new_line;
-
-#if 0
-  /*  Code to test out eval_str function, which "appears" to work correctly. */
-  {
-    /* warning!! Line is pretty small, but since this is just testing code, we
-       can easily control the input for this test.  This code should NEVER be
-       compiled into released build, its only for testing of eval_str() */
-    char Line[500], *cp;
-    fgets (Line, sizeof(Line), fd);
-
-    if (!eval_str (n, Line, primetest, &cp))
-      goto new_line;
-    fprintf (stderr, "\nLine is at %X cp is at %X\n", Line, cp);
-  }
-#endif
-
-#if defined (DEBUG_EVALUATOR)
-  if (n->cpExpr)
-    fprintf (stderr, "%s\n", n->cpExpr);
-  mpz_out_str (stderr, 10, n->n);
-  fprintf (stderr, "\n");
-#endif
-
-  return 1;
-}
-
-int
-probab_prime_p (mpz_t N, int reps)
-{
-#ifdef WANT_SHELLCMD
-  if (prpcmd != NULL)
-    {
-      FILE *fc;
-      int r;
-      fc = popen (prpcmd, "w");
-      if (fc != NULL)
-        {
-          gmp_fprintf (fc, "%Zd\n", N);
-          r = pclose (fc);
-          if (r == 0) /* Exit status of 0 means success = is a PRP */
-            return 1;
-          else
-            return 0;
-        } else {
-          fprintf (stderr, "Error executing the PRP command\n");
-          exit (EXIT_FAILURE);
-        }
-    } else
-#endif
-      return mpz_probab_prime_p (N, reps);
-}
-
 void
 signal_handler (int sig)
 {
@@ -207,7 +122,7 @@ usage (void)
     printf ("  -resume file resume residues from file, reads from stdin if file is \"-\"\n");
     printf ("  -chkpnt file save periodic checkpoints during stage 1 to file\n");
     printf ("  -primetest   perform a primality test on input\n");
-    printf ("  -treefile f  store product tree of F in files f.0 f.1 ... \n");
+    printf ("  -treefile f  [ECM only] store stage 2 data in files f.0, ... \n");
     printf ("  -maxmem n    use at most n MB of memory in stage 2\n");
     printf ("  -stage1time n add n seconds to ECM stage 1 time (for expected time est.)\n");
 #ifdef WANT_SHELLCMD
@@ -234,8 +149,10 @@ usage (void)
     printf ("               or can use N as a placeholder for the number being factored.\n");
     printf ("  -printconfig Print compile-time configuration and exit.\n");
 
-    printf ("  -batch       (experimental) use Montgomery parametrization and batch\n" 
-					  "               computation.\n");
+    printf ("  -batch[=1|2] (experimental) use Montgomery parametrization and batch\n" 
+					  "               computation. Option -batch is equivalent to -batch=1\n");
+    printf ("  -bsaves file In the batch mode, save s in file.\n");
+    printf ("  -bloads file In the batch mode, load s from file.\n");
 
     printf ("  -h, --help   Prints this help and exit.\n");
 }
@@ -297,16 +214,6 @@ print_config ()
 
 #ifdef USE_ASM_REDC
   printf ("USE_ASM_REDC = %d\n", USE_ASM_REDC);
-#ifdef TUNE_MULREDC_THRESH
-  printf ("TUNE_MULREDC_THRESH = %d\n", TUNE_MULREDC_THRESH);
-#else
-  printf ("TUNE_MULREDC_THRESH undefined\n");
-#endif
-#ifdef TUNE_SQRREDC_THRESH
-  printf ("TUNE_SQRREDC_THRESH = %d\n", TUNE_SQRREDC_THRESH);
-#else
-  printf ("TUNE_SQRREDC_THRESH undefined\n");
-#endif
 #ifdef WINDOWS64_ABI
   printf ("WINDOWS64_ABI = %d\n", WINDOWS64_ABI);
 #else
@@ -454,6 +361,8 @@ main (int argc, char *argv[])
   double stage1time = 0.;
   ecm_params params;
   int batch = 0; /* By default we don't use batch mode */
+  char *savefile_s = NULL;
+  char *loadfile_s = NULL;
 #ifdef WANT_SHELLCMD
   char *faccmd = NULL;
   char *idlecmd = NULL;
@@ -583,12 +492,31 @@ main (int argc, char *argv[])
 	  argv++;
 	  argc--;
         }
-      else if (strcmp (argv[1], "-batch") == 0)
+      else if (strcmp (argv[1], "-batch") == 0 || 
+                                            strcmp (argv[1], "-batch=1") == 0)
         {
 	  batch = 1;
 	  argv++;
 	  argc--;
         }
+      else if (strcmp (argv[1], "-batch=2") == 0)
+        {
+	  batch = 2;
+	  argv++;
+	  argc--;
+        }
+      else if ((argc > 2) && (strcmp (argv[1], "-bsaves") == 0))
+        {
+          savefile_s = argv[2];
+          argv += 2;
+          argc -= 2;
+        }
+      else if ((argc > 2) && (strcmp (argv[1], "-bloads") == 0))
+        {
+          loadfile_s = argv[2];
+          argv += 2;
+          argc -= 2;
+        }
       else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0)
         {
           usage ();
@@ -1064,6 +992,13 @@ main (int argc, char *argv[])
   params->maxmem = maxmem;
   params->stage1time = stage1time;
 
+  /* -treefile is valid for ECM only */
+  if (TreeFilename != NULL && method != ECM_ECM)
+    {
+      fprintf (stderr, "Error: the -treefile option is for ECM only\n");
+      exit (EXIT_FAILURE);
+    }
+
   /* Open resume file for reading, if resuming is requested */
   if (resumefilename != NULL)
     {
@@ -1464,29 +1399,15 @@ BreadthFirstDoAgain:;
          If A was given one should check that d fits in one word and that x0=2.
          If A was not given one chooses it at random (and if x0 exists
          it must be 2). */
-      if (batch == 1)
+      if (batch != 0)
         {
-          static int random = 0; /* non-zero if user asked for random curves */
-
           if (method != ECM_ECM)
             {
               fprintf (stderr, "Error, the -batch option is only valid for ECM\n");
               exit (EXIT_FAILURE);
             }
           mpz_set_ui (sigma, 0); 
-          if (random || (mpz_sgn (A) == 0)) /* A was not given by the user */
-            {
-              random = 1;
-              /* We need that d = (A+2)/4 is smaller than 2^GMP_NUMB_BITS */
-              mpz_urandomb (A, randstate, 32);  /* generates d */
-              if (GMP_NUMB_BITS >= 64)
-                mpz_mul (A, A, A);              /* ensures d is a square,
-                                                   which increases the success
-                                                   probability */
-              mpz_mul_2exp (A, A, 2);           /* 4d */
-              mpz_sub_ui (A, A, 2);             /* 4d-2 */
-            }
-          
+
           if (mpz_sgn (orig_x0) == 0)
             mpz_set_ui (orig_x0, 2);
           else if (mpz_cmp_ui (orig_x0, 2) != 0)
@@ -1498,26 +1419,44 @@ BreadthFirstDoAgain:;
           
           mpz_set (x, orig_x0);
         }
-      /* set parameters that may change from one curve to another */
       params->batch = batch;
-      if (params->batch == 1 && params->batch_B1 != B1)
+      if (params->batch != 0 && params->batch_B1 != B1)
         {
           int st;
           params->batch_B1 = B1;
 
           if (verbose > OUTPUT_NORMAL)
-            printf ("Batch mode: \n");
+            printf ("Batch mode %d: ", batch);
           st = cputime ();
           /* construct the batch exponent */
-          compute_s (params->batch_s, params->batch_B1);
-          if (verbose > OUTPUT_NORMAL)
-            printf ("  computing prime product of %lu bits took %ldms\n",
+          if (loadfile_s != NULL)
+            {
+            /* For now, there is no check that it correspond to the actual B1*/
+              read_s_from_file (params->batch_s, loadfile_s);
+              if (verbose > OUTPUT_NORMAL)
+                printf ("reading prime product of %zu bits took %ldms\n",
                     mpz_sizeinbase (params->batch_s, 2), cputime () - st);
+            }
+          else
+            {
+              compute_s (params->batch_s, params->batch_B1);
+              if (verbose > OUTPUT_NORMAL)
+                printf ("computing prime product of %zu bits took %ldms\n",
+                    mpz_sizeinbase (params->batch_s, 2), cputime () - st);
+              if (savefile_s != NULL)
+                {
+                  int ret = write_s_in_file (savefile_s, params->batch_s);
+                  if (verbose > OUTPUT_NORMAL && ret > 0)
+                    printf ("Save s (%u bytes) in %s.\n", ret, savefile_s);
+                }
+            }
         }
+
+      /* set parameters that may change from one curve to another */
       params->method = method; /* may change with resume */
       mpz_set (params->x, x); /* may change with resume */
       /* if sigma is zero, then we use the A value instead */
-      params->sigma_is_A = ((mpz_sgn (sigma) == 0 || batch==1)? 1 : 0);
+      params->sigma_is_A = ((mpz_sgn (sigma) == 0 || batch != 0) ? 1 : 0);
       mpz_set (params->sigma, (params->sigma_is_A) ? A : sigma);
       mpz_set (params->go, go.Candi.n); /* may change if contains N */
       mpz_set (params->B2min, B2min); /* may change with -c */
diff --git a/mpmod.c b/mpmod.c
index c645f0a..e0ad18e 100644
--- a/mpmod.c
+++ b/mpmod.c
@@ -1,6 +1,6 @@
 /* Modular multiplication.
 
-  Copyright 2002, 2003, 2004, 2005, 2011 Paul Zimmermann and Alexander Kruppa.
+  Copyright 2002, 2003, 2004, 2005, 2011, 2012 Paul Zimmermann, Alexander Kruppa and Cyril Bouvier.
 
   This file is part of the ECM Library.
 
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include "ecm-gmp.h"
 #include "ecm-impl.h"
+#include "mpmod.h"
 
 #ifdef USE_ASM_REDC
   #include "mulredc.h"
@@ -71,7 +72,7 @@ mpmod_tune_base2 (const mpz_t n, int K, int base2)
   mpres_sub_ui (x, x, 1, modulus); /* so that the initial value is dense */
   t0 = cputime ();
   for (k = 0; k < K; k++)
-    mpres_mul (x, x, x, modulus);
+    mpres_sqr (x, x, modulus);
   t0 = cputime () - t0;
 
   mpres_clear (x, modulus);
@@ -85,7 +86,7 @@ mpmod_tune_base2 (const mpz_t n, int K, int base2)
   mpres_sub_ui (x, x, 1, modulus); /* so that the initial value is dense */
   t1 = cputime ();
   for (k = 0; k < K; k++)
-    mpres_mul (x, x, x, modulus);
+    mpres_sqr (x, x, modulus);
   t1 = cputime () - t1;
 
   fprintf (stderr, "ECM_MOD_NOBASE2:%ld ECM_MOD_BASE2:%ld\n", t0, t1);
@@ -229,7 +230,7 @@ base2mod_2 (mpres_t R, const mpres_t S, mp_size_t n, mpz_t modulus)
  */
 static void
 ecm_redc_n (mp_ptr rp, mp_srcptr x0p, mp_size_t xn,
-            mp_srcptr orig, mp_srcptr aux, mp_size_t n)
+            mp_srcptr orig, mp_srcptr invm, mp_size_t n)
 {
   mp_ptr tp, up, xp;
   mp_size_t nn = n + n;
@@ -247,9 +248,9 @@ ecm_redc_n (mp_ptr rp, mp_srcptr x0p, mp_size_t xn,
   else
     xp = (mp_ptr) x0p;
 #ifdef HAVE___GMPN_MULLO_N /* available up from GMP 5.0.0 */
-  __gmpn_mullo_n (up, xp, aux, n);
+  __gmpn_mullo_n (up, xp, invm, n);
 #else
-  ecm_mul_lo_n (up, xp, aux, n);
+  ecm_mul_lo_n (up, xp, invm, n);
 #endif
   tp = up + nn;
   mpn_mul_n (tp, up, orig, n);
@@ -264,9 +265,13 @@ ecm_redc_n (mp_ptr rp, mp_srcptr x0p, mp_size_t xn,
   cy = mpn_add_n (rp, tp + n, xp + n, n);
   cy += mpn_add_1 (rp, rp, n, (mp_limb_t) ((xp[n - 1] | tp[n - 1]) ? 1 : 0));
 #endif
-  if (cy || mpn_cmp (rp, orig, n) > 0)
+  /* when N < B^n/4, we don't need to perform this last reduction,
+     if we allow residues in [0, 2N).
+     See for example the slides from David Harvey at Sage Days 35
+     (http://wiki.sagemath.org/SageFlintDays/slides) */
+  if (orig[n-1] >> (GMP_NUMB_BITS - 2) && (cy || mpn_cmp (rp, orig, n) > 0))
     cy -= mpn_sub_n (rp, rp, orig, n);
-  /* ASSERT ((cy == 0) && (mpn_cmp (rp, orig, n) < 0)); */
+  ASSERT (cy == 0);
   TMP_FREE(marker);
 }
 
@@ -286,7 +291,7 @@ REDC (mpres_t r, const mpres_t x, mpz_t t, mpmod_t modulus)
       MPZ_REALLOC (r, n);
       rp = PTR(r);
       ecm_redc_n (rp, PTR(x), xn, PTR(modulus->orig_modulus),
-		PTR(modulus->aux_modulus), n);
+                  PTR(modulus->aux_modulus), n);
       MPN_NORMALIZE(rp, n);
       SIZ(r) = (SIZ(x) > 0) ? (int) n : (int) -n;
       MPZ_NORMALIZED (r);
@@ -318,13 +323,6 @@ redc_basecase_n (mp_ptr rp, mp_ptr cp, mp_srcptr np, const mp_size_t nn,
   __gmpn_redc_1 (rp, cp, np, nn, invm[0]);
 #else /* neither HAVE___GMPN_REDC_2 nor HAVE___GMPN_REDC_1 is defined */
   mp_limb_t cy;
-/* ecm_redc3 is assembly code for variable size redc, defined in
-   xxx/redc.asm for xxx={pentium4,athlon,x86_64,powerpc64} */
-#if defined(HAVE_ASM_REDC3)
-  ecm_redc3 (cp, np, nn, invm[0]);
-  /* add vector of carries and shift */
-  cy = mpn_add_n (rp, cp + nn, cp, nn);
-#else
   mp_size_t j;
   
   for (j = 0; j < nn; j++)
@@ -336,7 +334,6 @@ redc_basecase_n (mp_ptr rp, mp_ptr cp, mp_srcptr np, const mp_size_t nn,
     }
   /* add vector of carries and shift */
   cy = mpn_add_n (rp, cp, cp - nn, nn);
-#endif /* HAVE_ASM_REDC3 */
   /* the result of Montgomery's REDC is less than 2^Nbits + N,
      thus at most one correction is enough */
   if (cy != 0)
@@ -466,6 +463,65 @@ mulredc (mp_ptr z, mp_srcptr x, mp_srcptr y, mp_srcptr m,
     }
 }
 
+/* {rp, n} <- {ap, n}^2/B^n mod {np, n} where B = 2^GMP_NUMB_BITS */
+ATTRIBUTE_UNUSED static void
+sqrredc (mp_ptr rp, mp_srcptr ap, mp_srcptr np, const mp_size_t n,
+         const mp_limb_t invm)
+{
+  mp_ptr cp;
+  mp_size_t i;
+  mp_limb_t cy, q;
+  TMP_DECL(marker);
+
+  TMP_MARK(marker);
+  cp = TMP_ALLOC_LIMBS(2*n);
+  for (i = 0; i < n; i++)
+    umul_ppmm (cp[2*i+1], cp[2*i], ap[i], ap[i]);
+
+  if (UNLIKELY(n == 1))
+    {
+      q = cp[0] * invm;
+      rp[0] = mpn_addmul_1 (cp, np, 1, q);
+      cy = mpn_add_n (rp, rp, cp + 1, 1);
+      goto end_sqrredc;
+    }
+
+  if (cp[0] & (mp_limb_t) 1)
+    /* cp[n] is either some ap[i]^2 mod B or floor(ap[i]^2/B),
+       the latter is at most floor((B-1)^2/B) = B-2, and the former cannot be
+       B-1 since -1 is not a square mod 2^n for n >1, thus there is no carry
+       in cp[n] + ... below */
+    cp[n] += mpn_add_n (cp, cp, np, n);
+  /* now {cp, 2n} is even: divide by two */
+  mpn_rshift (cp, cp, 2*n, 1);
+  /* now cp[2n-1] is at most B/2-1 */
+
+  for (i = 0; i < n - 1; i++)
+    {
+      q = cp[i] * invm;
+      cp[i] = mpn_addmul_1 (cp + i, np, n, q);
+      /* accumulate ap[i+1..n-1] * ap[i] */
+      rp[i] = mpn_addmul_1 (cp + 2 * i + 1, ap + i + 1, n - 1 - i, ap[i]);
+    }
+  /* the last iteration did set cp[n-2] to zero, accumulated a[n-1] * a[n-2] */
+
+  /* cp[2n-1] was untouched so far, so it is still at most B/2-1 */
+  q = cp[n-1] * invm;
+  rp[n-1] = mpn_addmul_1 (cp + n - 1, np, n, q);
+  /* rp[n-1] <= floor((B^n-1)*(B-1)/B^n)<=B-2 */
+
+  /* now add {rp, n}, {cp+n, n} and {cp, n-1} */
+  /* cp[2n-1] still <= B/2-1 */
+  rp[n-1] += mpn_add_n (rp, rp, cp, n-1); /* no overflow in rp[n-1] + ... */
+  cy = mpn_add_n (rp, rp, cp + n, n);
+  /* multiply by 2 */
+  cy = (cy << 1) + mpn_lshift (rp, rp, n, 1);
+ end_sqrredc:
+  while (cy)
+    cy -= mpn_sub_n (rp, rp, np, n);
+  TMP_FREE(marker);
+}
+
 #ifdef HAVE_NATIVE_MULREDC1_N
 /* Multiplies y by the 1-limb value of x and does modulo reduction.
    The resulting residue may be multiplied by some constant, 
@@ -555,21 +611,130 @@ mulredc_1 (mp_ptr z, const mp_limb_t x, mp_srcptr y, mp_srcptr m,
 #endif /* ifdef HAVE_NATIVE_MULREDC1_N */
 #endif
 
-#if defined(USE_ASM_REDC) && !defined(TUNE_MULREDC_THRESH)
-#ifdef TUNE
-  extern mp_size_t TUNE_MULREDC_THRESH;
-#else
-  const mp_size_t TUNE_MULREDC_THRESH = 20;
-#endif
-#endif
-#if defined(USE_ASM_REDC) && !defined(TUNE_SQRREDC_THRESH)
-#ifdef TUNE
-  extern mp_size_t TUNE_SQRREDC_THRESH;
-#else
-  const mp_size_t TUNE_SQRREDC_THRESH = 20;
+#ifndef TUNE_MULREDC_TABLE
+#define TUNE_MULREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
 #endif
+#ifndef TUNE_SQRREDC_TABLE
+#define TUNE_SQRREDC_TABLE {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
 #endif
 
+static int tune_mulredc_table[] = TUNE_MULREDC_TABLE;
+static int tune_sqrredc_table[] = TUNE_SQRREDC_TABLE;
+
+static void 
+ecm_mulredc_basecase_n (mp_ptr rp, mp_srcptr s1p, mp_srcptr s2p, 
+                        mp_srcptr np, mp_size_t nn, mp_ptr invm, mp_ptr tmp)
+{
+  mp_limb_t cy;
+  mp_size_t j;
+
+  if (nn <= MULREDC_ASSEMBLY_MAX)
+    {
+      switch (tune_mulredc_table[nn])
+        {
+        case MPMOD_MULREDC: /* use quadratic assembly mulredc */
+#ifdef USE_ASM_REDC
+          mulredc (rp, s1p, s2p, np, nn, invm[0]);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC1: /* mpn_mul_n + __gmpn_redc_1 */
+#if defined(HAVE___GMPN_REDC_1)
+          mpn_mul_n (tmp, s1p, s2p, nn);
+          __gmpn_redc_1 (rp, tmp, np, nn, invm[0]);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC2: /* mpn_mul_n + __gmpn_redc_2 */
+#if defined(HAVE___GMPN_REDC_2)
+          mpn_mul_n (tmp, s1p, s2p, nn);
+          __gmpn_redc_2 (rp, tmp, np, nn, invm);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDCN: /* mpn_mul_n + __gmpn_redc_n */
+#if defined(HAVE___GMPN_REDC_N)
+          mpn_mul_n (tmp, s1p, s2p, nn);
+          __gmpn_redc_n (rp, tmp, np, nn, invm);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC_C: /* plain C quadratic reduction */
+          mpn_mul_n (tmp, s1p, s2p, nn);
+          for (j = 0; j < nn; j++, tmp++)
+            tmp[0] = mpn_addmul_1 (tmp, np, nn, tmp[0] * invm[0]);
+          cy = mpn_add_n (rp, tmp - nn, tmp, nn);
+          if (cy != 0)
+            mpn_sub_n (rp, rp, np, nn); /* a borrow should always occur here */
+          break;
+        default:
+          {
+            outputf (OUTPUT_ERROR, "Invalid mulredc mode: %d\n",
+                     tune_mulredc_table[nn]);
+            exit (EXIT_FAILURE);
+          }
+        }
+    }
+  else /* nn > MULREDC_ASSEMBLY_MAX */
+    {
+      mpn_mul_n (tmp, s1p, s2p, nn);
+      ecm_redc_n (rp, tmp, 2 * nn, np, invm, nn);
+    }
+}
+
+static void 
+ecm_sqrredc_basecase_n (mp_ptr rp, mp_srcptr s1p,
+                        mp_srcptr np, mp_size_t nn, mp_ptr invm, mp_ptr tmp)
+{
+  mp_limb_t cy;
+  mp_size_t j;
+
+  if (nn <= MULREDC_ASSEMBLY_MAX)
+    {
+      switch (tune_sqrredc_table[nn])
+        {
+        case MPMOD_MULREDC: /* use quadratic assembly mulredc */
+#ifdef USE_ASM_REDC
+          mulredc (rp, s1p, s1p, np, nn, invm[0]);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC1: /* mpn_sqr + __gmpn_redc_1 */
+#if defined(HAVE___GMPN_REDC_1)
+          mpn_sqr (tmp, s1p, nn);
+          __gmpn_redc_1 (rp, tmp, np, nn, invm[0]);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC2: /* mpn_sqr + __gmpn_redc_2 */
+#if defined(HAVE___GMPN_REDC_2)
+          mpn_sqr (tmp, s1p, nn);
+          __gmpn_redc_2 (rp, tmp, np, nn, invm);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDCN: /* mpn_sqr + __gmpn_redc_n */
+#if defined(HAVE___GMPN_REDC_N)
+          mpn_sqr (tmp, s1p, nn);
+          __gmpn_redc_n (rp, tmp, np, nn, invm);
+          break;
+#endif /* otherwise go through to the next available mode */
+        case MPMOD_MUL_REDC_C: /* plain C quadratic reduction */
+          mpn_sqr (tmp, s1p, nn);
+          for (j = 0; j < nn; j++, tmp++)
+            tmp[0] = mpn_addmul_1 (tmp, np, nn, tmp[0] * invm[0]);
+          cy = mpn_add_n (rp, tmp - nn, tmp, nn);
+          if (cy != 0)
+            mpn_sub_n (rp, rp, np, nn); /* a borrow should always occur here */
+          break;
+        default:
+          {
+            outputf (OUTPUT_ERROR, "Invalid sqrredc mode: %d\n",
+                     tune_sqrredc_table[nn]);
+            exit (EXIT_FAILURE);
+          }
+        }
+    }
+  else /* nn > MULREDC_ASSEMBLY_MAX */
+    {
+      mpn_sqr (tmp, s1p, nn);
+      ecm_redc_n (rp, tmp, 2 * nn, np, invm, nn);
+    }
+}
+
 /* R <- S1 * S2 mod modulus
    i.e. R <- S1*S2/r^nn mod n, where n has nn limbs, and r=2^GMP_NUMB_BITS.
    Same as ecm_redc_basecase previous, but combined with mul
@@ -578,36 +743,22 @@ static void
 ecm_mulredc_basecase (mpres_t R, const mpres_t S1, const mpres_t S2, 
                       mpmod_t modulus)
 {
-  mp_ptr rp;
-  mp_ptr s1p, s2p;
-  mp_srcptr np;
+  mp_ptr s1p, s2p, rp = PTR(R);
   mp_size_t j, nn = modulus->bits / GMP_NUMB_BITS;
 
   ASSERT(ALLOC(R) >= nn);
   ASSERT(ALLOC(S1) >= nn);
   ASSERT(ALLOC(S2) >= nn);
-  rp = PTR(R);
   s1p = PTR(S1);
   s2p = PTR(S2);
-  np = PTR(modulus->orig_modulus);
   /* FIXME: S1 and S2 are input and marked const, we mustn't write to them */
   for (j = ABSIZ(S1); j < nn; j++) 
     s1p[j] = 0;
   for (j = ABSIZ(S2); j < nn; j++) 
     s2p[j] = 0;
 
-#if defined(USE_ASM_REDC)
-  if (nn <= TUNE_MULREDC_THRESH)
-    mulredc (rp, s1p, s2p, np, nn, modulus->Nprim[0]);
-  else
-#endif
-    {
-      mp_ptr tmp = PTR(modulus->temp1);
-      ASSERT(ALLOC(modulus->temp1) >= 2*nn);
-      ASSERT(tmp != s1p && tmp != s2p);
-      mpn_mul_n (tmp, s1p, s2p, nn);
-      redc_basecase_n (rp, tmp, np, nn, modulus->Nprim);
-    }
+  ecm_mulredc_basecase_n (rp, s1p, s2p, PTR(modulus->orig_modulus), nn,
+                          modulus->Nprim, PTR(modulus->temp1));
 
   MPN_NORMALIZE (rp, nn);
   SIZ(R) = (SIZ(S1)*SIZ(S2)) < 0 ? (int) -nn : (int) nn;
@@ -622,34 +773,18 @@ ecm_sqrredc_basecase (mpres_t R, const mpres_t S1, mpmod_t modulus)
 {
   mp_ptr rp;
   mp_ptr s1p;
-  mp_srcptr np;
   mp_size_t j, nn = modulus->bits / GMP_NUMB_BITS;
 
   ASSERT(ALLOC(R) >= nn);
   ASSERT(ALLOC(S1) >= nn);
   rp = PTR(R);
   s1p = PTR(S1);
-  np = PTR(modulus->orig_modulus);
   /* FIXME: S1 is input and marked const, we mustn't write to it */
   for (j = ABSIZ(S1); j < nn; j++)
     s1p[j] = 0;
 
-#if defined(USE_ASM_REDC)
-  if (nn <= TUNE_SQRREDC_THRESH)
-    mulredc (rp, s1p, s1p, np, nn, modulus->Nprim[0]);
-  else
-#endif
-    { /* first square, then reduce */
-      mp_ptr tmp = PTR(modulus->temp1);
-      ASSERT(ALLOC(modulus->temp1) >= 2*nn);
-      ASSERT(tmp != s1p);
-#ifdef HAVE_MPN_SQR
-      mpn_sqr (tmp, s1p, nn);
-#else
-      mpn_mul_n (tmp, s1p, s1p, nn);
-#endif
-      redc_basecase_n (rp, tmp, np, nn, modulus->Nprim);
-    }
+  ecm_sqrredc_basecase_n (rp, s1p, PTR(modulus->orig_modulus), nn,
+                          modulus->Nprim, PTR(modulus->temp1));
 
   MPN_NORMALIZE (rp, nn);
   SIZ(R) = (int) nn;
@@ -704,6 +839,7 @@ int
 mpmod_init (mpmod_t modulus, const mpz_t N, int repr)
 {
   int base2 = 0, r = 0;
+  mp_size_t n = mpz_size (N);
 
   switch (repr)
     {
@@ -733,7 +869,9 @@ mpmod_init (mpmod_t modulus, const mpz_t N, int repr)
       mpmod_init_MPZ (modulus, N);
       break;
     case ECM_MOD_MODMULN:
-      outputf (OUTPUT_VERBOSE, "Using MODMULN\n");
+      outputf (OUTPUT_VERBOSE, "Using MODMULN [mulredc:%d, sqrredc:%d]\n",
+               (n <= MULREDC_ASSEMBLY_MAX) ? tune_mulredc_table[n] : 4,
+               (n <= MULREDC_ASSEMBLY_MAX) ? tune_sqrredc_table[n] : 4);
       mpmod_init_MODMULN (modulus, N);
       break;
     case ECM_MOD_REDC:
@@ -748,7 +886,7 @@ mpmod_init (mpmod_t modulus, const mpz_t N, int repr)
       ASSERT (r == 0); /* error should not happen if isbase2 is correct */
       break;
     }
-  
+
   return r;
 }
 
@@ -770,6 +908,7 @@ mpmod_init_MPZ (mpmod_t modulus, const mpz_t N)
   n = mpz_size (N); /* number of limbs of N */
   modulus->bits = n * GMP_NUMB_BITS; /* Number of bits, 
 					rounded up to full limb */
+
   MPZ_INIT2 (modulus->temp1, 2UL * modulus->bits + GMP_NUMB_BITS);
   MPZ_INIT2 (modulus->temp2, modulus->bits);
   MPZ_INIT2 (modulus->aux_modulus, modulus->bits);
@@ -796,6 +935,7 @@ mpmod_init_BASE2 (mpmod_t modulus, const int base2, const mpz_t N)
 
   Nbits = mpz_size (N) * GMP_NUMB_BITS; /* Number of bits, rounded
                                            up to full limb */
+
   MPZ_INIT2 (modulus->temp1, 2UL * Nbits + GMP_NUMB_BITS);
   MPZ_INIT2 (modulus->temp2, Nbits);
   
@@ -829,6 +969,15 @@ mpmod_init_BASE2 (mpmod_t modulus, const int base2, const mpz_t N)
   return 0;
 }
 
+/* initialize the following fields:
+   orig_modulus - the original modulus
+   bits         - # of bits of N, rounded up to a multiple of GMP_NUMB_BITS
+   temp1, temp2 - auxiliary variables
+   Nprim        - -1/N mod B^n where B=2^GMP_NUMB_BITS and n = #limbs(N)
+   R2           - (2^bits)^2 (mod N)
+   R3           - (2^bits)^3 (mod N)
+   multiple     - smallest multiple of N >= 2^bits
+ */
 void
 mpmod_init_MODMULN (mpmod_t modulus, const mpz_t N)
 {
@@ -844,18 +993,8 @@ mpmod_init_MODMULN (mpmod_t modulus, const mpz_t N)
   modulus->bits = Nbits;
 
   MPZ_INIT2 (modulus->temp1, 2UL * Nbits + GMP_NUMB_BITS);
-  MPZ_INIT2 (modulus->temp2, Nbits);
-
-  mpz_set_ui (modulus->temp1, 1UL);
-  mpz_mul_2exp (modulus->temp1, modulus->temp1, 2 * GMP_NUMB_BITS);
-  mpz_tdiv_r_2exp (modulus->temp2, modulus->orig_modulus, 
-                   2 * GMP_NUMB_BITS);
-  mpz_invert (modulus->temp2, modulus->temp2, modulus->temp1);
-  /* Now temp2 = 1/n (mod 2^(2*GMP_NUMB_BITS)) */
-  mpz_sub (modulus->temp2, modulus->temp1, modulus->temp2);
-  modulus->Nprim[0] = mpz_getlimbn (modulus->temp2, 0);
-  modulus->Nprim[1] = mpz_getlimbn (modulus->temp2, 1);
-  /* Now Nprim = -1/n (mod 2^(2*GMP_NUMB_BITS)) */
+  MPZ_INIT2 (modulus->temp2, Nbits + 1);
+  modulus->Nprim = (mp_limb_t*) malloc (mpz_size (N) * sizeof (mp_limb_t));
 
   MPZ_INIT2 (modulus->R2, Nbits);
   mpz_set_ui (modulus->temp1, 1UL);
@@ -875,6 +1014,17 @@ mpmod_init_MODMULN (mpmod_t modulus, const mpz_t N)
   mpz_cdiv_q (modulus->temp1, modulus->temp1, modulus->orig_modulus);
   mpz_mul (modulus->multiple, modulus->temp1, modulus->orig_modulus);
   /* Now multiple is the smallest multiple of N >= 2^bits */
+
+  mpz_set_ui (modulus->temp1, 1UL);
+  mpz_mul_2exp (modulus->temp1, modulus->temp1, Nbits);
+  /* since we directly check even modulus in ecm/pm1/pp1,
+     N is odd here, thus 1/N mod 2^Nbits always exist */
+  mpz_invert (modulus->temp2, N, modulus->temp1); /* temp2 = 1/N mod B^n */
+  mpz_sub (modulus->temp2, modulus->temp1, modulus->temp2);
+  /* temp2 = -1/N mod B^n */
+  /* ensure Nprim has all its n limbs correctly set, for ecm_redc_n */
+  MPN_ZERO(modulus->Nprim, mpz_size (N));
+  mpn_copyi (modulus->Nprim, PTR(modulus->temp2), ABSIZ(modulus->temp2));
 }
 
 void 
@@ -946,20 +1096,22 @@ mpmod_clear (mpmod_t modulus)
       mpz_clear (modulus->R3);
       mpz_clear (modulus->multiple);
     }
+  if (modulus->repr == ECM_MOD_MODMULN)
+    free (modulus->Nprim);
   
   return;
 }
 
-
+/* initialize r and set all entries from those of modulus */
 void
-mpmod_copy (mpmod_t r, const mpmod_t modulus)
+mpmod_init_set (mpmod_t r, const mpmod_t modulus)
 {
   const unsigned long Nbits = abs(modulus->bits);
+  const unsigned long n = mpz_size (modulus->orig_modulus);
+
   r->repr = modulus->repr;
   r->bits = modulus->bits;
   r->Fermat = modulus->Fermat;
-  r->Nprim[0] = modulus->Nprim[0];
-  r->Nprim[1] = modulus->Nprim[1];
   mpz_init_set (r->orig_modulus, modulus->orig_modulus);
   MPZ_INIT2 (r->temp1, 2 * Nbits + GMP_NUMB_BITS);
   MPZ_INIT2 (r->temp2, Nbits + GMP_NUMB_BITS);
@@ -977,6 +1129,11 @@ mpmod_copy (mpmod_t r, const mpmod_t modulus)
       MPZ_INIT2 (r->aux_modulus, Nbits);
       mpz_set (r->aux_modulus, modulus->aux_modulus);
     }
+  if (modulus->repr == ECM_MOD_MODMULN)
+    {
+      r->Nprim = (mp_limb_t*) malloc (n * sizeof (mp_limb_t));
+      mpn_copyi (r->Nprim, modulus->Nprim, n);
+    }
 }
 
 
@@ -1872,7 +2029,7 @@ mpres_invert (mpres_t R, const mpres_t S, mpmod_t modulus)
 
   if (mpz_invert (modulus->temp2, S, modulus->orig_modulus) == 0)
     return 0;
-
+  
   if (modulus->repr == ECM_MOD_MPZ || modulus->repr == ECM_MOD_BASE2)
     {
       mpz_set (R, modulus->temp2);
@@ -1955,3 +2112,253 @@ mpmod_selftest (const mpz_t n)
 
   return 0;
 }
+
+/****************************************************/
+/* mpresn: modular arithmetic based directly on mpn */
+/****************************************************/
+
+/* We use here a signed word-based redundant representation.
+
+   In case N < B^n/16 (since for redc where we add to the absolute value of
+   the residue), where n is the number of limbs of N in base B (2^32 or 2^64
+   usually), we can prove there is no adjustment (adding or subtracting N),
+   cf http://www.loria.fr/~zimmerma/papers/norm.pdf.
+
+   However current branch predictors are quite good, thus we prefer to keep
+   the tests and to allow any input N (instead of only N < B^n/16).
+*/
+
+/* ensure R has allocated space for at least n limbs,
+   and if less than n limbs are used, pad with zeros,
+   and set SIZ(R) to n if positive or -n if negative */
+void
+mpresn_pad (mpres_t R, mpmod_t N)
+{
+  mp_size_t n = ABSIZ(N->orig_modulus);
+  mp_size_t rn;
+
+  _mpz_realloc (R, n);
+  rn = mpz_size (R);
+  ASSERT_ALWAYS (rn <= n);
+  if (rn < n)
+    {
+      MPN_ZERO (PTR(R) + rn, n - rn);
+      SIZ(R) = SIZ(R) >= 0 ? n : -n;
+    }
+}
+
+void
+mpresn_unpad (mpres_t R)
+{
+  mp_size_t n = ABSIZ(R);
+
+  while (n > 0 && PTR(R)[n-1] == 0)
+    n--;
+  SIZ(R) = SIZ(R) >= 0 ? n : -n;
+}
+
+/* R <- S1 * S1 mod N, used only for ECM_MOD_MODMULN */
+void 
+mpresn_sqr (mpres_t R, const mpres_t S1, mpmod_t modulus)
+{
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+
+  ASSERT (SIZ(S1) == n || -SIZ(S1) == n);
+
+  ecm_sqrredc_basecase_n (PTR(R), PTR(S1), PTR(modulus->orig_modulus),
+                          n, modulus->Nprim, PTR(modulus->temp1));
+
+  SIZ(R) = n;
+}
+
+/* R <- S1 * S2 mod N, used only for ECM_MOD_MODMULN */
+void 
+mpresn_mul (mpres_t R, const mpres_t S1, const mpres_t S2, mpmod_t modulus)
+{
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+
+  ASSERT (SIZ(S1) == n || -SIZ(S1) == n);
+  ASSERT (SIZ(S2) == n || -SIZ(S2) == n);
+
+  ecm_mulredc_basecase_n (PTR(R), PTR(S1), PTR(S2), PTR(modulus->orig_modulus),
+                          n, modulus->Nprim, PTR(modulus->temp1));
+
+  SIZ(R) = SIZ(S1) == SIZ(S2) ? n : -n;
+}
+
+/* R <- S*m/B mod modulus where m fits in a mp_limb_t.
+   Here S (w in dup_add_batch1) is the result of a subtraction,
+   thus with the notations from http://www.loria.fr/~zimmerma/papers/norm.pdf
+   we have S < 2 \alpha N.
+   Then R < (2 \alpha N \beta + \beta N) = (2 \alpha + 1) N.
+   This result R is used in an addition with u being the result of a squaring
+   thus u < \alpha N, which gives a result < (3 \alpha + 1) N.
+   Finally this result is used in a multiplication with another operand less
+   than 2 \alpha N, thus we want:
+   ((2 \alpha) (3 \alpha + 1) N^2 + \beta N)/\beta \leq \alpha N, i.e.,
+   2 \alpha (3 \alpha + 1) \varepsilon + 1 \leq \alpha
+   This implies \varepsilon \leq 7/2 - sqrt(3)/2 ~ 0.0359, in which case
+   we can take \alpha = 2/3*sqrt(3)+1 ~ 2.1547.
+   In that case no adjustment is needed in mpresn_mul_1.
+   However we prefer to keep the adjustment here, to allow a larger set of
+   inputs (\varepsilon \leq 1/16 = 0.0625 instead of 0.0359).
+*/
+void 
+mpresn_mul_1 (mpres_t R, const mpres_t S, const mp_limb_t m, mpmod_t modulus)
+{
+  mp_ptr t1 = PTR(modulus->temp1);
+  mp_ptr t2 = PTR(modulus->temp2);
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+  mp_limb_t q;
+
+  ASSERT (SIZ(S) == n || -SIZ(S) == n);
+  ASSERT (ALLOC(modulus->temp1) >= n+1);
+
+  t1[n] = mpn_mul_1 (t1, PTR(S), n, m);
+  q = t1[0] * modulus->Nprim[0];
+  t2[n] = mpn_mul_1 (t2, PTR(modulus->orig_modulus), n, q);
+#ifdef HAVE___GMPN_ADD_NC
+  q = __gmpn_add_nc (PTR(R), t1 + 1, t2 + 1, n, t1[0] != 0);
+#else
+  q = mpn_add_n (PTR(R), t1 + 1, t2 + 1, n);
+  q += mpn_add_1 (PTR(R), PTR(R), n, t1[0] != 0);
+#endif
+  while (q != 0)
+    q -= mpn_sub_n (PTR(R), PTR(R), PTR(modulus->orig_modulus), n);
+
+  SIZ(R) = SIZ(S); /* sign is unchanged */
+}
+
+/* R <- S1 + S2 mod modulus */
+/* we assume all numbers are allocated to n limbs, and unused most significant
+   limbs are set to zero */
+void
+mpresn_add (mpres_t R, const mpres_t S1, const mpres_t S2, mpmod_t modulus)
+{
+  mp_ptr r = PTR(R);
+  mp_ptr s1 = PTR(S1);
+  mp_ptr s2 = PTR(S2);
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+  ATTRIBUTE_UNUSED mp_limb_t cy;
+
+  ASSERT (SIZ(S1) == n || -SIZ(S1) == n);
+  ASSERT (SIZ(S2) == n || -SIZ(S2) == n);
+
+  if (SIZ(S1) == SIZ(S2)) /* S1 and S2 are of same sign */
+    {
+      cy = mpn_add_n (r, s1, s2, n);
+      /* for N < B^n/16, the while loop will be never performed, which proves
+         it will be performed a small number of times. In practice we
+         observed up to 7 loops, but it happens rarely. */
+#ifndef MPRESN_NO_ADJUSTMENT
+      while (cy != 0)
+        cy -= mpn_sub_n (r, r, PTR(modulus->orig_modulus), n);
+#endif
+      SIZ(R) = SIZ(S1);
+    }
+  else /* different signs */
+    {
+      if (mpn_cmp (s1, s2, n) >= 0)
+        {
+          mpn_sub_n (r, s1, s2, n); /* no borrow here */
+          SIZ(R) = SIZ(S1);
+        }
+      else
+        {
+          mpn_sub_n (r, s2, s1, n); /* idem */
+          SIZ(R) = SIZ(S2);
+        }
+    }
+}
+
+void
+mpresn_sub (mpres_t R, const mpres_t S1, const mpres_t S2, mpmod_t modulus)
+{
+  mp_ptr r = PTR(R);
+  mp_ptr s1 = PTR(S1);
+  mp_ptr s2 = PTR(S2);
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+  ATTRIBUTE_UNUSED mp_limb_t cy;
+
+  ASSERT (SIZ(S1) == n || -SIZ(S1) == n);
+  ASSERT (SIZ(S2) == n || -SIZ(S2) == n);
+
+  if (SIZ(S1) != SIZ(S2)) /* S1 and S2 are of different signs */
+    {
+      cy = mpn_add_n (r, s1, s2, n);
+#ifndef MPRESN_NO_ADJUSTMENT
+      while (cy != 0)
+        cy -= mpn_sub_n (r, r, PTR(modulus->orig_modulus), n);
+#endif
+      SIZ(R) = SIZ(S1);
+    }
+  else /* same signs, it's a real subtraction */
+    {
+      if (mpn_cmp (s1, s2, n) >= 0)
+        {
+          mpn_sub_n (r, s1, s2, n); /* no borrow here */
+          SIZ(R) = SIZ(S1);
+        }
+      else
+        {
+          mpn_sub_n (r, s2, s1, n); /* idem */
+          SIZ(R) = -SIZ(S2);
+        }
+      
+    }
+}
+
+/* (R, T) <- (S1 + S2, S1 - S2) */
+void
+mpresn_addsub (mpres_t R, mpres_t T,
+               const mpres_t S1, const mpres_t S2, mpmod_t modulus)
+{
+  mp_ptr r = PTR(R);
+  mp_ptr t = PTR(T);
+  mp_ptr s1 = PTR(S1);
+  mp_ptr s2 = PTR(S2);
+  mp_size_t n = ABSIZ(modulus->orig_modulus);
+  ATTRIBUTE_UNUSED mp_limb_t cy;
+
+  ASSERT (SIZ(S1) == n || -SIZ(S1) == n);
+  ASSERT (SIZ(S2) == n || -SIZ(S2) == n);
+
+  if (SIZ(S1) == SIZ(S2)) /* S1 and S2 are of same sign */
+    {
+      cy = mpn_add_n (r, s1, s2, n);
+#ifndef MPRESN_NO_ADJUSTMENT
+      while (cy != 0)
+        cy -= mpn_sub_n (r, r, PTR(modulus->orig_modulus), n);
+#endif
+      SIZ(R) = SIZ(S1);
+      if (mpn_cmp (s1, s2, n) >= 0)
+        {
+          mpn_sub_n (t, s1, s2, n); /* no borrow since {s1,n} >= {s2,n} */
+          SIZ(T) = SIZ(S1);
+        }
+      else
+        {
+          mpn_sub_n (t, s2, s1, n); /* idem since {s2,n} >= {s1,n} */
+          SIZ(T) = -SIZ(S2);
+        }
+    }
+  else /* different signs */
+    {
+      if (mpn_cmp (s1, s2, n) >= 0)
+        {
+          mpn_sub_n (r, s1, s2, n); /* no borrow since {s1,n} >= {s2,n} */
+          SIZ(R) = SIZ(S1);
+        }
+      else
+        {
+          mpn_sub_n (r, s2, s1, n); /* idem since {s2,n} >= {s1,n} */
+          SIZ(R) = SIZ(S2);
+        }
+      cy = mpn_add_n (t, s1, s2, n);
+#ifndef MPRESN_NO_ADJUSTMENT
+      while (cy != 0)
+        cy -= mpn_sub_n (r, r, PTR(modulus->orig_modulus), n);
+#endif
+      SIZ(T) = SIZ(S1);
+    }
+}
diff --git a/mpmod.h b/mpmod.h
new file mode 100644
index 0000000..ad98e76
--- /dev/null
+++ b/mpmod.h
@@ -0,0 +1,27 @@
+/* Header for modular multiplication.
+
+  Copyright 2012 Paul Zimmermann.
+
+  This file is part of the ECM Library.
+
+  The ECM 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.
+
+  The ECM 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 ECM Library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+  MA 02110-1301, USA.
+*/
+
+#define MPMOD_MULREDC 0    /* assembly combined mulredc */
+#define MPMOD_MUL_REDC1 1  /* mpn_mul_n or mpn_sqr followed by mpn_redc_1 */
+#define MPMOD_MUL_REDC2 2  /* mpn_mul_n or mpn_sqr followed by mpn_redc_2 */
+#define MPMOD_MUL_REDCN 3  /* mpn_mul_n or mpn_sqr followed by mpn_redc_n */
+#define MPMOD_MUL_REDC_C 4 /* mpn_mul_n or mpn_sqr followed by plain C redc */
diff --git a/mpzspv.c b/mpzspv.c
index 1a5ea5d..d9a931f 100644
--- a/mpzspv.c
+++ b/mpzspv.c
@@ -176,10 +176,11 @@ mpzspv_reverse (mpzspv_t x, spv_size_t offset, spv_size_t len, mpzspm_t mpzspm)
 }
 
 /* convert mpzvi to CRT representation, naive version */
-void
+static void
 mpzspv_from_mpzv_slow (mpzspv_t x, const spv_size_t offset, mpz_t mpzvi,
-                       mpzspm_t mpzspm, unsigned int sp_num)
+                       mpzspm_t mpzspm)
 {
+  const unsigned int sp_num = mpzspm->sp_num;
   unsigned int j;
 
   for (j = 0; j < sp_num; j++)
@@ -191,10 +192,11 @@ mpzspv_from_mpzv_slow (mpzspv_t x, const spv_size_t offset, mpz_t mpzvi,
 
 /* convert mpzvi to CRT representation, fast version, assumes
    mpzspm->T has been precomputed (see mpzspm.c) */
-void
+static void
 mpzspv_from_mpzv_fast (mpzspv_t x, const spv_size_t offset, mpz_t mpzvi,
-                       mpzspm_t mpzspm, unsigned int sp_num)
+                       mpzspm_t mpzspm)
 {
+  const unsigned int sp_num = mpzspm->sp_num;
   unsigned int i, j, k, i0 = I0_THRESHOLD, I0;
   mpzv_t *T = mpzspm->T;
   unsigned int d = mpzspm->d, ni;
@@ -266,9 +268,9 @@ mpzspv_from_mpzv (mpzspv_t x, const spv_size_t offset, const mpzv_t mpzv,
         {
 	  ASSERT(mpz_sgn (mpzv[i]) > 0); /* We can't handle negative values */
           if (mpzspm->T == NULL)
-            mpzspv_from_mpzv_slow (x, i + offset, mpzv[i], mpzspm, sp_num);
+            mpzspv_from_mpzv_slow (x, i + offset, mpzv[i], mpzspm);
           else
-            mpzspv_from_mpzv_fast (x, i + offset, mpzv[i], mpzspm, sp_num);
+            mpzspv_from_mpzv_fast (x, i + offset, mpzv[i], mpzspm);
 	}
     }
 #if defined(_OPENMP)
diff --git a/pm1fs2.c b/pm1fs2.c
index d8f4754..b1af859 100644
--- a/pm1fs2.c
+++ b/pm1fs2.c
@@ -1149,7 +1149,7 @@ V (mpres_t R, const mpres_t S, const long k, mpmod_t modulus)
       mpres_set (R, S, modulus);
       while (po2-- > 0)
         {
-          mpres_mul (R, R, R, modulus);
+          mpres_sqr (R, R, modulus);
           mpres_sub (R, R, V0, modulus);
         }
       mpres_clear (V0, modulus);
@@ -1172,7 +1172,7 @@ V (mpres_t R, const mpres_t S, const long k, mpmod_t modulus)
 
   /* i = 1. Vi = V_i(S), Vi1 = V_{i+1}(S) */
   mpres_set (Vi, S, modulus);
-  mpres_mul (Vi1, S, S, modulus);
+  mpres_sqr (Vi1, S, modulus);
   mpres_sub (Vi1, Vi1, V0, modulus);
   j >>= 1;
 
@@ -1185,7 +1185,7 @@ V (mpres_t R, const mpres_t S, const long k, mpmod_t modulus)
 	     V_{i'+1} = V_{2i + 2} = {V_{i+1}}^2 - V_0. */
 	  mpres_mul (Vi, Vi, Vi1, modulus);
 	  mpres_sub (Vi, Vi, S, modulus);
-	  mpres_mul (Vi1, Vi1, Vi1, modulus);
+	  mpres_sqr (Vi1, Vi1, modulus);
 	  mpres_sub (Vi1, Vi1, V0, modulus);
 	}
       else
@@ -1196,7 +1196,7 @@ V (mpres_t R, const mpres_t S, const long k, mpmod_t modulus)
 	  mpres_mul (Vi1, Vi, Vi1, modulus);
 	  mpres_sub (Vi1, Vi1, S, modulus);
 
-	  mpres_mul (Vi, Vi, Vi, modulus);
+	  mpres_sqr (Vi, Vi, modulus);
 	  mpres_sub (Vi, Vi, V0, modulus);
 	}
       j >>= 1;
@@ -1208,7 +1208,7 @@ V (mpres_t R, const mpres_t S, const long k, mpmod_t modulus)
 
   while (po2-- > 0)
     {
-      mpres_mul (Vi, Vi, Vi, modulus);
+      mpres_sqr (Vi, Vi, modulus);
       mpres_sub (Vi, Vi, V0, modulus);
     }
 
@@ -1289,7 +1289,7 @@ U (mpres_t R, mpres_t R1, const mpres_t S, const long k, mpmod_t modulus)
   mpres_set (Ui1, S, modulus);       /* Ui1 = U_2(S) = S */
   mpres_add (V0, Ui, Ui, modulus);   /* V0 = V_0(S) = 2 */
   mpres_set (Vi, S, modulus);        /* Vi = V_1(S) = S */
-  mpres_mul (Vi1, Vi, Vi, modulus);
+  mpres_sqr (Vi1, Vi, modulus);
   mpres_sub (Vi1, Vi1, V0, modulus); /* Vi1 = V_2(S) = S^2 - 2 */
   j >>= 1; /* i = 1 */
 
@@ -1304,7 +1304,7 @@ U (mpres_t R, mpres_t R1, const mpres_t S, const long k, mpmod_t modulus)
 	  mpres_add (Ui1, Ui1, Ui, modulus);
 	  mpres_mul (Ui1, Ui1, t, modulus); 
 	  mpres_mul (Ui, Ui, Vi, modulus); /* U_{2n} = U_n V_n */
-	  mpres_mul (Vi, Vi, Vi, modulus);
+	  mpres_sqr (Vi, Vi, modulus);
 	  mpres_sub (Vi, Vi, V0, modulus); /* V_{2n} = V_n^2 - 2 */
 	}
       else
@@ -1316,7 +1316,7 @@ U (mpres_t R, mpres_t R1, const mpres_t S, const long k, mpmod_t modulus)
 	  mpres_mul (Ui1, Ui1, Vi1, modulus); /* U_{2n+2} = U_{n+1} V_{n+1} */
 	  mpres_mul (Vi, Vi, Vi1, modulus);
 	  mpres_sub (Vi, Vi, S, modulus); /* V_{2i+1} = V_{i+1} V_i - V_1 */
-	  mpres_mul (Vi1, Vi1, Vi1, modulus);
+	  mpres_sqr (Vi1, Vi1, modulus);
 	  mpres_sub (Vi1, Vi1, V0, modulus); /* V_{2n+2} = V_{n+1}^2 - 2 */
 	}
       j >>= 1;
@@ -1448,7 +1448,7 @@ list_scale_V (listz_t R, const listz_t F, const mpres_t Q,
     start_i = thread_nr * l + 1;
     l = MIN(l, deg + 1 - start_i);
 
-    mpmod_copy (modulus_local, modulus);
+    mpmod_init_set (modulus_local, modulus);
     mpres_init (Vi_1, modulus_local);
     mpres_init (Vi, modulus_local);
     
@@ -1510,7 +1510,7 @@ list_scale_V (listz_t R, const listz_t F, const mpres_t Q,
     start_i = thread_nr * l + 1UL;
     l = MIN(l, deg + 1 - start_i);
     
-    mpmod_copy (modulus_local, modulus);
+    mpmod_init_set (modulus_local, modulus);
     mpres_init (Ui_1, modulus_local);
     mpres_init (Ui, modulus_local);
     
@@ -1581,7 +1581,7 @@ list_scale_V (listz_t R, const listz_t F, const mpres_t Q,
 
   /* Multiply by Q^2-4 */
   mpres_init (Vt, modulus);
-  mpres_mul (Vt, Q, Q, modulus);
+  mpres_sqr (Vt, Q, modulus);
   mpres_sub_ui (Vt, Vt, 4, modulus);
 
 #if defined(_OPENMP)
@@ -1590,7 +1590,7 @@ list_scale_V (listz_t R, const listz_t F, const mpres_t Q,
     mpmod_t modulus_local;
     long i; /* OpenMP insists on signed loop iteration var :( */
     
-    mpmod_copy (modulus_local, modulus);
+    mpmod_init_set (modulus_local, modulus);
     
 #pragma omp for
     for (i = 0; (unsigned long) i <= 2 * deg - 2; i++)
@@ -1796,8 +1796,9 @@ poly_from_sets_V (listz_t F, const mpres_t Q, sets_long_t *sets,
   ASSERT_ALWAYS (sets->nr > 0UL);
   ASSERT_ALWAYS (set->card == 2UL); /* Check that the cardinality of 
                                        first set is 2 */
-  /* Check that first set is symmetric around 0 */
-  ASSERT_ALWAYS (set->elem[0] == -set->elem[1]);
+  /* Check that first set is symmetric around 0 (we write card-1
+     instead of 1 to avoid a compiler warning with clang 2.9) */
+  ASSERT_ALWAYS (set->elem[0] == -set->elem[set->card - 1]);
 
   if (test_verbose (OUTPUT_TRACE))
     {
@@ -1841,8 +1842,9 @@ poly_from_sets_V (listz_t F, const mpres_t Q, sets_long_t *sets,
 
       if (c == 2UL)
 	{
-	  /* Check it's symmetric */
-	  ASSERT_ALWAYS (set->elem[0] == -set->elem[1]);
+	  /* Check it's symmetric (we write c-1 instead of 2 to avoid a
+           compiler warning with clang 2.9) */
+	  ASSERT_ALWAYS (set->elem[0] == -set->elem[c - 1]);
 	  V (Qt, Q, set->elem[0], modulus);
 	  V (Qt, Qt, 2UL, modulus);
 	  list_scale_V (F, F, Qt, deg, modulus, tmp, tmplen, dct, 
@@ -2020,7 +2022,7 @@ pm1_sequence_g (listz_t g_mpz, mpzspv_t g_ntt, const mpres_t b_1,
 #endif
 
   /* Make a private copy of the mpmod_t struct */
-  mpmod_copy (modulus, modulus_param);
+  mpmod_init_set (modulus, modulus_param);
 
   mpz_init (t);
   mpres_init (r[0], modulus);
@@ -2064,7 +2066,7 @@ pm1_sequence_g (listz_t g_mpz, mpzspv_t g_ntt, const mpres_t b_1,
   mpz_set_si (t, M);
   mpz_mul (t, t, t);                     /* t = M^2 */
   mpres_pow (r[2], r[0], t, modulus);    /* r[2] = r^{(M-i)^2}, i = 0 */
-  mpres_mul (r[0], r[0], r[0], modulus); /* r[0] = r^2 */
+  mpres_sqr (r[0], r[0], modulus); /* r[0] = r^2 */
 
   mpz_mul_2exp (t, m_1, 1UL);
   mpz_add_ui (t, t, 1UL);
@@ -2211,7 +2213,7 @@ pm1_sequence_h (listz_t h, mpzspv_t h_ntt, mpz_t *f, const mpres_t r,
     }
 #endif
     
-    mpmod_copy (modulus, modulus_parm);
+    mpmod_init_set (modulus, modulus_parm);
     mpres_init (fd[0], modulus);
     mpres_init (fd[1], modulus);
     mpres_init (fd[2], modulus);
@@ -2224,7 +2226,7 @@ pm1_sequence_h (listz_t h, mpzspv_t h_ntt, mpz_t *f, const mpres_t r,
        separately in each thread has the advantage of putting it in
        local memory. May not make much difference overall */
 
-    mpres_mul (fd[0], invr, invr, modulus); /* fd[0] = r^{-2} */
+    mpres_sqr (fd[0], invr, modulus);       /* fd[0] = r^{-2} */
     mpz_set_ui (t, offset);
     mpz_mul_2exp (t, t, 1UL);
     mpz_add_ui (t, t, 1UL);                 /* t = 2 * offset + 1 */
@@ -2551,7 +2553,7 @@ ntt_gcd (mpz_t f, mpz_t *product, mpzspv_t ntt, const unsigned long ntt_offset,
 #endif
 
     /* Make a private copy of the mpmod_t struct */
-    mpmod_copy (modulus, modulus_param);
+    mpmod_init_set (modulus, modulus_param);
 
     MEMORY_TAG;
     R = init_list2 (Rlen, (mpz_size (modulus->orig_modulus) + 2) * 
@@ -3154,7 +3156,7 @@ gfp_ext_sqr_norm1 (mpres_t r_0, mpres_t r_1, const mpres_t a_0,
   mpres_mul (r_1, a_0, a_1, modulus);
   mpres_add (r_1, r_1, r_1, modulus);       /* r_1 = 2*a_0*a_1 */
   
-  mpres_mul (r_0, a_0, a_0, modulus);
+  mpres_sqr (r_0, a_0, modulus);
   mpres_add (r_0, r_0, r_0, modulus);
   mpres_sub_ui (r_0, r_0, 1UL, modulus);    /* r_0 = 2*a_0^2 - 1 */
 
@@ -3351,7 +3353,7 @@ gfp_ext_rn2 (mpres_t *r_x, mpres_t *r_y, const mpres_t a_x, const mpres_t a_y,
   mpres_add (*V2, a_x, a_x, modulus); /* V2 = a + 1/a  = 2*a_x*/
   V (v[0], *V2, 2 * k + 1, modulus);  /* v[0] = V_{2k+1} (a + 1/a) */
   V (v[1], *V2, 2 * k + 3, modulus);  /* v[0] = V_{2k+3} (a + 1/a) */
-  mpres_mul (*V2, *V2, *V2, modulus); /* V2 = 4*a_x^2 */
+  mpres_sqr (*V2, *V2, modulus);      /* V2 = 4*a_x^2 */
   mpres_sub_ui (*V2, *V2, 2UL, modulus); /* V2 = 4*a_x^2 - 2 */
   if (pari)
     {
@@ -3439,7 +3441,7 @@ pp1_sequence_g (listz_t g_x, listz_t g_y, mpzspv_t g_x_ntt, mpzspv_t g_y_ntt,
     if (want_output)
       outputf (OUTPUT_VERBOSE, " using %d threads", nr_chunks);
 #endif
-    mpmod_copy (modulus, modulus_param);
+    mpmod_init_set (modulus, modulus_param);
     mpres_init (r_x, modulus);
     mpres_init (r_y, modulus);
     mpres_init (x0_x, modulus);
@@ -3746,7 +3748,7 @@ pp1_sequence_h (listz_t h_x, listz_t h_y, mpzspv_t h_x_ntt, mpzspv_t h_y_ntt,
 
     mpz_init (mt);
     /* Make thread-local copy of modulus */
-    mpmod_copy (modulus, modulus_param);
+    mpmod_init_set (modulus, modulus_param);
 
     /* Init the local mpres_t variables */
     for (i = 0; i < 2; i++)
@@ -3852,7 +3854,7 @@ pp1_sequence_h (listz_t h_x, listz_t h_y, mpzspv_t h_x_ntt, mpzspv_t h_y_ntt,
     mpres_add (V2, rn_x, rn_x, modulus); /* V2 = r + 1/r  = 2*rn_x */
     V (v[0], V2, 2 * k + 1, modulus);  /* v[0] = V_{2k+1} (r + 1/r) */
     V (v[1], V2, 2 * k + 3, modulus);  /* v[1] = V_{2k+3} (r + 1/r) */
-    mpres_mul (V2, V2, V2, modulus); /* V2 = 4*a_x^2 */
+    mpres_sqr (V2, V2, modulus);       /* V2 = 4*a_x^2 */
     mpres_sub_ui (V2, V2, 2UL, modulus); /* V2 = 4*a_x^2 - 2 */
     if (test_verbose (OUTPUT_TRACE))
       {
@@ -4080,7 +4082,7 @@ pp1fs2 (mpz_t f, const mpres_t X, mpmod_t modulus,
     }
 
   /* Compute Delta and b1_x + b1_y * sqrt(Delta) = X) */
-  mpres_mul (Delta, X, X, modulus);
+  mpres_sqr (Delta, X, modulus);
   mpres_sub_ui (Delta, Delta, 4UL, modulus);
   mpres_div_2exp (b1_x, X, 1, modulus);
   mpres_set_ui (b1_y, 1UL, modulus);
@@ -4306,7 +4308,7 @@ pp1fs2_ntt (mpz_t f, const mpres_t X, mpmod_t modulus,
   mpres_init (Delta, modulus);
 
   /* Compute Delta and b1_x + b1_y * sqrt(Delta) = X) */
-  mpres_mul (Delta, X, X, modulus);
+  mpres_sqr (Delta, X, modulus);
   mpres_sub_ui (Delta, Delta, 4UL, modulus);
   mpres_div_2exp (b1_x, X, 1, modulus);
   mpres_set_ui (b1_y, 1UL, modulus);
diff --git a/pp1.c b/pp1.c
index 9328a16..9ff26e3 100644
--- a/pp1.c
+++ b/pp1.c
@@ -80,7 +80,7 @@ pp1_mul (mpres_t P1, mpres_t P0, mpz_t e, mpmod_t n, mpres_t P, mpres_t Q)
   
   /* now e >= 2 */
   mpz_sub_ui (e, e, 1);
-  mpres_mul (P, P0, P0, n);
+  mpres_sqr (P, P0, n);
   mpres_sub_ui (P, P, 2, n); /* P = V_2(P0) = P0^2-2 */
   mpres_set (Q, P0, n);      /* Q = V_1(P0) = P0 */
 
@@ -95,7 +95,7 @@ pp1_mul (mpres_t P1, mpres_t P0, mpz_t e, mpmod_t n, mpres_t P, mpres_t Q)
               mpres_mul (Q, P, Q, n);
               mpres_sub (Q, Q, P0, n);
             }
-          mpres_mul (P, P, P, n);
+          mpres_sqr (P, P, n);
           mpres_sub_ui (P, P, 2, n);
         }
       else /* k -> 2k */
@@ -104,7 +104,7 @@ pp1_mul (mpres_t P1, mpres_t P0, mpz_t e, mpmod_t n, mpres_t P, mpres_t Q)
           mpres_sub (P, P, P0, n);
           if (i) /* Q is not needed for last iteration */
             {
-              mpres_mul (Q, Q, Q, n);
+              mpres_sqr (Q, Q, n);
               mpres_sub_ui (Q, Q, 2, n);
             }
         }
@@ -326,10 +326,10 @@ pp1_mul2 (mpres_t a, mpres_t b, mpres_t P, mpz_t e, mpmod_t n)
   while (l--)
     {
       /* square: (ax+b)^2 = (a^2P+2ab) x + (b^2-a^2) */
-      mpres_mul (t, a, a, n); /* a^2 */
+      mpres_sqr (t, a, n);    /* a^2 */
       mpres_mul (a, a, b, n);
       mpres_add (a, a, a, n); /* 2ab */
-      mpres_mul (b, b, b, n); /* b^2 */
+      mpres_sqr (b, b, n);    /* b^2 */
       mpres_sub (b, b, t, n); /* b^2-a^2 */
       mpres_mul (t, t, P, n); /* a^2P */
       mpres_add (a, t, a, n); /* a^2P+2ab */
diff --git a/resume.c b/resume.c
index 4584f53..141208b 100644
--- a/resume.c
+++ b/resume.c
@@ -469,8 +469,13 @@ write_resumefile_line (char *fn, int method, double B1, mpz_t sigma, mpz_t A,
   mpz_out_str (file, 16, x);
   mpz_mul_ui (checksum, checksum, mpz_fdiv_ui (n->n, CHKSUMMOD));
   mpz_mul_ui (checksum, checksum, mpz_fdiv_ui (x, CHKSUMMOD));
+#ifdef GPUECM
+  fprintf (file, "; CHECKSUM=%lu; PROGRAM=GPU-ECM %s;",
+           mpz_fdiv_ui (checksum, CHKSUMMOD), VERSION_GPU);
+#else
   fprintf (file, "; CHECKSUM=%lu; PROGRAM=GMP-ECM %s;",
            mpz_fdiv_ui (checksum, CHKSUMMOD), VERSION);
+#endif
   mpz_clear (checksum);
   
   if (mpz_sgn (x0) != 0)
diff --git a/sets_long.c b/sets_long.c
index add1b3c..5f05341 100644
--- a/sets_long.c
+++ b/sets_long.c
@@ -62,8 +62,12 @@ set_copy (set_long_t *T, set_long_t *S)
 }
 
 
-/* Exchange two adjacent sets in memory. */
-
+/* Exchange two adjacent sets in memory. Since all "elem" arrays are stored
+   in the same chunk of allocated memory, and not in different chunks, we
+   cannot simply swap the "elem" pointers.
+   If the set T has size c and the next has size d, after the swap the set T
+   will have size d and the next will have size c.
+*/
 static void 
 set_swap (set_long_t *T)
 {
@@ -74,6 +78,8 @@ set_swap (set_long_t *T)
   ASSERT(tmp != NULL);
   set_copy (tmp, T);
   set_copy (T, next);
+  /* warning: sets_nextset(T) might differ from next, if T and next had
+     different sizes */
   set_copy (sets_nextset(T), tmp);  
 }
 
diff --git a/stage2.c b/stage2.c
index dccec95..26273a7 100644
--- a/stage2.c
+++ b/stage2.c
@@ -471,7 +471,6 @@ stage2 (mpz_t f, void *X, mpmod_t modulus, unsigned long dF, unsigned long k,
               goto clear_T;
             }
         }
-      /* list_set (Tree[lgk - 1], F, dF); PolyFromRoots_Tree does it */
     }
   else
     Tree = NULL;
diff --git a/test.ecm b/test.ecm
index c0a5f58..24231e9 100755
--- a/test.ecm
+++ b/test.ecm
@@ -45,6 +45,9 @@ checkcode () {
 # 2^4 * 3^3 * 29 * 2411
 echo 2050449353925555290706354283 | $ECM -sigma 7 -k 1 30 0-1e6; checkcode $? 14
 
+# check the -treefile option
+echo 2050449353925555290706354283 | $ECM -treefile tree -sigma 7 -k 1 30 0-1e6; checkcode $? 14
+
 # Check a stage 2 of length 1. g1=1822795201 g2=968809 g3=567947
 echo 212252637915375215854013140804296246361 | $ECM -sigma 781683988 -go 550232165123 63421 1822795201-1822795201; checkcode $? 8
 
@@ -145,17 +148,44 @@ echo 493671084022010320922697718944221569774262937898523672663031469122444419595
 
 echo "10090030271*10^400+696212088699" | $ECM -sigma 3923937547 1e3 1e6; checkcode $? 14
 
-# To test the batch mode
-echo "458903930815802071188998938170281707063809443792768383215233" | $ECM -batch -A 166 10000
+# To test batch mode 1
+# the following test works both on 32- and 64-bit machines
+# on 32-bit machines it corresponds to d' = 42
+# on 64-bit machines it corresponds to d' = 42*2^32
+echo 458903930815802071188998938170281707063809443792768383215233 | $ECM -batch -A 103699173453039012668349162616750601868936199904547322268878 10000
+checkcode $? 14
+
+# same with batch=2
+echo 458903930815802071188998938170281707063809443792768383215233 | $ECM -batch=2 -A 103699173453039012668349162616750601868936199904547322268878 10000
 checkcode $? 14
 
-echo "2^349-1" | $ECM -batch -A 134 967 551113 
+# this test corresponds to d'=13 on 32-bit, 13*2^32 on 64-bit
+echo "2^349-1" | $ECM -batch -A 13883915733485915535567641090102088744917579395318243004655770450844428217574163575149253565087742 587 29383
+checkcode $? 6
+
+# same with batch=2
+echo "2^349-1" | $ECM -batch=2 -A 13883915733485915535567641090102088744917579395318243004655770450844428217574163575149253565087742 587 29383
 checkcode $? 6
 
-# this example did fail on 32-bit computers (thanks to David Cleaver)
-echo "2^347-1" | $ECM -batch -A 5837673714 36209 11436599
+# another batch-mode test (d' = 1097 on 32-bit, 1097*2^32 on 64-bit)
+echo "2^347-1" | $ECM -batch -A 292897222300654795048417351458499833714895857628156011078988080472621879897670335421898676171177982 3301 229939
 checkcode $? 14
 
+# same with batch=2
+echo "2^347-1" | $ECM -batch=2 -A 292897222300654795048417351458499833714895857628156011078988080472621879897670335421898676171177982 3301 229939
+checkcode $? 14
+
+# To test batch mode 2
+echo 911962091 | $ECM -batch=2 -A 440688534 50000
+checkcode $? 8
+
+echo 31622776601683791911 | $ECM -batch=1 -A 124052764650467335534 11000
+checkcode $? 0
+
+# this example would fail with the old Fgw.c when using gwnum (fixed by David Cleaver, r1734)
+echo "((173^173+1)/174)/471462511391940575680645418941" | $ECM -sigma 12345 20000
+checkcode $? 0
+
 # the following tests should work on machines which have uint64_t or where
 # unsigned long long has 64 bits (exercises patch from David Cleaver, r1575)
 echo "NOTE: NEXT 3 TESTS WILL FAIL ON SOME 32BIT MACHINES, THIS IS EXPECTED."
diff --git a/test.pm1 b/test.pm1
index a96236f..84011f9 100755
--- a/test.pm1
+++ b/test.pm1
@@ -90,8 +90,8 @@ echo 504403158265489337 | $PM1 -k 4 8 9007199254740700-9007199254740900; checkco
 echo 6857 | $PM1 840 857; checkcode $? 8
 
 # A test with a larger input number to test modular arithmetic routines not
-# in mulredc*.asm. This input has 1363 bits so it has 22 64 bit words 
-# (43 32 bit words) and cannot use mulredc which handles only up to 20 limbs
+# in mulredc*.asm. This input has 1363 bits so it has 22 64-bit words 
+# (43 32-bit words) and cannot use mulredc which handles only up to 20 limbs
 
 echo "10090030271*10^400+696212088699" | $PM1 2e3 2e6; checkcode $? 14
 
diff --git a/test_mulredc.c b/test_mulredc.c
index e1248a4..28fc53b 100644
--- a/test_mulredc.c
+++ b/test_mulredc.c
@@ -241,30 +241,9 @@ void test(mp_size_t N, int k)
         }
     }
     
-    /* Mul followed by ecm_redc3 */
-    mpn_mul_n(tmp, x, yp, N);
-    ecm_redc3(tmp, m, N, invm);
-    cy2 = mpn_add_n (tmp2, tmp + N, tmp, N);
-
     /* Mixed mul and redc */
     cy = call_mulredc (N, z, x, yp, m, invm);
     
-    if (cy != cy2)
-      printf ("i = %d: mulredc cy = %ld, mpn_mul_n/ecm_redc3 cy = %ld\n", 
-              i, (long) cy, (long) cy2);
-    assert (cy == cy2);
-    if (mpn_cmp(z,tmp2, N) != 0)
-      {
-        printf ("i = %d\nmulredc             = ", i);
-        for (j = N - 1; j >= 0; j--)
-          printf ("%lx ", z[j]);
-        printf ("\nmpn_mul_n/ecm_redc3 = ");
-        for (j = N - 1; j >= 0; j--)
-          printf ("%lx ", tmp2[j]);
-        printf ("\n");
-        assert (mpn_cmp(z,tmp2, N) == 0);
-      }
-
     if (cy)
       printf("!");
     z[N] = cy;
diff --git a/tune.c b/tune.c
index 3e5c51d..4fdced9 100644
--- a/tune.c
+++ b/tune.c
@@ -1,7 +1,7 @@
-/* Tune program.
+/* Tune program for GMP-ECM.
 
-  Copyright 2003, 2005, 2006, 2008 Paul Zimmermann, Alexander Kruppa, 
-  Dave Newman and Jason Papadopoulos.
+  Copyright 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Paul Zimmermann,
+  Alexander Kruppa, Dave Newman and Jason Papadopoulos.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -86,7 +86,6 @@ size_t PREREVERTDIVISION_NTT_THRESHOLD;
 size_t POLYINVERT_NTT_THRESHOLD;
 size_t POLYEVALT_NTT_THRESHOLD;
 size_t MPZSPV_NORMALISE_STRIDE = 256;
-size_t TUNE_MULREDC_THRESH, TUNE_SQRREDC_THRESH;
 
 void
 mpz_quick_random (mpz_t x, mpz_t M, unsigned long b)
@@ -150,8 +149,6 @@ tune_mpres_mul (mp_size_t limbs, int repr)
   return (double) __k / (double) __st;
 }
 
-/* There is no actual mpres_sqr() function (yet), we simply call
-   mpres_mul() with two identical input */
 double
 tune_mpres_sqr (mp_size_t limbs, int repr)
 {
@@ -188,7 +185,7 @@ tune_mpres_sqr (mp_size_t limbs, int repr)
 
   mpres_set_z (x, p, modulus);
 
-  TUNE_FUNC_LOOP (mpres_mul (z, x, x, modulus));
+  TUNE_FUNC_LOOP (mpres_sqr (z, x, modulus));
 
   mpres_clear (x, modulus);
   mpres_clear (z, modulus);
@@ -330,56 +327,6 @@ TUNE_FUNC_START (tune_ecm_mul_lo_n)
   TUNE_FUNC_LOOP (ecm_mul_lo_n (rp, xp, yp, mp_size));
 TUNE_FUNC_END (tune_ecm_mul_lo_n)
 
-double 
-tune_mulredc_asm (size_t n)
-{
-  double r;
-  /* Make ecm_mulredc_basecase() always use asm mulredc code */
-  TUNE_MULREDC_THRESH=20;
-  r = tune_mpres_mul (n, ECM_MOD_MODMULN);
-  if (tune_verbose)
-    fprintf (stderr, "tune_mulredc_asm(%2ld) = %f\n", (long) n, r);
-  return r;
-}
-
-double 
-tune_mulredc_noasm (size_t n)
-{
-  double r;
-  /* Make ecm_mulredc_basecase() never use asm mulredc code */
-  TUNE_MULREDC_THRESH=0;
-  r = tune_mpres_mul (n, ECM_MOD_MODMULN);
-  if (tune_verbose)
-    fprintf (stderr, "tune_mulredc_noasm(%2ld) = %f\n", (long) n, r);
-  return r;
-}
-
-
-double 
-tune_sqrredc_asm (size_t n)
-{
-  double r;
-  /* Make ecm_mulredc_basecase() always use asm mulredc code */
-  TUNE_SQRREDC_THRESH=20;
-  r = tune_mpres_sqr (n, ECM_MOD_MODMULN);
-  if (tune_verbose)
-    fprintf (stderr, "tune_sqrredc_asm(%2ld) = %f\n", (long) n, r);
-  return r;
-}
-
-double 
-tune_sqrredc_noasm (size_t n)
-{
-  double r;
-  /* Make ecm_mulredc_basecase() always use asm mulredc code */
-  TUNE_SQRREDC_THRESH=0;
-  r = tune_mpres_sqr (n, ECM_MOD_MODMULN);
-  if (tune_verbose)
-    fprintf (stderr, "tune_sqrredc_noasm(%2ld) = %f\n", (long) n, r);
-  return r;
-}
-
-
 /* Return the lowest n with min_n <= n < max_n such that
  * f1(t) >= f0(t) for all t in [n, n + k), or return max_n if no such
  * n exists. This function will typically return high values if there
@@ -525,16 +472,6 @@ main (int argc, char **argv)
   spm = mpzspm->spm[0];
   spv = mpzspv[0];
   
-  TUNE_MULREDC_THRESH = crossover2 (tune_mulredc_asm, tune_mulredc_noasm,
-                                    1, 20, 2);
-  printf ("#define TUNE_MULREDC_THRESH %lu\n", 
-          (unsigned long) TUNE_MULREDC_THRESH);
-
-  TUNE_SQRREDC_THRESH = crossover2 (tune_sqrredc_asm, tune_sqrredc_noasm,
-                                    1, 20, 2);
-  printf ("#define TUNE_SQRREDC_THRESH %lu\n", 
-          (unsigned long) TUNE_SQRREDC_THRESH);
-
   MPZMOD_THRESHOLD = crossover2 (tune_mpres_mul_modmuln, tune_mpres_mul_mpz,
       1, 512, 10);
   
diff --git a/x86_64/mulredc.h b/x86_64/mulredc.h
index 68f9ecc..595ffa0 100644
--- a/x86_64/mulredc.h
+++ b/x86_64/mulredc.h
@@ -7,8 +7,7 @@
 /* Signals that we have assembly code for 1xN mul/redc */
 #define HAVE_NATIVE_MULREDC1_N
 /* Signals that we have assembly code for variable size redc */
-/* Undefined since recent versions of GMP are faster */
-/* #define HAVE_ASM_REDC3 */
+#define HAVE_ASM_REDC3
 
 /* Call the mulredc*() function with MS Windows parameter passing if
   WINDOWS64_ABI is defined. This is useful for testing the functions
diff --git a/x86_64/mulredc.m4 b/x86_64/mulredc.m4
index 6af5ed7..77f350c 100644
--- a/x86_64/mulredc.m4
+++ b/x86_64/mulredc.m4
@@ -140,7 +140,10 @@ GSYM_PREFIX``''mulredc`'LENGTH:
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
+`ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+') dnl'
 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
diff --git a/x86_64/mulredc10.asm b/x86_64/mulredc10.asm
index 2e58545..44de1e0 100644
--- a/x86_64/mulredc10.asm
+++ b/x86_64/mulredc10.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc11.asm b/x86_64/mulredc11.asm
index d8f889b..eac829f 100644
--- a/x86_64/mulredc11.asm
+++ b/x86_64/mulredc11.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc12.asm b/x86_64/mulredc12.asm
index 86d585e..4587a0b 100644
--- a/x86_64/mulredc12.asm
+++ b/x86_64/mulredc12.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc13.asm b/x86_64/mulredc13.asm
index 7bb7096..8376291 100644
--- a/x86_64/mulredc13.asm
+++ b/x86_64/mulredc13.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc14.asm b/x86_64/mulredc14.asm
index 81e1f58..05a8d22 100644
--- a/x86_64/mulredc14.asm
+++ b/x86_64/mulredc14.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc15.asm b/x86_64/mulredc15.asm
index 1b6455e..4f73028 100644
--- a/x86_64/mulredc15.asm
+++ b/x86_64/mulredc15.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc16.asm b/x86_64/mulredc16.asm
index 0049e39..d5e368d 100644
--- a/x86_64/mulredc16.asm
+++ b/x86_64/mulredc16.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc17.asm b/x86_64/mulredc17.asm
index 7e5d219..575ab53 100644
--- a/x86_64/mulredc17.asm
+++ b/x86_64/mulredc17.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc18.asm b/x86_64/mulredc18.asm
index efa7702..446a543 100644
--- a/x86_64/mulredc18.asm
+++ b/x86_64/mulredc18.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc19.asm b/x86_64/mulredc19.asm
index ac4c610..6cf5bf7 100644
--- a/x86_64/mulredc19.asm
+++ b/x86_64/mulredc19.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc2.asm b/x86_64/mulredc2.asm
index 194b507..95cf4ad 100644
--- a/x86_64/mulredc2.asm
+++ b/x86_64/mulredc2.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc20.asm b/x86_64/mulredc20.asm
index b8566bf..958c5f5 100644
--- a/x86_64/mulredc20.asm
+++ b/x86_64/mulredc20.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc3.asm b/x86_64/mulredc3.asm
index bf70dd7..c1fb41b 100644
--- a/x86_64/mulredc3.asm
+++ b/x86_64/mulredc3.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc4.asm b/x86_64/mulredc4.asm
index 4fe4753..604962f 100644
--- a/x86_64/mulredc4.asm
+++ b/x86_64/mulredc4.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc5.asm b/x86_64/mulredc5.asm
index 14ac5f9..3b44b63 100644
--- a/x86_64/mulredc5.asm
+++ b/x86_64/mulredc5.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc6.asm b/x86_64/mulredc6.asm
index 975cc91..74e8473 100644
--- a/x86_64/mulredc6.asm
+++ b/x86_64/mulredc6.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc7.asm b/x86_64/mulredc7.asm
index aff5754..248fe97 100644
--- a/x86_64/mulredc7.asm
+++ b/x86_64/mulredc7.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc8.asm b/x86_64/mulredc8.asm
index 7b8fd02..a410868 100644
--- a/x86_64/mulredc8.asm
+++ b/x86_64/mulredc8.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored
diff --git a/x86_64/mulredc9.asm b/x86_64/mulredc9.asm
index c738982..7d42085 100644
--- a/x86_64/mulredc9.asm
+++ b/x86_64/mulredc9.asm
@@ -130,8 +130,10 @@ ifdef(`WINDOWS64_ABI',
 	movq 	%rax, %T0		# Move low word of product to T0
 	movq	%rdx, %T1		# Move high word of product to T1
 
-	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64
-	movq	%rax, %U		# this is the new u value
+ifdef(`MULREDC_SVOBODA',
+, `'
+`	imulq	%INVM, %rax		# %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64'
+) 	movq	%rax, %U		# this is the new u value
 
 	mulq	(%MP)			# multipy u*m[0]
 	addq	%rax, %T0		# Now %T0 = 0, need not be stored

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/gmp-ecm.git



More information about the debian-science-commits mailing list