#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 */
void ffts_elaborate_tree(size_t **p, int N, int leaf_N, int offset) {
  if (N <= leaf_N) {
    return;
  }
  ffts_elaborate_tree(p, N / 4, leaf_N, offset);
  ffts_elaborate_tree(p, N / 8, leaf_N, offset + N / 4);
  ffts_elaborate_tree(p, N / 8, leaf_N, offset + N / 4 + N / 8);
  ffts_elaborate_tree(p, N / 4, leaf_N, offset + N / 2);
  ffts_elaborate_tree(p, N / 4, leaf_N, offset + 3 * N / 4);
  (*p)[0] = N;
  (*p)[1] = 2 * offset;
  (*p) += 2;
}


x86 assembly (clang, -O0):
<ffts_elaborate_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1136 <ffts_elaborate_tree+0x26>
jmp    1256 <ffts_elaborate_tree+0x146>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <ffts_elaborate_tree@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    $0x4,%r8d
cltd
idiv   %r8d
mov    -0x24(%rbp),%edx
add    %eax,%ecx
call   1030 <ffts_elaborate_tree@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    $0x4,%r8d
cltd
idiv   %r8d
add    %eax,%ecx
mov    -0xc(%rbp),%eax
mov    $0x8,%r8d
cltd
idiv   %r8d
mov    -0x20(%rbp),%edx
add    %eax,%ecx
call   1030 <ffts_elaborate_tree@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x1c(%rbp),%edx
add    %eax,%ecx
call   1030 <ffts_elaborate_tree@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
imul   $0x3,-0xc(%rbp),%eax
mov    $0x4,%r8d
cltd
idiv   %r8d
mov    -0x18(%rbp),%edx
add    %eax,%ecx
call   1030 <ffts_elaborate_tree@plt>
movslq -0xc(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x10,%rcx
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffts_elaborate_tree>:
cmp    %edx,%esi
jle    11ee <ffts_elaborate_tree+0xde>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %esi,%ebx
lea    0x3(%rbx),%r13d
test   %esi,%esi
cmovns %esi,%r13d
lea    0x7(%rbx),%ebp
cmovns %esi,%ebp
sar    $0x2,%r13d
mov    %rdi,%r12
mov    %r13d,%esi
mov    %edx,0xc(%rsp)
call   1030 <ffts_elaborate_tree@plt>
sar    $0x3,%ebp
lea    (%r15,%r13,1),%r14d
mov    %r12,0x10(%rsp)
mov    %r12,%rdi
mov    %ebp,%esi
mov    0xc(%rsp),%edx
mov    %r14d,%ecx
call   1030 <ffts_elaborate_tree@plt>
add    %ebp,%r14d
mov    %r12,%rdi
mov    %ebp,%esi
mov    0xc(%rsp),%r12d
mov    %r12d,%edx
mov    %r14d,%ecx
call   1030 <ffts_elaborate_tree@plt>
mov    %ebx,%ecx
shr    $0x1f,%ecx
add    %ebx,%ecx
sar    %ecx
add    %r15d,%ecx
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
call   1030 <ffts_elaborate_tree@plt>
lea    (%rbx,%rbx,2),%eax
lea    (%rbx,%rbx,2),%ecx
add    $0x3,%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
add    %r15d,%ecx
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
call   1030 <ffts_elaborate_tree@plt>
movslq %ebx,%rax
mov    0x0(%rbp),%rcx
mov    %rax,(%rcx)
add    %r15d,%r15d
movslq %r15d,%rax
mov    %rax,0x8(%rcx)
add    $0x10,%rcx
mov    %rcx,0x0(%rbp)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @ffts_elaborate_tree(i64** %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, %2
br i1 %5, label %7, label %6
6: ; preds = %4, %7
ret void
7: ; preds = %4
%8 = sdiv i32 %1, 4
tail call void @ffts_elaborate_tree(i64** %0, i32 %8, i32 %2, i32 %3)
%9 = sdiv i32 %1, 8
%10 = add nsw i32 %8, %3
tail call void @ffts_elaborate_tree(i64** %0, i32 %9, i32 %2, i32 %10)
%11 = add nsw i32 %10, %9
tail call void @ffts_elaborate_tree(i64** %0, i32 %9, i32 %2, i32 %11)
%12 = sdiv i32 %1, 2
%13 = add nsw i32 %12, %3
tail call void @ffts_elaborate_tree(i64** %0, i32 %8, i32 %2, i32 %13)
%14 = mul nsw i32 %1, 3
%15 = sdiv i32 %14, 4
%16 = add nsw i32 %15, %3
tail call void @ffts_elaborate_tree(i64** %0, i32 %8, i32 %2, i32 %16)
%17 = sext i32 %1 to i64
%18 = load i64*, i64** %0
store i64 %17, i64* %18
%19 = shl nsw i32 %3, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %18, i64 1
store i64 %20, i64* %21
%22 = getelementptr inbounds i64, i64* %18, i64 2
store i64* %22, i64** %0
br label %6
}