void FFT1D(direction, M, N, x, scratch, upriv, umain2, MyNum, l_transtime,
           MyFirst, MyLast, pad_length, P, test_result, doprint, dostats,
           Global) int direction;
int M;
int N;
int *l_transtime;
double *x;
double *upriv;
double *scratch;
double *umain2;
int MyFirst;
int MyLast;
int pad_length;
int P;
int test_result;
int doprint;
int dostats;
struct GlobalMemory *Global;
{
  int i;
  int j;
  int m1;
  int n1;
  int flag = 0;
  unsigned int clocktime1;
  unsigned int clocktime2;
  m1 = M / 2;
  n1 = 1 << m1;
  Transpose(n1, x, scratch, MyNum, MyFirst, MyLast, pad_length);
  for (j = MyFirst; j < MyLast; j++) {
    FFT1DOnce(direction, m1, n1, upriv, &scratch[2 * j * (n1 + pad_length)]);
    TwiddleOneCol(direction, n1, N, j, umain2,
                  &scratch[2 * j * (n1 + pad_length)], pad_length);
  }
  Transpose(n1, scratch, x, MyNum, MyFirst, MyLast, pad_length);
  for (j = MyFirst; j < MyLast; j++) {
    FFT1DOnce(direction, m1, n1, upriv, &x[2 * j * (n1 + pad_length)]);
    if (direction == -1)
      Scale(n1, N, &x[2 * j * (n1 + pad_length)]);
  }
  Transpose(n1, x, scratch, MyNum, MyFirst, MyLast, pad_length);
}


