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_copy(int n, int radix, int in[], int out[]);
  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_nt_out(int nfft, double d1[], double d2[], int ip[],
                          double w[]);
  void mp_mul_cmul_nt_d2(int nfft, double d1[], double d2[], int ip[],
                         double w[]);
  void mp_mul_cmul_nt_d1_add(int nfft, double d1[], double d2[], double d3[],
                             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 (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);
  mp_mul_i2d(n, radix, nfft, shift, in2, tmp3fft);
  mp_mul_cmul_nt_out(nfft, tmp1fft, tmp3fft, ip, w);
  mp_mul_i2d(n, radix, nfft, 0, in2, tmp2fft);
  mp_mul_cmul_nt_d2(nfft, tmp2fft, tmp1fft, ip, w);
  mp_mul_d2i(n, radix, nfft, tmp1fft, tmp);
  mp_mul_i2d(n, radix, nfft, shift, in1, tmp1fft);
  mp_mul_cmul_nt_d1_add(nfft, tmp2fft, tmp1fft, tmp3fft, ip, w);
  mp_mul_d2i(n_h, radix, nfft, tmp3fft, out);
  if (out[0] != 0) {
    mp_add(n, radix, out, tmp, out);
  } else {
    mp_copy(n, radix, 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    11f9 <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     11eb <mp_mul+0x7b>
jmp    11f9 <mp_mul+0x89>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b1 <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    1224 <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   1040 <mp_mul_i2d@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   1040 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rsi
mov    0x28(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
call   1080 <mp_mul_cmul_nt_out@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   1040 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x20(%rbp),%rsi
mov    0x18(%rbp),%rdx
mov    0x30(%rbp),%rcx
mov    0x38(%rbp),%r8
call   1030 <mp_mul_cmul_nt_d2@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1090 <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   1040 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x20(%rbp),%rsi
mov    0x18(%rbp),%rdx
mov    0x28(%rbp),%rcx
mov    0x30(%rbp),%r8
mov    0x38(%rbp),%r9
call   1060 <mp_mul_cmul_nt_d1_add@plt>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1090 <mp_mul_d2i@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     1327 <mp_mul+0x1b7>
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>
jmp    133a <mp_mul+0x1ca>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <mp_copy@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    $0x48,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,0x40(%rsp)
mov    %rcx,%r13
mov    %rdx,%r14
mov    %edi,%r12d
mov    0xa8(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0xa0(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x98(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x90(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0x80(%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    0x88(%rsp),%r9
nopl   0x0(%rax)
lea    -0x2(%rcx),%rdi
cmp    %rax,%rdi
jge    1210 <mp_mul+0xa0>
mov    (%r14,%rcx,4),%ebx
lea    0x1(%rcx),%rdi
add    $0x1,%ebp
add    0x0(%r13,%rcx,4),%ebx
mov    %rdi,%rcx
je     11f0 <mp_mul+0x80>
jmp    1212 <mp_mul+0xa2>
mov    %edx,%ebp
mov    %r12d,%eax
shr    $0x1f,%eax
add    %r12d,%eax
sar    %eax
add    $0x1,%eax
mov    %r12d,%ecx
sub    %ebp,%ecx
cmp    %ecx,%eax
cmovge %eax,%ecx
mov    %ecx,0x24(%rsp)
mov    %r12d,%edi
mov    %r15d,%edx
xor    %ecx,%ecx
mov    %esi,%ebx
mov    %esi,0x4(%rsp)
mov    %r14,%r8
mov    %r9,0x28(%rsp)
call   1040 <mp_mul_i2d@plt>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r13,%r8
mov    0x38(%rsp),%rbx
mov    %rbx,%r9
mov    %r12d,(%rsp)
call   1040 <mp_mul_i2d@plt>
mov    %r15d,%edi
mov    0x28(%rsp),%rsi
mov    %rbx,%rdx
mov    (%rsp),%r12d
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
call   1080 <mp_mul_cmul_nt_out@plt>
mov    %r12d,%edi
mov    0x4(%rsp),%esi
mov    %r15d,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    0x30(%rsp),%rbx
mov    %rbx,%r9
call   1040 <mp_mul_i2d@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    0x28(%rsp),%rbx
mov    %rbx,%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
call   1030 <mp_mul_cmul_nt_d2@plt>
mov    %r12d,%edi
mov    0x4(%rsp),%r13d
mov    %r13d,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    0x8(%rsp),%r8
call   1090 <mp_mul_d2i@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %rbx,%r9
call   1040 <mp_mul_i2d@plt>
mov    %r15d,%edi
mov    0x30(%rsp),%rsi
mov    %rbx,%rdx
mov    0x38(%rsp),%rbp
mov    %rbp,%rcx
mov    0x10(%rsp),%r8
mov    0x18(%rsp),%r9
call   1060 <mp_mul_cmul_nt_d1_add@plt>
mov    0x24(%rsp),%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    0x40(%rsp),%rbp
mov    %rbp,%r8
call   1090 <mp_mul_d2i@plt>
cmpl   $0x0,0x0(%rbp)
je     1355 <mp_mul+0x1e5>
mov    (%rsp),%edi
mov    %r13d,%esi
mov    %rbp,%rdx
mov    0x8(%rsp),%rcx
mov    %rbp,%r8
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <mp_add@plt>
mov    (%rsp),%edi
mov    %r13d,%esi
mov    0x8(%rsp),%rdx
mov    %rbp,%rcx
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <mp_copy@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* %13
%73 = load i32, i32* %14
%74 = load i32, i32* %19
%75 = load i32, i32* %26
%76 = load i32*, i32** %16
%77 = load double*, double** %22
%78 = load i32, i32* %19
%79 = load double*, double** %20
%80 = load double*, double** %22
%81 = load i32*, i32** %23
%82 = load double*, double** %24
%83 = load i32, i32* %13
%84 = load i32, i32* %14
%85 = load i32, i32* %19
%86 = load i32*, i32** %16
%87 = load double*, double** %21
%88 = load i32, i32* %19
%89 = load double*, double** %21
%90 = load double*, double** %20
%91 = load i32*, i32** %23
%92 = load double*, double** %24
%93 = load i32, i32* %13
%94 = load i32, i32* %14
%95 = load i32, i32* %19
%96 = load double*, double** %20
%97 = load i32*, i32** %18
%98 = load i32, i32* %13
%99 = load i32, i32* %14
%100 = load i32, i32* %19
%101 = load i32, i32* %26
%102 = load i32*, i32** %15
%103 = load double*, double** %20
%104 = load i32, i32* %19
%105 = load double*, double** %21
%106 = load double*, double** %20
%107 = load double*, double** %22
%108 = load i32*, i32** %23
%109 = load double*, double** %24
%110 = load i32, i32* %25
%111 = load i32, i32* %14
%112 = load i32, i32* %19
%113 = load double*, double** %22
%114 = load i32*, i32** %17
%115 = load i32*, i32** %17
%116 = getelementptr inbounds i32, i32* %115, i64 0
%117 = load i32, i32* %116
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %125
119: ; preds = %66
%120 = load i32, i32* %13
%121 = load i32, i32* %14
%122 = load i32*, i32** %17
%123 = load i32*, i32** %18
%124 = load i32*, i32** %17
br label %130
125: ; preds = %66
%126 = load i32, i32* %13
%127 = load i32, i32* %14
%128 = load i32*, i32** %18
%129 = load i32*, i32** %17
br label %130
130: ; preds = %125, %119
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)
tail call void @mp_mul_i2d(i32 %0, i32 %1, i32 %6, i32 %33, i32* %3, double* %9)
tail call void @mp_mul_cmul_nt_out(i32 %6, double* %7, double* %9, i32* %10, double* %11)
tail call void @mp_mul_i2d(i32 %0, i32 %1, i32 %6, i32 0, i32* %3, double* %8)
tail call void @mp_mul_cmul_nt_d2(i32 %6, double* %8, double* %7, 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 @mp_mul_cmul_nt_d1_add(i32 %6, double* %8, double* %7, double* %9, i32* %10, double* %11)
tail call void @mp_mul_d2i(i32 %38, i32 %1, i32 %6, double* %9, i32* %4)
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %32
tail call void @mp_add(i32 %0, i32 %1, i32* %4, i32* %5, i32* %4)
br label %43
42: ; preds = %32
tail call void @mp_copy(i32 %0, i32 %1, i32* %5, i32* %4)
br label %43
43: ; preds = %42, %41
ret void
}