#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*/ bitrev(double *, int);
void unscramble(double *f, int len) {
  double temp;
  int i, ii1, ii2, halflen, qtrlen;
  halflen = len >> 1;
  qtrlen = halflen >> 1;
  ii1 = len - 1;
  ii2 = halflen;
  for (i = 0; i <= qtrlen - 1; i++) {
    temp = f[ii1];
    f[ii1] = f[ii2];
    f[ii2] = temp;
    ii1--;
    ii2++;
  }
  bitrev(&f[0], halflen);
  bitrev(&f[halflen], halflen);
  bitrev(f, len);
}


x86 assembly (clang, -O0):
<unscramble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11b6 <unscramble+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <unscramble+0x37>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1030 <bitrev@plt>
mov    -0x8(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%esi
call   1030 <bitrev@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <bitrev@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unscramble>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %esi,%ebp
sar    %ebp
cmp    $0x3,%esi
jle    1145 <unscramble+0x35>
mov    %r14d,%ecx
shr    $0x2,%ecx
mov    %r14d,%eax
movslq %ebp,%r15
cmp    $0x1,%ecx
jne    114d <unscramble+0x3d>
mov    %r15,%rcx
test   $0x4,%r14b
jne    11b1 <unscramble+0xa1>
jmp    11c7 <unscramble+0xb7>
movslq %ebp,%r15
jmp    11c7 <unscramble+0xb7>
lea    (%rbx,%r15,8),%rcx
add    $0x8,%rcx
lea    (%rbx,%rax,8),%rdx
add    $0xfffffffffffffff8,%rdx
mov    %rax,%rsi
shr    $0x2,%rsi
and    $0xfffffffe,%esi
xor    %edi,%edi
nopl   0x0(%rax)
movsd  (%rdx),%xmm0
movsd  -0x8(%rcx,%rdi,8),%xmm1
movsd  %xmm1,(%rdx)
movsd  %xmm0,-0x8(%rcx,%rdi,8)
movsd  -0x8(%rdx),%xmm0
movsd  (%rcx,%rdi,8),%xmm1
movsd  %xmm1,-0x8(%rdx)
movsd  %xmm0,(%rcx,%rdi,8)
add    $0x2,%rdi
add    $0xfffffffffffffff0,%rdx
cmp    %edi,%esi
jne    1170 <unscramble+0x60>
lea    (%r15,%rdi,1),%rcx
sub    %rdi,%rax
test   $0x4,%r14b
je     11c7 <unscramble+0xb7>
movsd  -0x8(%rbx,%rax,8),%xmm0
movsd  (%rbx,%rcx,8),%xmm1
movsd  %xmm1,-0x8(%rbx,%rax,8)
movsd  %xmm0,(%rbx,%rcx,8)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <bitrev@plt>
lea    (%rbx,%r15,8),%rdi
mov    %ebp,%esi
call   1030 <bitrev@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <bitrev@plt>

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

LLVM IR (-O2):
define void @unscramble(double* %0, i32 %1) {
%3 = ashr i32 %1, 1
%4 = icmp sgt i32 %1, 3
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = sext i32 %3 to i64
br label %43
7: ; preds = %2
%8 = lshr i32 %1, 2
%9 = zext i32 %1 to i64
%10 = sext i32 %3 to i64
%11 = icmp eq i32 %8, 1
br i1 %11, label %32, label %12
12: ; preds = %7
%13 = and i32 %8, 1073741822
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ %10, %12 ], [ %29, %14 ]
%16 = phi i64 [ %9, %12 ], [ %24, %14 ]
%17 = phi i32 [ 0, %12 ], [ %30, %14 ]
%18 = add nsw i64 %16, -1
%19 = getelementptr inbounds double, double* %0, i64 %18
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %0, i64 %15
%22 = load double, double* %21
store double %22, double* %19
store double %20, double* %21
%23 = add nsw i64 %15, 1
%24 = add nsw i64 %16, -2
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %0, i64 %23
%28 = load double, double* %27
store double %28, double* %25
store double %26, double* %27
%29 = add nsw i64 %15, 2
%30 = add i32 %17, 2
%31 = icmp eq i32 %30, %13
br i1 %31, label %32, label %14
32: ; preds = %14, %7
%33 = phi i64 [ %10, %7 ], [ %29, %14 ]
%34 = phi i64 [ %9, %7 ], [ %24, %14 ]
%35 = and i32 %1, 4
%36 = icmp eq i32 %35, 0
br i1 %36, label %43, label %37
37: ; preds = %32
%38 = add nsw i64 %34, -1
%39 = getelementptr inbounds double, double* %0, i64 %38
%40 = load double, double* %39
%41 = getelementptr inbounds double, double* %0, i64 %33
%42 = load double, double* %41
store double %42, double* %39
store double %40, double* %41
br label %43
43: ; preds = %37, %32, %5
%44 = phi i64 [ %6, %5 ], [ %10, %32 ], [ %10, %37 ]
%45 = tail call i32 @bitrev(double* %0, i32 %3)
%46 = getelementptr inbounds double, double* %0, i64 %44
%47 = tail call i32 @bitrev(double* %46, i32 %3)
%48 = tail call i32 @bitrev(double* %0, i32 %1)
ret void
}