int mp_inv_newton(int n, int radix, int in[], int inout[], int tmp1[],
                  int tmp2[], int nfft, double tmp1fft[], double tmp2fft[],
                  int ip[], double w[]) {
  void mp_load_1(int n, int radix, int out[]);
  void mp_round(int n, int radix, int m, int inout[]);
  void mp_add(int n, int radix, int in1[], int in2[], int out[]);
  void mp_sub(int n, int radix, int in1[], int in2[], int out[]);
  void mp_mulh(int n, int radix, int in1[], int in2[], int out[], int nfft,
               double in1fft[], double outfft[], int ip[], double w[]);
  void mp_mulh_use_in1fft(int n, int radix, double in1fft[], int shift,
                          int in2[], int out[], int nfft, double outfft[],
                          int ip[], double w[]);
  int n_h, shift, prc;
  shift = (nfft >> 1) + 1;
  n_h = n / 2 + 1;
  if (n_h < n - shift) {
    n_h = n - shift;
  }
  mp_round(n, radix, shift, inout);
  mp_mulh(n, radix, inout, in, tmp1, nfft, tmp1fft, tmp2fft, ip, w);
  mp_load_1(n, radix, tmp2);
  mp_sub(n, radix, tmp2, tmp1, tmp2);
  mp_mulh_use_in1fft(n, radix, tmp1fft, shift, in, tmp1, nfft, tmp2fft, ip, w);
  mp_sub(n_h, radix, tmp2, tmp1, tmp2);
  prc = -tmp2[1];
  if (tmp2[0] == 0) {
    prc = nfft + 1;
  }
  mp_mulh_use_in1fft(n_h, radix, tmp1fft, 0, tmp2, tmp2, nfft, tmp2fft, ip, w);
  mp_add(n, radix, inout, tmp2, inout);
  return prc;
}


