#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*/ cftleaf(int, int, double *);
int /*<<< orphan*/ cftmdl1(int, double *);
int cfttree(int, int, int, double *);
void cftrec4(int n, double *a) {
  int isplt, j, k, m;
  m = n;
  while (m > 512) {
    m >>= 2;
    cftmdl1(m, &a[n - m]);
  }
  cftleaf(m, 1, &a[n - m]);
  k = 0;
  for (j = n - m; j > 0; j -= m) {
    k++;
    isplt = cfttree(m, j, k, a);
    cftleaf(m, isplt, &a[j - m]);
  }
}


x86 assembly (clang, -O0):
<cftrec4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x200,-0x20(%rbp)
jle    117b <cftrec4+0x4b>
mov    -0x20(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%eax
sub    -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
call   1040 <cftmdl1@plt>
jmp    1145 <cftrec4+0x15>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%eax
sub    -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    $0x1,%esi
call   1030 <cftleaf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1201 <cftrec4+0xd1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1050 <cfttree@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%eax
sub    -0x20(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1030 <cftleaf@plt>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    11ab <cftrec4+0x7b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cftrec4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
mov    %edi,%r15d
cmp    $0x201,%edi
jl     1172 <cftrec4+0x42>
mov    %ebx,%ebp
mov    %ebx,%r15d
shr    $0x2,%r15d
mov    %ebx,%eax
sub    %r15d,%eax
cltq
lea    (%r14,%rax,8),%rsi
mov    %r15d,%edi
call   1040 <cftmdl1@plt>
cmp    $0x803,%ebp
mov    %r15d,%ebp
ja     1150 <cftrec4+0x20>
mov    %ebx,%ebp
sub    %r15d,%ebp
movslq %ebp,%r13
lea    (%r14,%r13,8),%rdx
mov    $0x1,%r12d
mov    %r15d,%edi
mov    $0x1,%esi
call   1030 <cftleaf@plt>
test   %r13d,%r13d
jle    11cf <cftrec4+0x9f>
sub    %r15d,%ebx
sub    %r15d,%ebx
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1050 <cfttree@plt>
sub    %r15d,%ebp
movslq %ebx,%rbx
lea    (%r14,%rbx,8),%rdx
mov    %r15d,%edi
mov    %eax,%esi
call   1030 <cftleaf@plt>
add    $0x1,%r12d
sub    %r15d,%ebx
test   %ebp,%ebp
jg     11a0 <cftrec4+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cftrec4(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%9 = load i32, i32* %3
store i32 %9, i32* %8
br label %10
10: ; preds = %13, %2
%11 = load i32, i32* %8
%12 = icmp sgt i32 %11, 512
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32, i32* %8
%15 = ashr i32 %14, 2
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = load double*, double** %4
%18 = load i32, i32* %3
%19 = load i32, i32* %8
%20 = sub nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %17, i64 %21
%23 = call i32 @cftmdl1(i32 %16, double* %22)
br label %10
24: ; preds = %10
%25 = load i32, i32* %8
%26 = load double*, double** %4
%27 = load i32, i32* %3
%28 = load i32, i32* %8
%29 = sub nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %26, i64 %30
%32 = call i32 @cftleaf(i32 %25, i32 1, double* %31)
store i32 0, i32* %7
%33 = load i32, i32* %3
%34 = load i32, i32* %8
%35 = sub nsw i32 %33, %34
store i32 %35, i32* %6
br label %36
36: ; preds = %56, %24
%37 = load i32, i32* %6
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %60
39: ; preds = %36
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
%42 = load i32, i32* %8
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = load double*, double** %4
%46 = call i32 @cfttree(i32 %42, i32 %43, i32 %44, double* %45)
store i32 %46, i32* %5
%47 = load i32, i32* %8
%48 = load i32, i32* %5
%49 = load double*, double** %4
%50 = load i32, i32* %6
%51 = load i32, i32* %8
%52 = sub nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %49, i64 %53
%55 = call i32 @cftleaf(i32 %47, i32 %48, double* %54)
br label %56
56: ; preds = %39
%57 = load i32, i32* %8
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, %57
store i32 %59, i32* %6
br label %36
60: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @cftrec4(i32 %0, double* %1) {
%3 = icmp sgt i32 %0, 512
br i1 %3, label %4, label %12
4: ; preds = %2, %4
%5 = phi i32 [ %6, %4 ], [ %0, %2 ]
%6 = lshr i32 %5, 2
%7 = sub nsw i32 %0, %6
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = tail call i32 @cftmdl1(i32 %6, double* %9)
%11 = icmp ugt i32 %5, 2051
br i1 %11, label %4, label %12
12: ; preds = %4, %2
%13 = phi i32 [ %0, %2 ], [ %6, %4 ]
%14 = sub nsw i32 %0, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = tail call i32 @cftleaf(i32 %13, i32 1, double* %16)
%18 = icmp sgt i32 %14, 0
br i1 %18, label %19, label %29
19: ; preds = %12, %19
%20 = phi i32 [ %22, %19 ], [ 0, %12 ]
%21 = phi i32 [ %24, %19 ], [ %14, %12 ]
%22 = add nuw nsw i32 %20, 1
%23 = tail call i32 @cfttree(i32 %13, i32 %21, i32 %22, double* %1)
%24 = sub nsw i32 %21, %13
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = tail call i32 @cftleaf(i32 %13, i32 %23, double* %26)
%28 = icmp sgt i32 %24, 0
br i1 %28, label %19, label %29
29: ; preds = %19, %12
ret void
}