void mp_squ(int n, int radix, int in[], int out[], int tmp[], int nfft,
            double tmp1fft[], double tmp2fft[], int ip[], double w[]) {
  void mp_add(int n, int radix, int in1[], int in2[], int out[]);
  void mp_mul_i2d(int n, int radix, int nfft, int shift, int in[],
                  double dout[]);
  void mp_mul_cmul(int nfft, double d1[], double d2[], int ip[], double w[]);
  void mp_mul_csqu_nt_d1(int nfft, double d1[], int ip[], double w[]);
  void mp_mul_d2i(int n, int radix, int nfft, double din[], int out[]);
  int n_h, shift;
  shift = (nfft >> 1) + 1;
  while (n > shift) {
    if (in[shift + 2] != 0) {
      break;
    }
    shift++;
  }
  n_h = n / 2 + 1;
  if (n_h < n - shift) {
    n_h = n - shift;
  }
  mp_mul_i2d(n, radix, nfft, 0, in, tmp1fft);
  mp_mul_i2d(n, radix, nfft, shift, in, tmp2fft);
  mp_mul_cmul(nfft, tmp1fft, tmp2fft, ip, w);
  mp_mul_d2i(n_h, radix, nfft, tmp2fft, tmp);
  mp_mul_csqu_nt_d1(nfft, tmp1fft, ip, w);
  mp_mul_d2i(n, radix, nfft, tmp1fft, out);
  if (tmp[0] != 0) {
    mp_add(n_h, radix, tmp, tmp, tmp);
    mp_add(n, radix, out, tmp, out);
  }
}


x86 assembly (clang, -O0):
<mp_squ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    11c0 <mp_squ+0x70>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11b2 <mp_squ+0x62>
jmp    11c0 <mp_squ+0x70>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118a <mp_squ+0x3a>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
cmp    %ecx,%eax
jge    11eb <mp_squ+0x9b>
mov    -0x4(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%r8
mov    0x10(%rbp),%r9
xor    %ecx,%ecx
call   1030 <mp_mul_i2d@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    0x18(%rbp),%r9
call   1030 <mp_mul_i2d@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rsi
mov    0x18(%rbp),%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
call   1050 <mp_mul_cmul@plt>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1070 <mp_mul_d2i@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rsi
mov    0x20(%rbp),%rdx
mov    0x28(%rbp),%rcx
call   1060 <mp_mul_csqu_nt_d1@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1070 <mp_mul_d2i@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     12af <mp_squ+0x15f>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1040 <mp_add@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1040 <mp_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_squ>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r13d
mov    %r8,0x28(%rsp)
mov    %rcx,0x30(%rsp)
mov    %rdx,%r15
mov    %esi,%r14d
mov    0x88(%rsp),%rax
mov    %rax,(%rsp)
mov    0x80(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x78(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x70(%rsp),%r10
mov    %r9d,%ebp
sar    %ebp
movslq %ebp,%rcx
movslq %edi,%rax
lea    0x1(%rcx),%edx
cmp    %edx,%eax
cmovg  %edi,%edx
add    $0x1,%rcx
cmp    %rax,%rcx
jge    11c6 <mp_squ+0x76>
add    $0x1,%ebp
cmpl   $0x0,0x8(%r15,%rcx,4)
lea    0x1(%rcx),%rcx
je     11b0 <mp_squ+0x60>
jmp    11c8 <mp_squ+0x78>
mov    %edx,%ebp
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
add    $0x1,%eax
mov    %edi,%ebx
sub    %ebp,%ebx
cmp    %ebx,%eax
cmovge %eax,%ebx
mov    %edi,%r12d
mov    %edi,0xc(%rsp)
mov    %r14d,%esi
mov    %r13d,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r10,0x10(%rsp)
mov    %r10,%r9
call   1030 <mp_mul_i2d@plt>
mov    %r12d,%edi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %ebp,%ecx
mov    %r15,%r8
mov    0x18(%rsp),%rbp
mov    %rbp,%r9
call   1030 <mp_mul_i2d@plt>
mov    %r13d,%edi
mov    0x10(%rsp),%r12
mov    %r12,%rsi
mov    %rbp,%rdx
mov    0x20(%rsp),%r15
mov    %r15,%rcx
mov    (%rsp),%r8
call   1050 <mp_mul_cmul@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %rbp,%rcx
mov    0x28(%rsp),%rbp
mov    %rbp,%r8
call   1070 <mp_mul_d2i@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    0xc(%rsp),%r15d
mov    (%rsp),%rcx
call   1060 <mp_mul_csqu_nt_d1@plt>
mov    %r15d,%edi
mov    %r14d,(%rsp)
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r12,%rcx
mov    0x30(%rsp),%r14
mov    %r14,%r8
call   1070 <mp_mul_d2i@plt>
cmpl   $0x0,0x0(%rbp)
je     12be <mp_squ+0x16e>
mov    %ebx,%edi
mov    (%rsp),%ebx
mov    %ebx,%esi
mov    %rbp,%rdx
mov    %rbp,%rcx
mov    %rbp,%r8
call   1040 <mp_add@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mp_add@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @mp_squ(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32 %5, double* %6, double* %7, i32* %8, double* %9) {
%11 = ashr i32 %5, 1
%12 = sext i32 %11 to i64
%13 = sext i32 %0 to i64
%14 = add nsw i32 %11, 1
%15 = call i32 @llvm.smax.i32(i32 %0, i32 %14)
br label %16
16: ; preds = %20, %10
%17 = phi i64 [ %18, %20 ], [ %12, %10 ]
%18 = add nsw i64 %17, 1
%19 = icmp slt i64 %18, %13
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = add nsw i64 %17, 3
%22 = getelementptr inbounds i32, i32* %2, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %16, label %25
25: ; preds = %20
%26 = trunc i64 %18 to i32
br label %27
27: ; preds = %16, %25
%28 = phi i32 [ %26, %25 ], [ %15, %16 ]
%29 = sdiv i32 %0, 2
%30 = add nsw i32 %29, 1
%31 = sub nsw i32 %0, %28
%32 = icmp slt i32 %30, %31
%33 = select i1 %32, i32 %31, i32 %30
tail call void @mp_mul_i2d(i32 %0, i32 %1, i32 %5, i32 0, i32* %2, double* %6)
tail call void @mp_mul_i2d(i32 %0, i32 %1, i32 %5, i32 %28, i32* %2, double* %7)
tail call void @mp_mul_cmul(i32 %5, double* %6, double* %7, i32* %8, double* %9)
tail call void @mp_mul_d2i(i32 %33, i32 %1, i32 %5, double* %7, i32* %4)
tail call void @mp_mul_csqu_nt_d1(i32 %5, double* %6, i32* %8, double* %9)
tail call void @mp_mul_d2i(i32 %0, i32 %1, i32 %5, double* %6, i32* %3)
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %27
tail call void @mp_add(i32 %33, i32 %1, i32* %4, i32* %4, i32* %4)
tail call void @mp_add(i32 %0, i32 %1, i32* %3, i32* %4, i32* %3)
br label %37
37: ; preds = %36, %27
ret void
}