#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 bit_rev(int, int);
void rev_small1(double *re, int bits) {
  int x, y, n = 1 << bits;
  double t;
  for (x = 0; x < n; x++)
    if ((y = bit_rev(x, bits)) > x)
      (t = re[y], re[y] = re[x], re[x] = t);
}


x86 assembly (clang, -O0):
<rev_small1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a7 <rev_small1+0x97>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <bit_rev@plt>
mov    %eax,-0x14(%rbp)
cmp    -0x10(%rbp),%eax
jle    1194 <rev_small1+0x84>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1199 <rev_small1+0x89>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1133 <rev_small1+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev_small1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1f,%esi
jne    1127 <rev_small1+0x17>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x1,%eax
mov    $0x1,%r15d
mov    %r14d,%ecx
shl    %cl,%r15d
cmp    $0x2,%r15d
cmovl  %eax,%r15d
xor    %ebp,%ebp
jmp    1159 <rev_small1+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     111c <rev_small1+0xc>
mov    %ebp,%edi
mov    %r14d,%esi
call   1030 <bit_rev@plt>
cltq
cmp    %rax,%rbp
jge    1150 <rev_small1+0x40>
movsd  (%rbx,%rax,8),%xmm0
movsd  (%rbx,%rbp,8),%xmm1
movsd  %xmm1,(%rbx,%rax,8)
movsd  %xmm0,(%rbx,%rbp,8)
jmp    1150 <rev_small1+0x40>

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

LLVM IR (-O2):
define void @rev_small1(double* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 31
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = shl nuw nsw i32 1, %1
%6 = call i32 @llvm.smax.i32(i32 %5, i32 1)
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %4, %19
%9 = phi i64 [ 0, %4 ], [ %20, %19 ]
%10 = trunc i64 %9 to i32
%11 = tail call i32 @bit_rev(i32 %10, i32 %1)
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %9, %12
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = getelementptr inbounds double, double* %0, i64 %12
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %0, i64 %9
%18 = load double, double* %17
store double %18, double* %15
store double %16, double* %17
br label %19
19: ; preds = %8, %14
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %22, label %8
22: ; preds = %19, %2
ret void
}