void mp_mulhf(int n, int radix, int in1[], int in2[], int out[], int tmp[],
              int nfft, double in1fft[], double tmpfft[], 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(int nfft, double d1[], double d2[], int ip[], double w[]);
  void mp_mul_cmul_nt_d1(int nfft, double d1[], double d2[], 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 (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, in1fft);
  mp_mul_i2d(n, radix, nfft, 0, in2, tmpfft);
  mp_mul_cmul(nfft, in1fft, tmpfft, ip, w);
  mp_mul_d2i(n, radix, nfft, tmpfft, tmp);
  mp_mul_i2d(n, radix, nfft, shift, in2, tmpfft);
  mp_mul_cmul_nt_d1(nfft, in1fft, tmpfft, ip, w);
  mp_mul_d2i(n_h, radix, nfft, tmpfft, out);
  if (out[0] != 0) {
    mp_add(n, radix, out, tmp, out);
  } else {
    mp_copy(n, radix, tmp, out);
  }
}


x86 assembly (clang, -O0):
<mp_mulhf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    11d3 <mp_mulhf+0x73>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11c5 <mp_mulhf+0x65>
jmp    11d3 <mp_mulhf+0x73>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    119d <mp_mulhf+0x3d>
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    11fe <mp_mulhf+0x9e>
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    -0x18(%rbp),%r8
mov    0x20(%rbp),%r9
xor    %ecx,%ecx
call   1040 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rsi
mov    0x20(%rbp),%rdx
mov    0x28(%rbp),%rcx
mov    0x30(%rbp),%r8
call   1060 <mp_mul_cmul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x20(%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    -0x18(%rbp),%r8
mov    0x20(%rbp),%r9
call   1040 <mp_mul_i2d@plt>
mov    0x10(%rbp),%edi
mov    0x18(%rbp),%rsi
mov    0x20(%rbp),%rdx
mov    0x28(%rbp),%rcx
mov    0x30(%rbp),%r8
call   1030 <mp_mul_cmul_nt_d1@plt>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1080 <mp_mul_d2i@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     12cc <mp_mulhf+0x16c>
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    12df <mp_mulhf+0x17f>
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_mulhf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,0x30(%rsp)
mov    %rcx,%r14
mov    %rdx,%r8
mov    %esi,%r13d
mov    0x90(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x88(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0x80(%rsp),%r15
mov    0x78(%rsp),%r9
mov    0x70(%rsp),%r12d
mov    %r12d,%ebp
sar    %ebp
movslq %ebp,%rcx
movslq %edi,%rax
lea    0x1(%rcx),%ebx
cmp    %ebx,%eax
cmovg  %edi,%ebx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %rax,%rcx
jge    11e6 <mp_mulhf+0x86>
add    $0x1,%ebp
cmpl   $0x0,0x8(%r14,%rcx,4)
lea    0x1(%rcx),%rcx
je     11d0 <mp_mulhf+0x70>
jmp    11e8 <mp_mulhf+0x88>
mov    %ebx,%ebp
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
add    $0x1,%eax
mov    %edi,%ebx
mov    %edi,%ecx
sub    %ebp,%ecx
cmp    %ecx,%eax
cmovge %eax,%ecx
mov    %ecx,0x14(%rsp)
mov    %r13d,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    %r9,0x18(%rsp)
call   1040 <mp_mul_i2d@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1040 <mp_mul_i2d@plt>
mov    %r12d,%edi
mov    0x18(%rsp),%rsi
mov    %r15,%rdx
mov    0x20(%rsp),%rcx
mov    0x28(%rsp),%r8
call   1060 <mp_mul_cmul@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    0x8(%rsp),%r8
call   1080 <mp_mul_d2i@plt>
mov    %ebx,0x4(%rsp)
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1040 <mp_mul_i2d@plt>
mov    %r12d,%edi
mov    0x18(%rsp),%rsi
mov    %r15,%rdx
mov    0x20(%rsp),%rcx
mov    0x28(%rsp),%r8
call   1030 <mp_mul_cmul_nt_d1@plt>
mov    0x14(%rsp),%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    0x30(%rsp),%rbx
mov    %rbx,%r8
call   1080 <mp_mul_d2i@plt>
cmpl   $0x0,(%rbx)
je     12d0 <mp_mulhf+0x170>
mov    0x4(%rsp),%edi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%r8
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <mp_add@plt>
mov    0x4(%rsp),%edi
mov    %r13d,%esi
mov    0x8(%rsp),%rdx
mov    %rbx,%rcx
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <mp_copy@plt>

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

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