int mp_invisqrt_newton(int n, int radix, int in, int inout[], int tmp1[],
                       int tmp2[], int nfft, double tmp1fft[],
                       double tmp2fft[]) {
  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[]);
  void mp_mulh_use_in1fft(int n, int radix, double in1fft[], int shift,
                          int in2[], int out[], int nfft, double outfft[]);
  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);
  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);
  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
sub    $0x50,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    0x10(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x30(%rbp),%ecx
cmp    %ecx,%eax
jge    11df <mp_invisqrt_newton+0x5f>
mov    -0x4(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <mp_round@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%rax
mov    %rax,(%rsp)
call   1090 <mp_squh_save_infft@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1070 <mp_imul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1060 <mp_load_1@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1080 <mp_sub@plt>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
sub    0x4(%rcx),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1272 <mp_invisqrt_newton+0xf2>
mov    0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x18(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%r10d
mov    0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <mp_mulh_use_in1fft@plt>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   10a0 <mp_idiv_2@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
je     12d3 <mp_invisqrt_newton+0x153>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1040 <mp_add@plt>
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
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   0x68(%rsp)
call   1090 <mp_squh_save_infft@plt>
add    $0x10,%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   0x60(%rsp)
push   %r14
call   1050 <mp_mulh_use_in1fft@plt>
add    $0x10,%rsp
mov    %ebp,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %rbx,%rcx
call   10a0 <mp_idiv_2@plt>
cmpl   $0x0,(%rbx)
je     1282 <mp_invisqrt_newton+0x102>
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) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32 %6, i32* %16
store double* %7, double** %17
store double* %8, double** %18
%22 = load i32, i32* %16
%23 = ashr i32 %22, 1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %20
%25 = load i32, i32* %10
%26 = sdiv i32 %25, 2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %19
%28 = load i32, i32* %19
%29 = load i32, i32* %10
%30 = load i32, i32* %20
%31 = sub nsw i32 %29, %30
%32 = icmp slt i32 %28, %31
br i1 %32, label %33, label %37
33: ; preds = %9
%34 = load i32, i32* %10
%35 = load i32, i32* %20
%36 = sub nsw i32 %34, %35
store i32 %36, i32* %19
br label %37
37: ; preds = %33, %9
%38 = load i32, i32* %10
%39 = load i32, i32* %11
%40 = load i32, i32* %20
%41 = load i32*, i32** %13
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = load i32*, i32** %13
%45 = load i32*, i32** %14
%46 = load i32, i32* %16
%47 = load double*, double** %17
%48 = load double*, double** %18
%49 = load i32, i32* %10
%50 = load i32, i32* %11
%51 = load i32*, i32** %14
%52 = load i32, i32* %12
%53 = load i32*, i32** %14
%54 = load i32, i32* %10
%55 = load i32, i32* %11
%56 = load i32*, i32** %15
%57 = load i32, i32* %10
%58 = load i32, i32* %11
%59 = load i32*, i32** %15
%60 = load i32*, i32** %14
%61 = load i32*, i32** %15
%62 = load i32*, i32** %15
%63 = getelementptr inbounds i32, i32* %62, i64 1
%64 = load i32, i32* %63
%65 = sub nsw i32 0, %64
store i32 %65, i32* %21
%66 = load i32*, i32** %15
%67 = getelementptr inbounds i32, i32* %66, i64 0
%68 = load i32, i32* %67
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %37
%71 = load i32, i32* %16
%72 = add nsw i32 %71, 1
store i32 %72, i32* %21
br label %73
73: ; preds = %70, %37
%74 = load i32, i32* %19
%75 = load i32, i32* %11
%76 = load double*, double** %17
%77 = load i32*, i32** %15
%78 = load i32*, i32** %15
%79 = load i32, i32* %16
%80 = load double*, double** %18
%81 = load i32, i32* %19
%82 = load i32, i32* %11
%83 = load i32*, i32** %15
%84 = load i32*, i32** %15
%85 = load i32*, i32** %15
%86 = getelementptr inbounds i32, i32* %85, i64 0
%87 = load i32, i32* %86
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %95
89: ; preds = %73
%90 = load i32, i32* %10
%91 = load i32, i32* %11
%92 = load i32*, i32** %13
%93 = load i32*, i32** %15
%94 = load i32*, i32** %13
br label %95
95: ; preds = %89, %73
%96 = load i32, i32* %21
ret i32 %96
}

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) {
%10 = ashr i32 %6, 1
%11 = add nsw i32 %10, 1
%12 = sdiv i32 %0, 2
%13 = add nsw i32 %12, 1
%14 = sub nsw i32 %0, %11
%15 = icmp slt i32 %13, %14
%16 = select i1 %15, i32 %14, i32 %13
tail call void @mp_round(i32 %0, i32 %1, i32 %11, i32* %3)
tail call void @mp_squh_save_infft(i32 %0, i32 %1, i32* %3, i32* %4, i32 %6, double* %7, double* %8)
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)
%17 = getelementptr inbounds i32, i32* %5, i64 1
%18 = load i32, i32* %17
%19 = load i32, i32* %5
tail call void @mp_mulh_use_in1fft(i32 %16, i32 %1, double* %7, i32 0, i32* %5, i32* %5, i32 %6, double* %8)
tail call void @mp_idiv_2(i32 %16, i32 %1, i32* %5, i32* %5)
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %9
tail call void @mp_add(i32 %0, i32 %1, i32* %3, i32* %5, i32* %3)
br label %23
23: ; preds = %22, %9
%24 = icmp eq i32 %19, 0
%25 = add nsw i32 %6, 1
%26 = sub nsw i32 0, %18
%27 = select i1 %24, i32 %25, i32 %26
ret i32 %27
}