#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ remove(char *);
void mp_squ(int n, int radix, int in[], int out[], int tmp[], int nfft,
            double tmpfft[]) {
  void f_swap_out(int bytesize, char *f_name, char *out);
  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 rdft(int n, int isgn, double *a);
  void mp_mul_i2d(int n, int radix, int nfft, int shift, int in[],
                  double dout[]);
  void mp_mul_f_cmul(int nfft, char *f_name_in, 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;
  char *f_name_tmp1fft = "tmp1fft.swp";
  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, tmpfft);
  rdft(nfft, 1, &tmpfft[1]);
  f_swap_out((nfft + 2) * sizeof(double), f_name_tmp1fft, (char *)tmpfft);
  mp_mul_csqu(nfft, tmpfft);
  rdft(nfft, -1, &tmpfft[1]);
  mp_mul_d2i(n, radix, nfft, tmpfft, tmp);
  mp_mul_i2d(n, radix, nfft, shift, in, tmpfft);
  rdft(nfft, 1, &tmpfft[1]);
  mp_mul_f_cmul(nfft, f_name_tmp1fft, tmpfft);
  rdft(nfft, -1, &tmpfft[1]);
  mp_mul_d2i(n_h, radix, nfft, tmpfft, out);
  if (out[0] != 0) {
    mp_add(n_h, radix, out, out, out);
    mp_add(n, radix, out, tmp, out);
  } else {
    mp_copy(n, radix, tmp, out);
  }
  remove(f_name_tmp1fft);
}


x86 assembly (clang, -O0):
<mp_squ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
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)
lea    0xe47(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    1209 <mp_squ+0x79>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0x0,%eax
je     11fb <mp_squ+0x6b>
jmp    1209 <mp_squ+0x79>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <mp_squ+0x45>
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    1234 <mp_squ+0xa4>
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   1040 <mp_mul_i2d@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    $0x1,%esi
call   1080 <rdft@plt>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
mov    -0x38(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   1050 <f_swap_out@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rsi
call   1070 <mp_mul_csqu@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    $0xffffffff,%esi
call   1080 <rdft@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   10a0 <mp_mul_d2i@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    0x10(%rbp),%r9
call   1040 <mp_mul_i2d@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    $0x1,%esi
call   1080 <rdft@plt>
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   10b0 <mp_mul_f_cmul@plt>
mov    -0x24(%rbp),%edi
mov    0x10(%rbp),%rdx
add    $0x8,%rdx
mov    $0xffffffff,%esi
call   1080 <rdft@plt>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   10a0 <mp_mul_d2i@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     135c <mp_squ+0x1cc>
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1060 <mp_add@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1060 <mp_add@plt>
jmp    136f <mp_squ+0x1df>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1090 <mp_copy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <remove@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,%ebp
mov    %r8,0x10(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,%r14
mov    %edi,%r12d
mov    0x60(%rsp),%r13
mov    %r9d,%r15d
sar    %r15d
movslq %r15d,%rax
movslq %edi,%rcx
lea    0x1(%rax),%edx
cmp    %edx,%ecx
cmovg  %edi,%edx
add    $0x5,%rax
xchg   %ax,%ax
lea    -0x4(%rax),%rbx
cmp    %rcx,%rbx
jge    11eb <mp_squ+0x5b>
add    $0x1,%r15d
cmpw   $0x0,(%r14,%rax,2)
lea    0x1(%rax),%rax
je     11d0 <mp_squ+0x40>
jmp    11ee <mp_squ+0x5e>
mov    %edx,%r15d
mov    %r12d,%eax
shr    $0x1f,%eax
add    %r12d,%eax
sar    %eax
add    $0x1,%eax
mov    %r12d,%ebx
sub    %r15d,%ebx
cmp    %ebx,%eax
cmovge %eax,%ebx
mov    %r12d,%edi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    %esi,0x8(%rsp)
mov    %r14,%r8
mov    %r13,%r9
call   1040 <mp_mul_i2d@plt>
lea    0x8(%r13),%rdx
mov    %rdx,0x18(%rsp)
mov    %ebp,%edi
mov    $0x1,%esi
call   1080 <rdft@plt>
lea    0x10(,%rbp,8),%edi
lea    0xdc0(%rip),%rsi
mov    %r13,%rdx
call   1050 <f_swap_out@plt>
mov    %ebp,%edi
mov    %r13,%rsi
call   1070 <mp_mul_csqu@plt>
mov    %ebp,%edi
mov    $0xffffffff,%esi
mov    0x18(%rsp),%rdx
call   1080 <rdft@plt>
mov    %r12d,%edi
mov    0x8(%rsp),%esi
mov    %ebp,%edx
mov    %r13,%rcx
mov    0x10(%rsp),%r8
call   10a0 <mp_mul_d2i@plt>
mov    %r12d,0xc(%rsp)
mov    %r12d,%edi
mov    0x8(%rsp),%esi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %ebx,%r15d
mov    %r14,%r8
mov    %r13,%r9
call   1040 <mp_mul_i2d@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    0x18(%rsp),%rbx
mov    %rbx,%rdx
call   1080 <rdft@plt>
mov    %ebp,%edi
lea    0xd4b(%rip),%rsi
mov    %r13,%rdx
call   10b0 <mp_mul_f_cmul@plt>
mov    %ebp,%edi
mov    $0xffffffff,%esi
mov    %rbx,%rdx
mov    0x8(%rsp),%r14d
call   1080 <rdft@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r13,%rcx
mov    0x20(%rsp),%rbx
mov    %rbx,%r8
call   10a0 <mp_mul_d2i@plt>
cmpl   $0x0,(%rbx)
je     131b <mp_squ+0x18b>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
call   1060 <mp_add@plt>
mov    0xc(%rsp),%edi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    0x10(%rsp),%rcx
mov    %rbx,%r8
call   1060 <mp_add@plt>
jmp    132f <mp_squ+0x19f>
mov    0xc(%rsp),%edi
mov    %r14d,%esi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
call   1090 <mp_copy@plt>
lea    0xcca(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <remove@plt>

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

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