#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*/ Rprintf(char *, int, int);
void swap(int l, int r, double *window, int *outlist, int *nrlist,
          int print_level) {
  int nl, nr;
  double tmp;
  if (print_level >= 3)
    Rprintf("SW(%d,%d) ", l, r);
  tmp = window[l];
  window[l] = window[r];
  window[r] = tmp;
  nl = nrlist[l];
  nrlist[l] = (nr = nrlist[r]);
  nrlist[r] = nl;
  outlist[nl] = r;
  outlist[nr] = l;
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jl     114a <swap+0x3a>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xebb(%rip),%rdi
call   1030 <Rprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    %edx,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %esi,%r15d
mov    %edi,%r12d
cmp    $0x3,%r9d
jl     113f <swap+0x2f>
lea    0xecc(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <Rprintf@plt>
movslq %r12d,%rax
movsd  0x0(%rbp,%rax,8),%xmm0
movslq %r15d,%rcx
movsd  0x0(%rbp,%rcx,8),%xmm1
movsd  %xmm1,0x0(%rbp,%rax,8)
movsd  %xmm0,0x0(%rbp,%rcx,8)
movslq (%rbx,%rax,4),%rdx
movslq (%rbx,%rcx,4),%rsi
mov    %esi,(%rbx,%rax,4)
mov    %edx,(%rbx,%rcx,4)
mov    %r15d,(%r14,%rdx,4)
mov    %r12d,(%r14,%rsi,4)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"SW(%d,%d) \00"
define void @swap(i32 %0, i32 %1, double* nocapture %2, i32* nocapture writeonly %3, i32* nocapture %4, i32 %5) {
%7 = icmp sgt i32 %5, 2
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @Rprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %10
10: ; preds = %8, %6
%11 = sext i32 %0 to i64
%12 = getelementptr inbounds double, double* %2, i64 %11
%13 = load double, double* %12
%14 = sext i32 %1 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = load double, double* %15
store double %16, double* %12
store double %13, double* %15
%17 = getelementptr inbounds i32, i32* %4, i64 %11
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %4, i64 %14
%20 = load i32, i32* %19
store i32 %20, i32* %17
store i32 %18, i32* %19
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds i32, i32* %3, i64 %21
store i32 %1, i32* %22
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds i32, i32* %3, i64 %23
store i32 %0, i32* %24
ret void
}