#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*/ fdct_bitrev(double *, int);
void fdct_scramble(double *data) {
  double tmp;
  int i, ii1, ii2;
  fdct_bitrev(data, 16384);
  fdct_bitrev(&data[0], 8192);
  fdct_bitrev(&data[8192], 8192);
  ii1 = 16384 - 1;
  ii2 = 8192;
  for (i = 0; i <= 4096 - 1; i++, ii1--, ii2++) {
    tmp = data[ii1];
    data[ii1] = data[ii2];
    data[ii2] = tmp;
  }
}


x86 assembly (clang, -O0):
<fdct_scramble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4000,%esi
call   1030 <fdct_bitrev@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2000,%esi
call   1030 <fdct_bitrev@plt>
mov    -0x8(%rbp),%rdi
add    $0x10000,%rdi
mov    $0x2000,%esi
call   1030 <fdct_bitrev@plt>
movl   $0x3fff,-0x18(%rbp)
movl   $0x2000,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xfff,-0x14(%rbp)
jg     11cd <fdct_scramble+0xbd>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <fdct_scramble+0x52>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdct_scramble>:
push   %rbx
mov    %rdi,%rbx
mov    $0x4000,%esi
call   1030 <fdct_bitrev@plt>
mov    %rbx,%rdi
mov    $0x2000,%esi
call   1030 <fdct_bitrev@plt>
lea    0x10000(%rbx),%rdi
mov    $0x2000,%esi
call   1030 <fdct_bitrev@plt>
lea    0x1fff8(%rbx),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rax),%xmm0
movsd  0x10000(%rbx,%rcx,8),%xmm1
movsd  %xmm1,(%rax)
movsd  %xmm0,0x10000(%rbx,%rcx,8)
movsd  -0x8(%rax),%xmm0
movsd  0x10008(%rbx,%rcx,8),%xmm1
movsd  %xmm1,-0x8(%rax)
movsd  %xmm0,0x10008(%rbx,%rcx,8)
add    $0xfffffffffffffff0,%rax
add    $0x2,%rcx
cmp    $0x1000,%rcx
jne    1150 <fdct_scramble+0x40>
pop    %rbx
ret

LLVM IR (-O0):
define void @fdct_scramble(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %2
%7 = load double*, double** %2
%8 = call i32 @fdct_bitrev(double* %7, i32 16384)
%9 = load double*, double** %2
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = call i32 @fdct_bitrev(double* %10, i32 8192)
%12 = load double*, double** %2
%13 = getelementptr inbounds double, double* %12, i64 8192
%14 = call i32 @fdct_bitrev(double* %13, i32 8192)
store i32 16383, i32* %5
store i32 8192, i32* %6
store i32 0, i32* %4
br label %15
15: ; preds = %38, %1
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 4095
br i1 %17, label %18, label %45
18: ; preds = %15
%19 = load double*, double** %2
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
store double %23, double* %3
%24 = load double*, double** %2
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %2
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
%33 = load double, double* %3
%34 = load double*, double** %2
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %18
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
%41 = load i32, i32* %5
%42 = add nsw i32 %41, -1
store i32 %42, i32* %5
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %15
45: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @fdct_scramble(double* %0) {
%2 = tail call i32 @fdct_bitrev(double* %0, i32 16384)
%3 = tail call i32 @fdct_bitrev(double* %0, i32 8192)
%4 = getelementptr inbounds double, double* %0, i64 8192
%5 = tail call i32 @fdct_bitrev(double* %4, i32 8192)
br label %6
6: ; preds = %6, %1
%7 = phi i64 [ 16383, %1 ], [ %19, %6 ]
%8 = phi i64 [ 8192, %1 ], [ %20, %6 ]
%9 = getelementptr inbounds double, double* %0, i64 %7
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %0, i64 %8
%12 = load double, double* %11
store double %12, double* %9
store double %10, double* %11
%13 = add nsw i64 %7, -1
%14 = or i64 %8, 1
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %0, i64 %14
%18 = load double, double* %17
store double %18, double* %15
store double %16, double* %17
%19 = add nsw i64 %7, -2
%20 = add nuw nsw i64 %8, 2
%21 = icmp eq i64 %20, 12288
br i1 %21, label %22, label %6
22: ; preds = %6
ret void
}