x86 assembly (clang, -O0):
<mp_inv_newton>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    11c9 <mp_inv_newton+0x69>
mov    -0xc(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1040 <mp_round@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11
mov    0x28(%rbp),%r10
mov    0x30(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <mp_mulh@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1070 <mp_load_1@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1080 <mp_sub@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    0x18(%rbp),%rdx
mov    -0x38(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%ebx
mov    0x20(%rbp),%r11
mov    0x28(%rbp),%r10
mov    0x30(%rbp),%rax
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <mp_mulh_use_in1fft@plt>
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1080 <mp_sub@plt>
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
sub    0x4(%rcx),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12b3 <mp_inv_newton+0x153>
mov    0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    0x18(%rbp),%rdx
mov    -0x30(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%ebx
mov    0x20(%rbp),%r11
mov    0x28(%rbp),%r10
mov    0x30(%rbp),%rax
xor    %ecx,%ecx
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <mp_mulh_use_in1fft@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1050 <mp_add@plt>
mov    -0x3c(%rbp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_inv_newton>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r15
mov    %r8,0x18(%rsp)
mov    %rcx,%rbx
mov    %rdx,0x10(%rsp)
mov    %esi,%r13d
mov    %edi,%r12d
mov    0x60(%rsp),%eax
mov    %eax,%r14d
sar    %r14d
add    $0x1,%r14d
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
add    $0x1,%eax
mov    %edi,%ebp
sub    %r14d,%ebp
cmp    %ebp,%eax
cmovge %eax,%ebp
mov    %r14d,%edx
mov    %rcx,0x20(%rsp)
call   1040 <mp_round@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rbx
mov    %rbx,%r8
mov    0x60(%rsp),%r9d
mov    0x80(%rsp),%rax
push   %rax
mov    0x80(%rsp),%rax
push   %rax
mov    0x80(%rsp),%rax
push   %rax
mov    0x80(%rsp),%rax
push   %rax
call   1030 <mp_mulh@plt>
add    $0x20,%rsp
mov    %r12d,%edi
mov    %r13d,0xc(%rsp)
mov    %r13d,%esi
mov    %r15,%rdx
call   1070 <mp_load_1@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
call   1080 <mp_sub@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    0x68(%rsp),%rdx
mov    %r14d,%ecx
mov    0x10(%rsp),%r8
mov    %rbx,%r14
mov    %rbx,%r9
push   0x80(%rsp)
push   0x80(%rsp)
push   0x80(%rsp)
mov    0x78(%rsp),%r13d
push   %r13
call   1060 <mp_mulh_use_in1fft@plt>
add    $0x20,%rsp
mov    %ebp,%edi
mov    0xc(%rsp),%ebx
mov    %ebx,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1080 <mp_sub@plt>
xor    %eax,%eax
sub    0x4(%r15),%eax
lea    0x1(%r13),%r14d
cmpl   $0x0,(%r15)
cmovne %eax,%r14d
mov    %ebp,%edi
mov    %ebx,%esi
mov    0x68(%rsp),%rdx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r15,%r9
push   0x80(%rsp)
push   0x80(%rsp)
push   0x80(%rsp)
push   %r13
call   1060 <mp_mulh_use_in1fft@plt>
add    $0x20,%rsp
mov    %r12d,%edi
mov    %ebx,%esi
mov    0x20(%rsp),%rdx
mov    %r15,%rcx
mov    %rdx,%r8
call   1050 <mp_add@plt>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mp_inv_newton(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, double* %7, double* %8, i32* %9, double* %10) {
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32
%19 = alloca double*
%20 = alloca double*
%21 = alloca i32*
%22 = alloca double*
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %12
store i32 %1, i32* %13
store i32* %2, i32** %14
store i32* %3, i32** %15
store i32* %4, i32** %16
store i32* %5, i32** %17
store i32 %6, i32* %18
store double* %7, double** %19
store double* %8, double** %20
store i32* %9, i32** %21
store double* %10, double** %22
%26 = load i32, i32* %18
%27 = ashr i32 %26, 1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %24
%29 = load i32, i32* %12
%30 = sdiv i32 %29, 2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %23
%32 = load i32, i32* %23
%33 = load i32, i32* %12
%34 = load i32, i32* %24
%35 = sub nsw i32 %33, %34
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %41
37: ; preds = %11
%38 = load i32, i32* %12
%39 = load i32, i32* %24
%40 = sub nsw i32 %38, %39
store i32 %40, i32* %23
br label %41
41: ; preds = %37, %11
%42 = load i32, i32* %12
%43 = load i32, i32* %13
%44 = load i32, i32* %24
%45 = load i32*, i32** %15
%46 = load i32, i32* %12
%47 = load i32, i32* %13
%48 = load i32*, i32** %15
%49 = load i32*, i32** %14
%50 = load i32*, i32** %16
%51 = load i32, i32* %18
%52 = load double*, double** %19
%53 = load double*, double** %20
%54 = load i32*, i32** %21
%55 = load double*, double** %22
%56 = load i32, i32* %12
%57 = load i32, i32* %13
%58 = load i32*, i32** %17
%59 = load i32, i32* %12
%60 = load i32, i32* %13
%61 = load i32*, i32** %17
%62 = load i32*, i32** %16
%63 = load i32*, i32** %17
%64 = load i32, i32* %12
%65 = load i32, i32* %13
%66 = load double*, double** %19
%67 = load i32, i32* %24
%68 = load i32*, i32** %14
%69 = load i32*, i32** %16
%70 = load i32, i32* %18
%71 = load double*, double** %20
%72 = load i32*, i32** %21
%73 = load double*, double** %22
%74 = load i32, i32* %23
%75 = load i32, i32* %13
%76 = load i32*, i32** %17
%77 = load i32*, i32** %16
%78 = load i32*, i32** %17
%79 = load i32*, i32** %17
%80 = getelementptr inbounds i32, i32* %79, i64 1
%81 = load i32, i32* %80
%82 = sub nsw i32 0, %81
store i32 %82, i32* %25
%83 = load i32*, i32** %17
%84 = getelementptr inbounds i32, i32* %83, i64 0
%85 = load i32, i32* %84
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %41
%88 = load i32, i32* %18
%89 = add nsw i32 %88, 1
store i32 %89, i32* %25
br label %90
90: ; preds = %87, %41
%91 = load i32, i32* %23
%92 = load i32, i32* %13
%93 = load double*, double** %19
%94 = load i32*, i32** %17
%95 = load i32*, i32** %17
%96 = load i32, i32* %18
%97 = load double*, double** %20
%98 = load i32*, i32** %21
%99 = load double*, double** %22
%100 = load i32, i32* %12
%101 = load i32, i32* %13
%102 = load i32*, i32** %15
%103 = load i32*, i32** %17
%104 = load i32*, i32** %15
%105 = load i32, i32* %25
ret i32 %105
}

LLVM IR (-O2):
define i32 @mp_inv_newton(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, double* %7, double* %8, i32* %9, double* %10) {
%12 = ashr i32 %6, 1
%13 = add nsw i32 %12, 1
%14 = sdiv i32 %0, 2
%15 = add nsw i32 %14, 1
%16 = sub nsw i32 %0, %13
%17 = icmp slt i32 %15, %16
%18 = select i1 %17, i32 %16, i32 %15
tail call void @mp_round(i32 %0, i32 %1, i32 %13, i32* %3)
tail call void @mp_mulh(i32 %0, i32 %1, i32* %3, i32* %2, i32* %4, i32 %6, double* %7, double* %8, i32* %9, double* %10)
tail call void @mp_load_1(i32 %0, i32 %1, i32* %5)
tail call void @mp_sub(i32 %0, i32 %1, i32* %5, i32* %4, i32* %5)
tail call void @mp_mulh_use_in1fft(i32 %0, i32 %1, double* %7, i32 %13, i32* %2, i32* %4, i32 %6, double* %8, i32* %9, double* %10)
tail call void @mp_sub(i32 %18, i32 %1, i32* %5, i32* %4, i32* %5)
%19 = getelementptr inbounds i32, i32* %5, i64 1
%20 = load i32, i32* %19
%21 = sub nsw i32 0, %20
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
%24 = add nsw i32 %6, 1
%25 = select i1 %23, i32 %24, i32 %21
tail call void @mp_mulh_use_in1fft(i32 %18, i32 %1, double* %7, i32 0, i32* %5, i32* %5, i32 %6, double* %8, i32* %9, double* %10)
tail call void @mp_add(i32 %0, i32 %1, i32* %3, i32* %5, i32* %3)
ret i32 %25
}