void mp_mul(int n, int radix, int in1[], int in2[], int out[], int tmp[],
            int nfft, double tmp1fft[], double tmp2fft[], double tmp3fft[],
            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_cmuladd(int nfft, double din1[], double din2[], 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 (in1[shift + 2] + in2[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, in1, tmp1fft);
  rdft(nfft, 1, &tmp1fft[1], ip, w);
  mp_mul_i2d(n, radix, nfft, shift, in2, tmp3fft);
  rdft(nfft, 1, &tmp3fft[1], ip, w);
  mp_mul_cmul(nfft, tmp1fft, tmp3fft);
  mp_mul_i2d(n, radix, nfft, 0, in2, tmp2fft);
  rdft(nfft, 1, &tmp2fft[1], ip, w);
  mp_mul_cmul(nfft, tmp2fft, tmp1fft);
  rdft(nfft, -1, &tmp1fft[1], ip, w);
  mp_mul_d2i(n, radix, nfft, tmp1fft, tmp);
  mp_mul_i2d(n, radix, nfft, shift, in1, tmp1fft);
  rdft(nfft, 1, &tmp1fft[1], ip, w);
  mp_mul_cmuladd(nfft, tmp1fft, tmp2fft, tmp3fft);
  rdft(nfft, -1, &tmp3fft[1], ip, w);
  mp_mul_d2i(n_h, radix, nfft, tmp3fft, out);
  mp_add(n, radix, out, tmp, out);
}


x86 assembly (clang, -O0):
<mp_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%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
cmp    -0x30(%rbp),%eax
jle    11e9 <mp_mul+0x89>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%edx
add    $0x2,%edx
movslq %edx,%rdx
add    (%rcx,%rdx,4),%eax
cmp    $0x0,%eax
je     11db <mp_mul+0x7b>
jmp    11e9 <mp_mul+0x89>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11a1 <mp_mul+0x41>
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    1214 <mp_mul+0xb4>
mov    -0x4(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x10(%rbp),%r8
mov    0x18(%rbp),%r9
xor    %ecx,%ecx
call   1030 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    0x28(%rbp),%r9
call   1030 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x28(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
call   1070 <mp_mul_cmul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x18(%rbp),%r8
mov    0x20(%rbp),%r9
xor    %ecx,%ecx
call   1030 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x20(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@plt>
mov    0x10(%rbp),%edi
mov    0x20(%rbp),%rsi
mov    0x18(%rbp),%rdx
call   1070 <mp_mul_cmul@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0xffffffff,%esi
call   1060 <rdft@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1080 <mp_mul_d2i@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    0x18(%rbp),%r9
call   1030 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0x1,%esi
call   1060 <rdft@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rsi
mov    0x20(%rbp),%rdx
mov    0x28(%rbp),%rcx
call   1040 <mp_mul_cmuladd@plt>
mov    0x10(%rbp),%edi
mov    0x28(%rbp),%rdx
add    $0x8,%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
mov    $0xffffffff,%esi
call   1060 <rdft@plt>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1080 <mp_mul_d2i@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1050 <mp_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_mul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x40(%rsp)
mov    %r8,0x50(%rsp)
mov    %rcx,%r13
mov    %rdx,%r12
mov    %esi,%r14d
mov    0xb8(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0xb0(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0xa8(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0xa0(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x90(%rsp),%r15d
mov    %r15d,%ebp
sar    %ebp
movslq %ebp,%rcx
movslq %edi,%rax
lea    0x1(%rcx),%edx
cmp    %edx,%eax
cmovg  %edi,%edx
add    $0x3,%rcx
mov    0x98(%rsp),%r9
nopl   0x0(%rax)
lea    -0x2(%rcx),%rsi
cmp    %rax,%rsi
jge    1200 <mp_mul+0xa0>
mov    (%r12,%rcx,4),%esi
lea    0x1(%rcx),%rbx
add    $0x1,%ebp
add    0x0(%r13,%rcx,4),%esi
mov    %rbx,%rcx
je     11e0 <mp_mul+0x80>
jmp    1202 <mp_mul+0xa2>
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,0x24(%rsp)
mov    %r14d,%esi
mov    %r15d,%edx
xor    %ecx,%ecx
mov    %r14d,0x4(%rsp)
mov    %edi,%r14d
mov    %edi,(%rsp)
mov    %r12,%r8
mov    %r9,%rbx
mov    %r9,0x28(%rsp)
call   1030 <mp_mul_i2d@plt>
lea    0x8(%rbx),%rdx
mov    %rdx,0x30(%rsp)
mov    %r15d,%edi
mov    $0x1,%esi
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
call   1060 <rdft@plt>
mov    %r14d,%edi
mov    0x4(%rsp),%r14d
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r13,%r8
mov    0x18(%rsp),%rbx
mov    %rbx,%r9
call   1030 <mp_mul_i2d@plt>
lea    0x8(%rbx),%rdx
mov    %rdx,0x48(%rsp)
mov    %r15d,%edi
mov    $0x1,%esi
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
call   1060 <rdft@plt>
mov    %r15d,%edi
mov    0x28(%rsp),%rsi
mov    0x18(%rsp),%rdx
call   1070 <mp_mul_cmul@plt>
mov    (%rsp),%edi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    0x38(%rsp),%r14
mov    %r14,%r9
call   1030 <mp_mul_i2d@plt>
lea    0x8(%r14),%rdx
mov    %r15d,%edi
mov    $0x1,%esi
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
mov    0x10(%rsp),%r13
mov    %r13,%r8
call   1060 <rdft@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    0x28(%rsp),%rdx
mov    %rdx,%r14
call   1070 <mp_mul_cmul@plt>
mov    %r15d,%edi
mov    $0xffffffff,%esi
mov    0x30(%rsp),%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1060 <rdft@plt>
mov    (%rsp),%ebx
mov    %ebx,%edi
mov    0x4(%rsp),%r13d
mov    %r13d,%esi
mov    %r15d,%edx
mov    %r14,%rcx
mov    0x40(%rsp),%r8
call   1080 <mp_mul_d2i@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r12,%r8
mov    %r14,%rbp
mov    %r14,%r9
call   1030 <mp_mul_i2d@plt>
mov    %r15d,%edi
mov    $0x1,%esi
mov    0x30(%rsp),%rdx
mov    0x8(%rsp),%r14
mov    %r14,%rcx
mov    0x10(%rsp),%rbx
mov    %rbx,%r8
call   1060 <rdft@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    0x38(%rsp),%rdx
mov    0x18(%rsp),%rbp
mov    %rbp,%rcx
call   1040 <mp_mul_cmuladd@plt>
mov    %r15d,%edi
mov    $0xffffffff,%esi
mov    0x48(%rsp),%rdx
mov    %r14,%rcx
mov    %rbx,%r8
call   1060 <rdft@plt>
mov    0x24(%rsp),%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    0x50(%rsp),%rbp
mov    %rbp,%r8
call   1080 <mp_mul_d2i@plt>
mov    (%rsp),%edi
mov    %r13d,%esi
mov    %rbp,%rdx
mov    0x40(%rsp),%rcx
mov    %rbp,%r8
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <mp_add@plt>

LLVM IR (-O0):
define void @mp_mul(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6, double* %7, double* %8, double* %9, i32* %10, double* %11) {
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca i32*
%24 = alloca double*
%25 = alloca i32
%26 = alloca i32
store i32 %0, i32* %13
store i32 %1, i32* %14
store i32* %2, i32** %15
store i32* %3, i32** %16
store i32* %4, i32** %17
store i32* %5, i32** %18
store i32 %6, i32* %19
store double* %7, double** %20
store double* %8, double** %21
store double* %9, double** %22
store i32* %10, i32** %23
store double* %11, double** %24
%27 = load i32, i32* %19
%28 = ashr i32 %27, 1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %26
br label %30
30: ; preds = %50, %12
%31 = load i32, i32* %13
%32 = load i32, i32* %26
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %53
34: ; preds = %30
%35 = load i32*, i32** %15
%36 = load i32, i32* %26
%37 = add nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
%40 = load i32, i32* %39
%41 = load i32*, i32** %16
%42 = load i32, i32* %26
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %41, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %40, %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %34
br label %53
50: ; preds = %34
%51 = load i32, i32* %26
%52 = add nsw i32 %51, 1
store i32 %52, i32* %26
br label %30
53: ; preds = %49, %30
%54 = load i32, i32* %13
%55 = sdiv i32 %54, 2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %25
%57 = load i32, i32* %25
%58 = load i32, i32* %13
%59 = load i32, i32* %26
%60 = sub nsw i32 %58, %59
%61 = icmp slt i32 %57, %60
br i1 %61, label %62, label %66
62: ; preds = %53
%63 = load i32, i32* %13
%64 = load i32, i32* %26
%65 = sub nsw i32 %63, %64
store i32 %65, i32* %25
br label %66
66: ; preds = %62, %53
%67 = load i32, i32* %13
%68 = load i32, i32* %14
%69 = load i32, i32* %19
%70 = load i32*, i32** %15
%71 = load double*, double** %20
%72 = load i32, i32* %19
%73 = load double*, double** %20
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load i32*, i32** %23
%76 = load double*, double** %24
%77 = load i32, i32* %13
%78 = load i32, i32* %14
%79 = load i32, i32* %19
%80 = load i32, i32* %26
%81 = load i32*, i32** %16
%82 = load double*, double** %22
%83 = load i32, i32* %19
%84 = load double*, double** %22
%85 = getelementptr inbounds double, double* %84, i64 1
%86 = load i32*, i32** %23
%87 = load double*, double** %24
%88 = load i32, i32* %19
%89 = load double*, double** %20
%90 = load double*, double** %22
%91 = load i32, i32* %13
%92 = load i32, i32* %14
%93 = load i32, i32* %19
%94 = load i32*, i32** %16
%95 = load double*, double** %21
%96 = load i32, i32* %19
%97 = load double*, double** %21
%98 = getelementptr inbounds double, double* %97, i64 1
%99 = load i32*, i32** %23
%100 = load double*, double** %24
%101 = load i32, i32* %19
%102 = load double*, double** %21
%103 = load double*, double** %20
%104 = load i32, i32* %19
%105 = load double*, double** %20
%106 = getelementptr inbounds double, double* %105, i64 1
%107 = load i32*, i32** %23
%108 = load double*, double** %24
%109 = load i32, i32* %13
%110 = load i32, i32* %14
%111 = load i32, i32* %19
%112 = load double*, double** %20
%113 = load i32*, i32** %18
%114 = load i32, i32* %13
%115 = load i32, i32* %14
%116 = load i32, i32* %19
%117 = load i32, i32* %26
%118 = load i32*, i32** %15
%119 = load double*, double** %20
%120 = load i32, i32* %19
%121 = load double*, double** %20
%122 = getelementptr inbounds double, double* %121, i64 1
%123 = load i32*, i32** %23
%124 = load double*, double** %24
%125 = load i32, i32* %19
%126 = load double*, double** %20
%127 = load double*, double** %21
%128 = load double*, double** %22
%129 = load i32, i32* %19
%130 = load double*, double** %22
%131 = getelementptr inbounds double, double* %130, i64 1
%132 = load i32*, i32** %23
%133 = load double*, double** %24
%134 = load i32, i32* %25
%135 = load i32, i32* %14
%136 = load i32, i32* %19
%137 = load double*, double** %22
%138 = load i32*, i32** %17
%139 = load i32, i32* %13
%140 = load i32, i32* %14
%141 = load i32*, i32** %17
%142 = load i32*, i32** %18
%143 = load i32*, i32** %17
ret void
}

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