void mp_squ(int n, int radix, int in[], int out[], int tmp[], int nfft,
            double tmp1fft[], double tmp2fft[]) {
  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[]);
  void mp_mul_csqu_nt_d1(int nfft, double d1[]);
  void mp_mul_d2i(int n, int radix, int nfft, double din[], int out[]);
  int n_h, shift;
  short int *indgt;
  indgt = (short int *)&in[2];
  shift = (nfft >> 1) + 1;
  while (n > shift) {
    if (indgt[shift] != 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);
  mp_mul_d2i(n_h, radix, nfft, tmp2fft, tmp);
  mp_mul_csqu_nt_d1(nfft, tmp1fft);
  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    $0x40,%rsp
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    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    11c2 <mp_squ+0x72>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0x0,%eax
je     11b4 <mp_squ+0x64>
jmp    11c2 <mp_squ+0x72>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118e <mp_squ+0x3e>
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    11ed <mp_squ+0x9d>
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
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
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     12a1 <mp_squ+0x151>
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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_squ>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8,0x18(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,%r14
mov    %edi,%r13d
mov    0x68(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x60(%rsp),%r10
mov    %r9d,%ebp
sar    %ebp
movslq %ebp,%rax
movslq %edi,%rcx
lea    0x1(%rax),%edx
cmp    %edx,%ecx
cmovg  %edi,%edx
add    $0x5,%rax
nopw   0x0(%rax,%rax,1)
lea    -0x4(%rax),%rbx
cmp    %rcx,%rbx
jge    11ba <mp_squ+0x6a>
add    $0x1,%ebp
cmpw   $0x0,(%r14,%rax,2)
lea    0x1(%rax),%rax
je     11a0 <mp_squ+0x50>
jmp    11bc <mp_squ+0x6c>
mov    %edx,%ebp
mov    %r13d,%eax
shr    $0x1f,%eax
add    %r13d,%eax
sar    %eax
add    $0x1,%eax
mov    %r13d,%r12d
sub    %ebp,%r12d
cmp    %r12d,%eax
cmovge %eax,%r12d
mov    %r13d,%edi
mov    %r15d,%edx
xor    %ecx,%ecx
mov    %esi,%ebx
mov    %esi,0x4(%rsp)
mov    %r14,%r8
mov    %r10,0x10(%rsp)
mov    %r10,%r9
call   1030 <mp_mul_i2d@plt>
mov    %r13d,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    0x8(%rsp),%rbp
mov    %rbp,%r9
call   1030 <mp_mul_i2d@plt>
mov    %r15d,%edi
mov    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1050 <mp_mul_cmul@plt>
mov    %r12d,%edi
mov    0x4(%rsp),%r14d
mov    %r14d,%esi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    0x18(%rsp),%rbp
mov    %rbp,%r8
call   1070 <mp_mul_d2i@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1060 <mp_mul_csqu_nt_d1@plt>
mov    %r13d,0x8(%rsp)
mov    %r13d,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    0x20(%rsp),%r14
mov    %r14,%r8
call   1070 <mp_mul_d2i@plt>
cmpl   $0x0,0x0(%rbp)
je     12a8 <mp_squ+0x158>
mov    %r12d,%edi
mov    0x4(%rsp),%ebx
mov    %ebx,%esi
mov    %rbp,%rdx
mov    %rbp,%rcx
mov    %rbp,%r8
call   1040 <mp_add@plt>
mov    0x8(%rsp),%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mp_add@plt>
add    $0x28,%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) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i16*
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32 %5, i32* %14
store double* %6, double** %15
store double* %7, double** %16
%20 = load i32*, i32** %11
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = bitcast i32* %21 to i16*
store i16* %22, i16** %19
%23 = load i32, i32* %14
%24 = ashr i32 %23, 1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %18
br label %26
26: ; preds = %39, %8
%27 = load i32, i32* %9
%28 = load i32, i32* %18
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %42
30: ; preds = %26
%31 = load i16*, i16** %19
%32 = load i32, i32* %18
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i16, i16* %31, i64 %33
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%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* %18
%41 = add nsw i32 %40, 1
store i32 %41, i32* %18
br label %26
42: ; preds = %38, %26
%43 = load i32, i32* %9
%44 = sdiv i32 %43, 2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %17
%46 = load i32, i32* %17
%47 = load i32, i32* %9
%48 = load i32, i32* %18
%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* %9
%53 = load i32, i32* %18
%54 = sub nsw i32 %52, %53
store i32 %54, i32* %17
br label %55
55: ; preds = %51, %42
%56 = load i32, i32* %9
%57 = load i32, i32* %10
%58 = load i32, i32* %14
%59 = load i32*, i32** %11
%60 = load double*, double** %15
%61 = load i32, i32* %9
%62 = load i32, i32* %10
%63 = load i32, i32* %14
%64 = load i32, i32* %18
%65 = load i32*, i32** %11
%66 = load double*, double** %16
%67 = load i32, i32* %14
%68 = load double*, double** %15
%69 = load double*, double** %16
%70 = load i32, i32* %17
%71 = load i32, i32* %10
%72 = load i32, i32* %14
%73 = load double*, double** %16
%74 = load i32*, i32** %13
%75 = load i32, i32* %14
%76 = load double*, double** %15
%77 = load i32, i32* %9
%78 = load i32, i32* %10
%79 = load i32, i32* %14
%80 = load double*, double** %15
%81 = load i32*, i32** %12
%82 = load i32*, i32** %13
%83 = getelementptr inbounds i32, i32* %82, i64 0
%84 = load i32, i32* %83
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %97
86: ; preds = %55
%87 = load i32, i32* %17
%88 = load i32, i32* %10
%89 = load i32*, i32** %13
%90 = load i32*, i32** %13
%91 = load i32*, i32** %13
%92 = load i32, i32* %9
%93 = load i32, i32* %10
%94 = load i32*, i32** %12
%95 = load i32*, i32** %13
%96 = load i32*, i32** %12
br label %97
97: ; preds = %86, %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) {
%9 = getelementptr inbounds i32, i32* %2, i64 2
%10 = bitcast i32* %9 to i16*
%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, %8
%17 = phi i64 [ %18, %20 ], [ %12, %8 ]
%18 = add nsw i64 %17, 1
%19 = icmp slt i64 %18, %13
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = getelementptr inbounds i16, i16* %10, i64 %18
%22 = load i16, i16* %21
%23 = icmp eq i16 %22, 0
br i1 %23, label %16, label %24
24: ; preds = %20
%25 = trunc i64 %18 to i32
br label %26
26: ; preds = %16, %24
%27 = phi i32 [ %25, %24 ], [ %15, %16 ]
%28 = sdiv i32 %0, 2
%29 = add nsw i32 %28, 1
%30 = sub nsw i32 %0, %27
%31 = icmp slt i32 %29, %30
%32 = select i1 %31, i32 %30, i32 %29
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 %27, i32* %2, double* %7)
tail call void @mp_mul_cmul(i32 %5, double* %6, double* %7)
tail call void @mp_mul_d2i(i32 %32, i32 %1, i32 %5, double* %7, i32* %4)
tail call void @mp_mul_csqu_nt_d1(i32 %5, double* %6)
tail call void @mp_mul_d2i(i32 %0, i32 %1, i32 %5, double* %6, i32* %3)
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %26
tail call void @mp_add(i32 %32, 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 %36
36: ; preds = %35, %26
ret void
}