C code that gets executed when mpz_mul() is invoked

Torbjörn Granlund tg at gmplib.org
Tue May 15 07:21:51 UTC 2018

Tanushree Banerjee <banerjee.tanushree10 at gmail.com> writes:

  I want to see the C code which GMP uses for multiplication when I use
  mpz_mul () function and compile my C code using -lgmp flag.
  Is it the code in the folder    gmp-6.1.2\mpn\generic\mul_n.c ?
  Or is it some other multiplication code in any other folder?
  Can someone help me understand which code gets executed ?

Which code is executed depends on which function you call.  Typically,
mpn/generic/mul.c will get called quite soon in all cases.

Following GMP call chains can be tricky, just like with any other
program.  I usually use "grep -r function-name" to find call sites and
definition of a function.

An alternative is to use a debugger and single step through an example

Unfortunately, help at this level is a bit outside of what the GMP
volunteers can offer.

Please encrypt, key id 0xC8601622

More information about the gmp-discuss mailing list