void dswap_3l(int n, double *x, int incx, double *y, int incy) {
  if (n <= 0)
    return;
  double temp;
  int jj;
  for (jj = 0; jj < n; jj++) {
    temp = x[0];
    x[0] = y[0];
    y[0] = temp;
    x += incx;
    y += incy;
  }
}


x86 assembly (clang, -O0):
<dswap_3l>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1125 <dswap_3l+0x25>
jmp    119a <dswap_3l+0x9a>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119a <dswap_3l+0x9a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    112c <dswap_3l+0x2c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dswap_3l>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    120c <dswap_3l+0x10c>
movslq %edx,%r9
movslq %r8d,%r11
lea    -0x1(%rdi),%eax
mov    %edi,%r14d
and    $0x3,%r14d
cmp    $0x3,%eax
jb     11d9 <dswap_3l+0xd9>
and    $0xfffffffc,%edi
mov    %r9,%r8
shl    $0x5,%r8
mov    %r11,%r10
shl    $0x5,%r10
lea    0x0(,%r9,8),%rdx
lea    0x0(,%r11,8),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rsi,%rbx
mov    %rcx,%rax
movsd  (%rsi),%xmm0
movsd  (%rcx),%xmm1
movsd  %xmm1,(%rsi)
movsd  %xmm0,(%rcx)
lea    (%rsi,%rdx,1),%rcx
movsd  (%rsi,%rdx,1),%xmm0
lea    (%rax,%rbp,1),%rsi
movsd  (%rax,%rbp,1),%xmm1
movsd  %xmm1,(%rbx,%rdx,1)
movsd  %xmm0,(%rax,%rbp,1)
lea    (%rcx,%rdx,1),%r15
movsd  (%rdx,%rcx,1),%xmm0
lea    (%rsi,%rbp,1),%r12
movsd  0x0(%rbp,%rsi,1),%xmm1
movsd  %xmm1,(%rdx,%rcx,1)
movsd  %xmm0,0x0(%rbp,%rsi,1)
lea    (%r15,%rdx,1),%rsi
movsd  (%rdx,%r15,1),%xmm0
lea    (%r12,%rbp,1),%rcx
movsd  0x0(%rbp,%r12,1),%xmm1
movsd  %xmm1,(%rdx,%r15,1)
movsd  %xmm0,0x0(%rbp,%r12,1)
add    %rdx,%rsi
add    %rbp,%rcx
add    $0xfffffffc,%edi
jne    1150 <dswap_3l+0x50>
add    %r8,%rbx
add    %r10,%rax
mov    %rbx,%rsi
mov    %rax,%rcx
test   %r14d,%r14d
je     120c <dswap_3l+0x10c>
shl    $0x3,%r9
shl    $0x3,%r11
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsi),%xmm0
movsd  (%rcx),%xmm1
movsd  %xmm1,(%rsi)
movsd  %xmm0,(%rcx)
add    %r9,%rsi
add    %r11,%rcx
add    $0xffffffff,%r14d
jne    11f0 <dswap_3l+0xf0>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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