x86 assembly (clang, -O0):
<FFT1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x60(%rbp),%rax
mov    0x58(%rbp),%eax
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x28(%rbp),%r8d
mov    0x30(%rbp),%r9d
mov    0x38(%rbp),%eax
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <Transpose@plt>
mov    0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x30(%rbp),%eax
jge    1255 <FFT1D+0x115>
mov    -0x4(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
mov    -0x38(%rbp),%r9d
add    0x38(%rbp),%r9d
imul   %r9d,%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    $0x0,%al
call   1050 <FFT1DOnce@plt>
mov    -0x4(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    0x10(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
mov    -0x38(%rbp),%r10d
add    0x38(%rbp),%r10d
imul   %r10d,%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    0x38(%rbp),%eax
mov    %eax,(%rsp)
mov    $0x0,%al
call   1060 <TwiddleOneCol@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11cc <FFT1D+0x8c>
mov    -0x38(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x28(%rbp),%r8d
mov    0x30(%rbp),%r9d
mov    0x38(%rbp),%eax
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <Transpose@plt>
mov    0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    0x30(%rbp),%eax
jge    1303 <FFT1D+0x1c3>
mov    -0x4(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
mov    -0x38(%rbp),%r9d
add    0x38(%rbp),%r9d
imul   %r9d,%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    $0x0,%al
call   1050 <FFT1DOnce@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    12f0 <FFT1D+0x1b0>
mov    -0x38(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
mov    -0x38(%rbp),%ecx
add    0x38(%rbp),%ecx
imul   %ecx,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    $0x0,%al
call   1030 <Scale@plt>
jmp    12f5 <FFT1D+0x1b5>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    127e <FFT1D+0x13e>
mov    -0x38(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    0x18(%rbp),%ecx
mov    0x28(%rbp),%r8d
mov    0x30(%rbp),%r9d
mov    0x38(%rbp),%eax
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <Transpose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FFT1D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %rcx,%rbp
mov    %edx,0x14(%rsp)
mov    %edi,0x10(%rsp)
mov    0x98(%rsp),%r12d
mov    0x90(%rsp),%r14d
mov    0x88(%rsp),%ebx
mov    0x78(%rsp),%eax
mov    %esi,%r15d
shr    $0x1f,%r15d
add    %esi,%r15d
sar    %r15d
mov    $0x1,%r13d
mov    %r15d,%ecx
shl    %cl,%r13d
mov    %r12d,(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %r8,0x20(%rsp)
mov    %r8,%rdx
mov    %eax,%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <Transpose@plt>
cmp    %r14d,%ebx
jge    1301 <FFT1D+0x1c1>
mov    %rbp,0x28(%rsp)
lea    (%r12,%r13,1),%eax
mov    %ebx,%r12d
imul   %eax,%r12d
add    %eax,%eax
mov    %eax,0x18(%rsp)
lea    (%r12,%r12,1),%r14d
mov    %r13,%rax
mov    %r15d,0x1c(%rsp)
mov    0x10(%rsp),%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %r14d,%r14
mov    0x20(%rsp),%rcx
lea    (%rcx,%r14,8),%r15
mov    %ebp,%edi
mov    0x1c(%rsp),%esi
mov    %rax,%r13
mov    %r13d,%edx
mov    0x30(%rsp),%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <FFT1DOnce@plt>
mov    0x98(%rsp),%eax
mov    %eax,(%rsp)
mov    %ebp,%edi
mov    %r13d,%esi
mov    0x14(%rsp),%edx
mov    %ebx,%ecx
mov    0x70(%rsp),%r8
mov    %r15,%r9
xor    %eax,%eax
call   1060 <TwiddleOneCol@plt>
mov    %r13,%rax
add    $0x1,%ebx
add    0x18(%rsp),%r14d
cmp    %ebx,0x90(%rsp)
jne    11f0 <FFT1D+0xb0>
mov    0x98(%rsp),%ecx
mov    %ecx,(%rsp)
mov    %eax,%edi
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%r14
mov    %r14,%rdx
mov    0x78(%rsp),%ecx
mov    0x88(%rsp),%ebx
mov    %ebx,%r8d
mov    0x90(%rsp),%ebp
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <Transpose@plt>
mov    %r13,%rdx
cmp    %ebp,%ebx
mov    0x30(%rsp),%rcx
mov    0x10(%rsp),%esi
jge    1327 <FFT1D+0x1e7>
add    %r12d,%r12d
mov    0x90(%rsp),%ebp
sub    0x88(%rsp),%ebp
jmp    12c5 <FFT1D+0x185>
xchg   %ax,%ax
add    0x18(%rsp),%r12d
add    $0xffffffff,%ebp
mov    %r13,%rdx
mov    %r14,%rcx
mov    0x28(%rsp),%r14
je     1327 <FFT1D+0x1e7>
movslq %r12d,%rax
lea    (%r14,%rax,8),%rbx
mov    %esi,%r15d
mov    %esi,%edi
mov    0x1c(%rsp),%esi
mov    %rcx,%r14
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <FFT1DOnce@plt>
mov    %r15d,%esi
cmp    $0xffffffff,%r15d
jne    12b0 <FFT1D+0x170>
mov    %r13d,%edi
mov    0x14(%rsp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <Scale@plt>
mov    %r15d,%esi
jmp    12b0 <FFT1D+0x170>
mov    %r12d,(%rsp)
mov    %r13d,%edi
mov    0x20(%rsp),%rsi
mov    %rbp,%rdx
mov    0x78(%rsp),%ecx
mov    %ebx,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <Transpose@plt>
mov    %r13,%rdx
mov    %rbp,%r14
mov    0x98(%rsp),%eax
mov    %eax,(%rsp)
mov    %edx,%edi
mov    %r14,%rsi
mov    0x20(%rsp),%rdx
mov    0x78(%rsp),%ecx
mov    0x88(%rsp),%r8d
mov    0x90(%rsp),%r9d
xor    %eax,%eax
call   1040 <Transpose@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.GlobalMemory = type opaque
define void @FFT1D(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6, i32 %7, i32* nocapture readnone %8, i32 %9, i32 %10, i32 %11, i32 %12, i32 %13, i32 %14, i32 %15, %struct.GlobalMemory* nocapture readnone %16) {
%18 = sdiv i32 %1, 2
%19 = shl nuw i32 1, %18
%20 = tail call i32 (i32, double*, double*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @Transpose to i32 (i32, double*, double*, i32, i32, i32, i32, ...)*)(i32 %19, double* %3, double* %4, i32 %7, i32 %9, i32 %10, i32 %11)
%21 = icmp slt i32 %9, %10
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 (i32, double*, double*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @Transpose to i32 (i32, double*, double*, i32, i32, i32, i32, ...)*)(i32 %19, double* %4, double* %3, i32 %7, i32 %9, i32 %10, i32 %11)
br label %59
24: ; preds = %17
%25 = add nsw i32 %19, %11
%26 = shl i32 %25, 1
%27 = zext i32 %9 to i64
br label %28
28: ; preds = %24, %28
%29 = phi i64 [ %27, %24 ], [ %36, %28 ]
%30 = trunc i64 %29 to i32
%31 = mul i32 %26, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %4, i64 %32
%34 = tail call i32 (i32, i32, i32, double*, double*, ...) bitcast (i32 (...)* @FFT1DOnce to i32 (i32, i32, i32, double*, double*, ...)*)(i32 %0, i32 %18, i32 %19, double* %5, double* %33)
%35 = tail call i32 (i32, i32, i32, i32, double*, double*, i32, ...) bitcast (i32 (...)* @TwiddleOneCol to i32 (i32, i32, i32, i32, double*, double*, i32, ...)*)(i32 %0, i32 %19, i32 %2, i32 %30, double* %6, double* %33, i32 %11)
%36 = add i64 %29, 1
%37 = trunc i64 %36 to i32
%38 = icmp eq i32 %37, %10
br i1 %38, label %39, label %28
39: ; preds = %28
%40 = tail call i32 (i32, double*, double*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @Transpose to i32 (i32, double*, double*, i32, i32, i32, i32, ...)*)(i32 %19, double* %4, double* %3, i32 %7, i32 %9, i32 %10, i32 %11)
br i1 %21, label %41, label %59
41: ; preds = %39
%42 = add nsw i32 %19, %11
%43 = shl i32 %42, 1
%44 = icmp eq i32 %0, -1
%45 = zext i32 %9 to i64
br label %46
46: ; preds = %41, %55
%47 = phi i64 [ %45, %41 ], [ %56, %55 ]
%48 = trunc i64 %47 to i32
%49 = mul i32 %43, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %3, i64 %50
%52 = tail call i32 (i32, i32, i32, double*, double*, ...) bitcast (i32 (...)* @FFT1DOnce to i32 (i32, i32, i32, double*, double*, ...)*)(i32 %0, i32 %18, i32 %19, double* %5, double* %51)
br i1 %44, label %53, label %55
53: ; preds = %46
%54 = tail call i32 (i32, i32, double*, ...) bitcast (i32 (...)* @Scale to i32 (i32, i32, double*, ...)*)(i32 %19, i32 %2, double* %51)
br label %55
55: ; preds = %46, %53
%56 = add i64 %47, 1
%57 = trunc i64 %56 to i32
%58 = icmp eq i32 %57, %10
br i1 %58, label %59, label %46
59: ; preds = %55, %22, %39
%60 = tail call i32 (i32, double*, double*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @Transpose to i32 (i32, double*, double*, i32, i32, i32, i32, ...)*)(i32 %19, double* %3, double* %4, i32 %7, i32 %9, i32 %10, i32 %11)
ret void
}