int mp_invisqrt_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_imul(int n, int radix, int in1[], int in2, int out[]);
  void mp_idiv_2(int n, int radix, int in[], int out[]);
  void mp_squh_save_infft(int n, int radix, int in[], int out[], int nfft,
                          double infft[], 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_squh_save_infft(n, radix, inout, tmp1, nfft, tmp1fft, tmp2fft, ip, w);
  mp_imul(n, radix, tmp1, in, tmp1);
  mp_load_1(n, radix, tmp2);
  mp_sub(n, 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_idiv_2(n_h, radix, tmp2, tmp2);
  if (tmp2[0] != 0) {
    mp_add(n, radix, inout, tmp2, inout);
  }
  return prc;
}


x86 assembly (clang, -O0):
<mp_invisqrt_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    %edx,-0x14(%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    11e8 <mp_invisqrt_newton+0x68>
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   1030 <mp_round@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%r11
mov    0x28(%rbp),%r10
mov    0x30(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1090 <mp_squh_save_infft@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1070 <mp_imul@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1060 <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    -0x30(%rbp),%rcx
xor    %eax,%eax
sub    0x4(%rcx),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jne    128d <mp_invisqrt_newton+0x10d>
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   1050 <mp_mulh_use_in1fft@plt>
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   10a0 <mp_idiv_2@plt>
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
je     12fe <mp_invisqrt_newton+0x17e>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <mp_add@plt>
mov    -0x3c(%rbp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_invisqrt_newton>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r14
mov    %edx,0xc(%rsp)
mov    %esi,%r12d
mov    %edi,%r13d
mov    0x50(%rsp),%eax
mov    %eax,%edx
sar    %edx
add    $0x1,%edx
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
add    $0x1,%eax
mov    %edi,%ebp
sub    %edx,%ebp
cmp    %ebp,%eax
cmovge %eax,%ebp
call   1030 <mp_round@plt>
sub    $0x8,%rsp
mov    %r13d,%edi
mov    %r12d,%esi
mov    %r14,0x18(%rsp)
mov    %r14,%rdx
mov    0x58(%rsp),%r14d
mov    %r15,%rcx
mov    %r14d,%r8d
mov    0x60(%rsp),%r9
push   0x78(%rsp)
push   0x78(%rsp)
push   0x78(%rsp)
call   1090 <mp_squh_save_infft@plt>
add    $0x20,%rsp
mov    %r13d,%edi
mov    %r12d,%esi
mov    %r15,%rdx
mov    0xc(%rsp),%ecx
mov    %r15,%r8
call   1070 <mp_imul@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1060 <mp_load_1@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   1080 <mp_sub@plt>
mov    (%rbx),%eax
mov    %eax,0xc(%rsp)
mov    0x4(%rbx),%r15d
mov    %ebp,%edi
mov    %r12d,%esi
mov    0x58(%rsp),%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %rbx,%r9
push   0x70(%rsp)
push   0x70(%rsp)
push   0x70(%rsp)
push   %r14
call   1050 <mp_mulh_use_in1fft@plt>
add    $0x20,%rsp
mov    %ebp,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %rbx,%rcx
call   10a0 <mp_idiv_2@plt>
cmpl   $0x0,(%rbx)
je     1292 <mp_invisqrt_newton+0x112>
mov    %r13d,%edi
mov    %r12d,%esi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
mov    %rdx,%r8
call   1040 <mp_add@plt>
add    $0x1,%r14d
neg    %r15d
cmpl   $0x0,0xc(%rsp)
cmove  %r14d,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mp_invisqrt_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** %16
%50 = load i32, i32* %18
%51 = load double*, double** %19
%52 = load double*, double** %20
%53 = load i32*, i32** %21
%54 = load double*, double** %22
%55 = load i32, i32* %12
%56 = load i32, i32* %13
%57 = load i32*, i32** %16
%58 = load i32, i32* %14
%59 = load i32*, i32** %16
%60 = load i32, i32* %12
%61 = load i32, i32* %13
%62 = load i32*, i32** %17
%63 = load i32, i32* %12
%64 = load i32, i32* %13
%65 = load i32*, i32** %17
%66 = load i32*, i32** %16
%67 = load i32*, i32** %17
%68 = load i32*, i32** %17
%69 = getelementptr inbounds i32, i32* %68, i64 1
%70 = load i32, i32* %69
%71 = sub nsw i32 0, %70
store i32 %71, i32* %25
%72 = load i32*, i32** %17
%73 = getelementptr inbounds i32, i32* %72, i64 0
%74 = load i32, i32* %73
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %41
%77 = load i32, i32* %18
%78 = add nsw i32 %77, 1
store i32 %78, i32* %25
br label %79
79: ; preds = %76, %41
%80 = load i32, i32* %23
%81 = load i32, i32* %13
%82 = load double*, double** %19
%83 = load i32*, i32** %17
%84 = load i32*, i32** %17
%85 = load i32, i32* %18
%86 = load double*, double** %20
%87 = load i32*, i32** %21
%88 = load double*, double** %22
%89 = load i32, i32* %23
%90 = load i32, i32* %13
%91 = load i32*, i32** %17
%92 = load i32*, i32** %17
%93 = load i32*, i32** %17
%94 = getelementptr inbounds i32, i32* %93, i64 0
%95 = load i32, i32* %94
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %79
%98 = load i32, i32* %12
%99 = load i32, i32* %13
%100 = load i32*, i32** %15
%101 = load i32*, i32** %17
%102 = load i32*, i32** %15
br label %103
103: ; preds = %97, %79
%104 = load i32, i32* %25
ret i32 %104
}

LLVM IR (-O2):
define i32 @mp_invisqrt_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_squh_save_infft(i32 %0, i32 %1, i32* %3, i32* %4, i32 %6, double* %7, double* %8, i32* %9, double* %10)
tail call void @mp_imul(i32 %0, i32 %1, i32* %4, i32 %2, i32* %4)
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)
%19 = getelementptr inbounds i32, i32* %5, i64 1
%20 = load i32, i32* %19
%21 = load i32, i32* %5
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_idiv_2(i32 %18, i32 %1, i32* %5, i32* %5)
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %11
tail call void @mp_add(i32 %0, i32 %1, i32* %3, i32* %5, i32* %3)
br label %25
25: ; preds = %24, %11
%26 = icmp eq i32 %21, 0
%27 = add nsw i32 %6, 1
%28 = sub nsw i32 0, %20
%29 = select i1 %26, i32 %27, i32 %28
ret i32 %29
}