#include <gmp.h>
#include <iostream>
extern "C" {
void *__libc_dlopen_mode(const char *x, int y);
void *__libc_dlsym(void *x, const char *y);
}
const char *gmp_path = "/usr/lib/x86_64-linux-gnu/libgmp.so.10";
void *gmp_lib = __libc_dlopen_mode(gmp_path, 2);
void *get(const char *name) { return __libc_dlsym(gmp_lib, name); }
#define D(name) const auto __##name = (decltype(name) *)get("__g" #name)
D(mpn_mul);
D(mpn_tdiv_qr);
D(mpn_set_str);
D(mpn_get_str);
D(mpn_sub_n);
D(mpz_init);
D(mpz_clear);
D(mpz_invert);
D(mpz_import);
D(mpz_out_str);
#undef D
int main() {
mpz_t a;
mp_limb_t v1[100], v2[100];
for (int i = 0; i < 100; i++) {
v1[i] = 4 * i;
v2[i] = 5 * i;
}
std::cout << __mpn_sub_n(v1, v1, v2, 10) << "\n";
for (int i = 0; i < 100; i++) {
std::cout << v1[i] << " ";
}
__mpz_init(a);
__mpz_clear(a);
return 0;
}
I2luY2x1ZGUgPGdtcC5oPgojaW5jbHVkZSA8aW9zdHJlYW0+CmV4dGVybiAiQyIgewp2b2lkICpfX2xpYmNfZGxvcGVuX21vZGUoY29uc3QgY2hhciAqeCwgaW50IHkpOwp2b2lkICpfX2xpYmNfZGxzeW0odm9pZCAqeCwgY29uc3QgY2hhciAqeSk7Cn0KCmNvbnN0IGNoYXIgKmdtcF9wYXRoID0gIi91c3IvbGliL3g4Nl82NC1saW51eC1nbnUvbGliZ21wLnNvLjEwIjsKdm9pZCAqZ21wX2xpYiA9IF9fbGliY19kbG9wZW5fbW9kZShnbXBfcGF0aCwgMik7CnZvaWQgKmdldChjb25zdCBjaGFyICpuYW1lKSB7IHJldHVybiBfX2xpYmNfZGxzeW0oZ21wX2xpYiwgbmFtZSk7IH0KCiNkZWZpbmUgRChuYW1lKSBjb25zdCBhdXRvIF9fIyNuYW1lID0gKGRlY2x0eXBlKG5hbWUpICopZ2V0KCJfX2ciICNuYW1lKQpEKG1wbl9tdWwpOwpEKG1wbl90ZGl2X3F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