#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 */
typedef size_t uint64_t;
typedef size_t uint32_t;

/* Variables and functions */
void shuffle_bigger_o(uint32_t n, double *b, uint32_t N, double *a,
                      uint32_t order[]) {
  uint64_t i;
  for (i = 0; i < n; i++) {
    a[order[i]] = b[i];
  }
}


x86 assembly (clang, -O0):
<shuffle_bigger_o>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1161 <shuffle_bigger_o+0x61>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1120 <shuffle_bigger_o+0x20>
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle_bigger_o>:
test   %rdi,%rdi
je     11a7 <shuffle_bigger_o+0xa7>
lea    -0x1(%rdi),%rdx
mov    %edi,%r9d
and    $0x3,%r9d
cmp    $0x3,%rdx
jae    111e <shuffle_bigger_o+0x1e>
xor    %edx,%edx
jmp    1177 <shuffle_bigger_o+0x77>
and    $0xfffffffffffffffc,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rsi,%rdx,8),%xmm0
mov    (%r8,%rdx,8),%rax
movsd  %xmm0,(%rcx,%rax,8)
movsd  0x8(%rsi,%rdx,8),%xmm0
mov    0x8(%r8,%rdx,8),%rax
movsd  %xmm0,(%rcx,%rax,8)
movsd  0x10(%rsi,%rdx,8),%xmm0
mov    0x10(%r8,%rdx,8),%rax
movsd  %xmm0,(%rcx,%rax,8)
movsd  0x18(%rsi,%rdx,8),%xmm0
mov    0x18(%r8,%rdx,8),%rax
movsd  %xmm0,(%rcx,%rax,8)
add    $0x4,%rdx
cmp    %rdx,%rdi
jne    1130 <shuffle_bigger_o+0x30>
test   %r9,%r9
je     11a7 <shuffle_bigger_o+0xa7>
lea    (%r8,%rdx,8),%rdi
lea    (%rsi,%rdx,8),%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdx,%rsi,8),%xmm0
mov    (%rdi,%rsi,8),%rax
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%rsi
cmp    %rsi,%r9
jne    1190 <shuffle_bigger_o+0x90>
ret

LLVM IR (-O0):
define void @shuffle_bigger_o(i64 %0, double* %1, i64 %2, double* %3, i64* %4) {
%6 = alloca i64
%7 = alloca double*
%8 = alloca i64
%9 = alloca double*
%10 = alloca i64*
%11 = alloca i64
store i64 %0, i64* %6
store double* %1, double** %7
store i64 %2, i64* %8
store double* %3, double** %9
store i64* %4, i64** %10
store i64 0, i64* %11
br label %12
12: ; preds = %27, %5
%13 = load i64, i64* %11
%14 = load i64, i64* %6
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load double*, double** %7
%18 = load i64, i64* %11
%19 = getelementptr inbounds double, double* %17, i64 %18
%20 = load double, double* %19
%21 = load double*, double** %9
%22 = load i64*, i64** %10
%23 = load i64, i64* %11
%24 = getelementptr inbounds i64, i64* %22, i64 %23
%25 = load i64, i64* %24
%26 = getelementptr inbounds double, double* %21, i64 %25
store double %20, double* %26
br label %27
27: ; preds = %16
%28 = load i64, i64* %11
%29 = add i64 %28, 1
store i64 %29, i64* %11
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @shuffle_bigger_o(i64 %0, double* nocapture %1, i64 %2, double* nocapture writeonly %3, i64* nocapture %4) {
%6 = icmp eq i64 %0, 0
br i1 %6, label %56, label %7
7: ; preds = %5
%8 = add i64 %0, -1
%9 = and i64 %0, 3
%10 = icmp ult i64 %8, 3
br i1 %10, label %42, label %11
11: ; preds = %7
%12 = and i64 %0, -4
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %39, %13 ]
%15 = phi i64 [ 0, %11 ], [ %40, %13 ]
%16 = getelementptr inbounds double, double* %1, i64 %14
%17 = load double, double* %16
%18 = getelementptr inbounds i64, i64* %4, i64 %14
%19 = load i64, i64* %18
%20 = getelementptr inbounds double, double* %3, i64 %19
store double %17, double* %20
%21 = or i64 %14, 1
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = load double, double* %22
%24 = getelementptr inbounds i64, i64* %4, i64 %21
%25 = load i64, i64* %24
%26 = getelementptr inbounds double, double* %3, i64 %25
store double %23, double* %26
%27 = or i64 %14, 2
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = load double, double* %28
%30 = getelementptr inbounds i64, i64* %4, i64 %27
%31 = load i64, i64* %30
%32 = getelementptr inbounds double, double* %3, i64 %31
store double %29, double* %32
%33 = or i64 %14, 3
%34 = getelementptr inbounds double, double* %1, i64 %33
%35 = load double, double* %34
%36 = getelementptr inbounds i64, i64* %4, i64 %33
%37 = load i64, i64* %36
%38 = getelementptr inbounds double, double* %3, i64 %37
store double %35, double* %38
%39 = add nuw i64 %14, 4
%40 = add i64 %15, 4
%41 = icmp eq i64 %40, %12
br i1 %41, label %42, label %13
42: ; preds = %13, %7
%43 = phi i64 [ 0, %7 ], [ %39, %13 ]
%44 = icmp eq i64 %9, 0
br i1 %44, label %56, label %45
45: ; preds = %42, %45
%46 = phi i64 [ %53, %45 ], [ %43, %42 ]
%47 = phi i64 [ %54, %45 ], [ 0, %42 ]
%48 = getelementptr inbounds double, double* %1, i64 %46
%49 = load double, double* %48
%50 = getelementptr inbounds i64, i64* %4, i64 %46
%51 = load i64, i64* %50
%52 = getelementptr inbounds double, double* %3, i64 %51
store double %49, double* %52
%53 = add nuw i64 %46, 1
%54 = add i64 %47, 1
%55 = icmp eq i64 %54, %9
br i1 %55, label %56, label %45
56: ; preds = %42, %45, %5
ret void
}