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 rdft(int n, int isgn, double *a, int *ip, double *w);
  void mp_mul_i2d(int n, int radix, int nfft, int shift, int in[],
                  double dout[]);
  void mp_mul_cmul(int nfft, double din[], double dinout[]);
  void mp_mul_csqu(int nfft, double dinout[]);
  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);
  rdft(nfft, 1, &tmp1fft[1], ip, w);
  mp_mul_i2d(n, radix, nfft, shift, in, tmp2fft);
  rdft(nfft, 1, &tmp2fft[1], ip, w);
  mp_mul_cmul(nfft, tmp1fft, tmp2fft);
  rdft(nfft, -1, &tmp2fft[1], ip, w);
  mp_mul_d2i(n_h, radix, nfft, tmp2fft, tmp);
  mp_mul_csqu(nfft, tmp1fft);
  rdft(nfft, -1, &tmp1fft[1], 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    11d0 <mp_squ+0x70>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11c2 <mp_squ+0x62>
jmp    11d0 <mp_squ+0x70>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119a <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    11fb <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    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@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    0x18(%rbp),%rdx
add    $0x8,%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rsi
mov    0x18(%rbp),%rdx
call   1070 <mp_mul_cmul@plt>
mov    -0x24(%rbp),%edi
mov    0x18(%rbp),%rdx
add    $0x8,%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
mov    $0xffffffff,%esi
call   1060 <rdft@plt>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1080 <mp_mul_d2i@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rsi
call   1050 <mp_mul_csqu@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    0x20(%rbp),%rcx
mov    0x28(%rbp),%r8
mov    $0xffffffff,%esi
call   1060 <rdft@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1080 <mp_mul_d2i@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1323 <mp_squ+0x1c3>
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    $0x48,%rsp
mov    %r9d,%r14d
mov    %r8,0x38(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rdx,%r12
mov    0x98(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x90(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x88(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x80(%rsp),%r15
mov    %r9d,%ebp
sar    %ebp
movslq %ebp,%rcx
movslq %edi,%rax
lea    0x1(%rcx),%edx
cmp    %edx,%eax
cmovg  %edi,%edx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %rax,%rcx
jge    11e6 <mp_squ+0x86>
add    $0x1,%ebp
cmpl   $0x0,0x8(%r12,%rcx,4)
lea    0x1(%rcx),%rcx
je     11d0 <mp_squ+0x70>
jmp    11e8 <mp_squ+0x88>
mov    %edx,%ebp
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
add    $0x1,%eax
mov    %edi,%ecx
sub    %ebp,%ecx
cmp    %ecx,%eax
cmovge %eax,%ecx
mov    %ecx,0x8(%rsp)
mov    %edi,%ebx
mov    %edi,0x1c(%rsp)
mov    %esi,0xc(%rsp)
mov    %r14d,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r15,%r9
call   1030 <mp_mul_i2d@plt>
lea    0x8(%r15),%rdx
mov    %rdx,0x20(%rsp)
mov    %r14d,%edi
mov    $0x1,%esi
mov    0x10(%rsp),%rcx
mov    0x30(%rsp),%r13
mov    %r13,%r8
call   1060 <rdft@plt>
mov    %ebx,%edi
mov    0xc(%rsp),%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12,%r8
mov    0x28(%rsp),%rbx
mov    %rbx,%r9
call   1030 <mp_mul_i2d@plt>
lea    0x8(%rbx),%r12
mov    %r14d,%edi
mov    $0x1,%esi
mov    %r12,%rdx
mov    0x10(%rsp),%rbp
mov    %rbp,%rcx
mov    %r13,%r8
call   1060 <rdft@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <mp_mul_cmul@plt>
mov    %r14d,%edi
mov    $0xffffffff,%esi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %r13,%r8
call   1060 <rdft@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%r12d
mov    %r12d,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
mov    0x38(%rsp),%rbx
mov    %rbx,%r8
call   1080 <mp_mul_d2i@plt>
mov    %r14d,%edi
mov    %r15,%rsi
call   1050 <mp_mul_csqu@plt>
mov    %r14d,%edi
mov    $0xffffffff,%esi
mov    0x20(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r13,%r8
mov    0x1c(%rsp),%r13d
call   1060 <rdft@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %r15,%rcx
mov    0x40(%rsp),%rbp
mov    %rbp,%r8
call   1080 <mp_mul_d2i@plt>
cmpl   $0x0,(%rbx)
je     133a <mp_squ+0x1da>
mov    0x8(%rsp),%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
call   1040 <mp_add@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mp_add@plt>
add    $0x48,%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* %16
%62 = load double*, double** %17
%63 = getelementptr inbounds double, double* %62, i64 1
%64 = load i32*, i32** %19
%65 = load double*, double** %20
%66 = load i32, i32* %11
%67 = load i32, i32* %12
%68 = load i32, i32* %16
%69 = load i32, i32* %22
%70 = load i32*, i32** %13
%71 = load double*, double** %18
%72 = load i32, i32* %16
%73 = load double*, double** %18
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load i32*, i32** %19
%76 = load double*, double** %20
%77 = load i32, i32* %16
%78 = load double*, double** %17
%79 = load double*, double** %18
%80 = load i32, i32* %16
%81 = load double*, double** %18
%82 = getelementptr inbounds double, double* %81, i64 1
%83 = load i32*, i32** %19
%84 = load double*, double** %20
%85 = load i32, i32* %21
%86 = load i32, i32* %12
%87 = load i32, i32* %16
%88 = load double*, double** %18
%89 = load i32*, i32** %15
%90 = load i32, i32* %16
%91 = load double*, double** %17
%92 = load i32, i32* %16
%93 = load double*, double** %17
%94 = getelementptr inbounds double, double* %93, i64 1
%95 = load i32*, i32** %19
%96 = load double*, double** %20
%97 = load i32, i32* %11
%98 = load i32, i32* %12
%99 = load i32, i32* %16
%100 = load double*, double** %17
%101 = load i32*, i32** %14
%102 = load i32*, i32** %15
%103 = getelementptr inbounds i32, i32* %102, i64 0
%104 = load i32, i32* %103
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %117
106: ; preds = %55
%107 = load i32, i32* %21
%108 = load i32, i32* %12
%109 = load i32*, i32** %15
%110 = load i32*, i32** %15
%111 = load i32*, i32** %15
%112 = load i32, i32* %11
%113 = load i32, i32* %12
%114 = load i32*, i32** %14
%115 = load i32*, i32** %15
%116 = load i32*, i32** %14
br label %117
117: ; preds = %106, %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)
%34 = getelementptr inbounds double, double* %6, i64 1
tail call void @rdft(i32 %5, i32 1, double* %34, i32* %8, double* %9)
tail call void @mp_mul_i2d(i32 %0, i32 %1, i32 %5, i32 %28, i32* %2, double* %7)
%35 = getelementptr inbounds double, double* %7, i64 1
tail call void @rdft(i32 %5, i32 1, double* %35, i32* %8, double* %9)
tail call void @mp_mul_cmul(i32 %5, double* %6, double* %7)
tail call void @rdft(i32 %5, i32 -1, double* %35, 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(i32 %5, double* %6)
tail call void @rdft(i32 %5, i32 -1, double* %34, i32* %8, double* %9)
tail call void @mp_mul_d2i(i32 %0, i32 %1, i32 %5, double* %6, i32* %3)
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 0
br i1 %37, label %39, label %38
38: ; 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 %39
39: ; preds = %38, %27
ret void
}