void array_swap1_d(register double *arr1, register double *arr2,
                   const unsigned int NIn, const unsigned int stepIn) {
  register unsigned int i, N, step;
  register double tmp;
  for (i = 0, N = NIn, step = stepIn; N--; i += step) {
    tmp = arr1[i];
    arr1[i] = arr2[i];
    arr2[i] = tmp;
  }
}


x86 assembly (clang, -O0):
<array_swap1_d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
je     1181 <array_swap1_d+0x81>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1125 <array_swap1_d+0x25>
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_swap1_d>:
push   %rbp
push   %r14
push   %rbx
test   %edx,%edx
je     129e <array_swap1_d+0x19e>
xor    %r11d,%r11d
cmp    $0x4,%edx
jb     1136 <array_swap1_d+0x36>
cmp    $0x1,%ecx
jne    1136 <array_swap1_d+0x36>
lea    -0x1(%rdx),%eax
lea    (%rsi,%rax,8),%rbx
add    $0x8,%rbx
cmp    %rdi,%rbx
jbe    114f <array_swap1_d+0x4f>
lea    (%rdi,%rax,8),%rax
add    $0x8,%rax
cmp    %rsi,%rax
jbe    114f <array_swap1_d+0x4f>
test   $0x1,%dl
jne    1235 <array_swap1_d+0x135>
mov    %edx,%eax
cmp    $0x1,%edx
jne    1260 <array_swap1_d+0x160>
jmp    129e <array_swap1_d+0x19e>
mov    %edx,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%eax
mov    %eax,%r8d
shr    $0x2,%r8d
add    $0x1,%r8d
test   %eax,%eax
je     12a3 <array_swap1_d+0x1a3>
mov    %r8d,%r10d
and    $0xfffffffe,%r10d
lea    0x0(,%rcx,4),%r14d
lea    0x0(,%rcx,8),%ebp
xor    %eax,%eax
xor    %r9d,%r9d
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebx
movups (%rdi,%rbx,8),%xmm0
movups 0x10(%rdi,%rbx,8),%xmm1
movups (%rsi,%rbx,8),%xmm2
movups 0x10(%rsi,%rbx,8),%xmm3
movups %xmm2,(%rdi,%rbx,8)
movups %xmm3,0x10(%rdi,%rbx,8)
movups %xmm0,(%rsi,%rbx,8)
movups %xmm1,0x10(%rsi,%rbx,8)
lea    (%r14,%rax,1),%ebx
movups (%rdi,%rbx,8),%xmm0
movups 0x10(%rdi,%rbx,8),%xmm1
movups (%rsi,%rbx,8),%xmm2
movups 0x10(%rsi,%rbx,8),%xmm3
movups %xmm2,(%rdi,%rbx,8)
movups %xmm3,0x10(%rdi,%rbx,8)
movups %xmm0,(%rsi,%rbx,8)
movups %xmm1,0x10(%rsi,%rbx,8)
add    $0x8,%r9d
add    %ebp,%eax
add    $0xfffffffe,%r10d
jne    1190 <array_swap1_d+0x90>
test   $0x1,%r8b
je     1220 <array_swap1_d+0x120>
imul   %ecx,%r9d
movups (%rdi,%r9,8),%xmm0
movups 0x10(%rdi,%r9,8),%xmm1
movups (%rsi,%r9,8),%xmm2
movups 0x10(%rsi,%r9,8),%xmm3
movups %xmm2,(%rdi,%r9,8)
movups %xmm3,0x10(%rdi,%r9,8)
movups %xmm0,(%rsi,%r9,8)
movups %xmm1,0x10(%rsi,%r9,8)
cmp    %edx,%r11d
je     129e <array_swap1_d+0x19e>
imul   %ecx,%r11d
and    $0x3,%edx
test   $0x1,%dl
je     113f <array_swap1_d+0x3f>
lea    -0x1(%rdx),%eax
mov    %r11d,%ebp
movsd  (%rdi,%rbp,8),%xmm0
movsd  (%rsi,%rbp,8),%xmm1
movsd  %xmm1,(%rdi,%rbp,8)
movsd  %xmm0,(%rsi,%rbp,8)
add    %ecx,%r11d
cmp    $0x1,%edx
je     129e <array_swap1_d+0x19e>
nopw   0x0(%rax,%rax,1)
mov    %r11d,%edx
movsd  (%rdi,%rdx,8),%xmm0
movsd  (%rsi,%rdx,8),%xmm1
movsd  %xmm1,(%rdi,%rdx,8)
movsd  %xmm0,(%rsi,%rdx,8)
add    %ecx,%r11d
movsd  (%rdi,%r11,8),%xmm0
movsd  (%rsi,%r11,8),%xmm1
movsd  %xmm1,(%rdi,%r11,8)
movsd  %xmm0,(%rsi,%r11,8)
lea    (%r11,%rcx,1),%edx
mov    %edx,%r11d
add    $0xfffffffe,%eax
jne    1260 <array_swap1_d+0x160>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %r9d,%r9d
test   $0x1,%r8b
jne    11f0 <array_swap1_d+0xf0>
jmp    1220 <array_swap1_d+0x120>

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

LLVM IR (-O2):
define void @array_swap1_d(double* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %131, label %6
6: ; preds = %4
%7 = icmp ugt i32 %2, 3
%8 = icmp eq i32 %3, 1
%9 = and i1 %7, %8
br i1 %9, label %10, label %97
10: ; preds = %6
%11 = add i32 %2, -1
%12 = zext i32 %11 to i64
%13 = add nuw nsw i64 %12, 1
%14 = getelementptr double, double* %0, i64 %13
%15 = getelementptr double, double* %1, i64 %13
%16 = icmp ugt double* %15, %0
%17 = icmp ugt double* %14, %1
%18 = and i1 %16, %17
br i1 %18, label %97, label %19
19: ; preds = %10
%20 = and i32 %2, -4
%21 = mul i32 %20, %3
%22 = and i32 %2, 3
%23 = add i32 %20, -4
%24 = lshr exact i32 %23, 2
%25 = add nuw nsw i32 %24, 1
%26 = and i32 %25, 1
%27 = icmp eq i32 %23, 0
br i1 %27, label %73, label %28
28: ; preds = %19
%29 = and i32 %25, 2147483646
br label %30
30: ; preds = %30, %28
%31 = phi i32 [ 0, %28 ], [ %70, %30 ]
%32 = phi i32 [ 0, %28 ], [ %71, %30 ]
%33 = mul i32 %31, %3
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds double, double* %0, i64 %34
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %35, i64 2
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %1, i64 %34
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %41, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = bitcast double* %35 to <2 x double>*
store <2 x double> %43, <2 x double>* %47
%48 = bitcast double* %38 to <2 x double>*
store <2 x double> %46, <2 x double>* %48
%49 = bitcast double* %41 to <2 x double>*
store <2 x double> %37, <2 x double>* %49
%50 = bitcast double* %44 to <2 x double>*
store <2 x double> %40, <2 x double>* %50
%51 = or i32 %31, 4
%52 = mul i32 %51, %3
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds double, double* %0, i64 %53
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = getelementptr inbounds double, double* %54, i64 2
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %1, i64 %53
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %60, i64 2
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = bitcast double* %54 to <2 x double>*
store <2 x double> %62, <2 x double>* %66
%67 = bitcast double* %57 to <2 x double>*
store <2 x double> %65, <2 x double>* %67
%68 = bitcast double* %60 to <2 x double>*
store <2 x double> %56, <2 x double>* %68
%69 = bitcast double* %63 to <2 x double>*
store <2 x double> %59, <2 x double>* %69
%70 = add nuw i32 %31, 8
%71 = add i32 %32, 2
%72 = icmp eq i32 %71, %29
br i1 %72, label %73, label %30
73: ; preds = %30, %19
%74 = phi i32 [ 0, %19 ], [ %70, %30 ]
%75 = icmp eq i32 %26, 0
br i1 %75, label %95, label %76
76: ; preds = %73
%77 = mul i32 %74, %3
%78 = zext i32 %77 to i64
%79 = getelementptr inbounds double, double* %0, i64 %78
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %79, i64 2
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %1, i64 %78
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %85, i64 2
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = bitcast double* %79 to <2 x double>*
store <2 x double> %87, <2 x double>* %91
%92 = bitcast double* %82 to <2 x double>*
store <2 x double> %90, <2 x double>* %92
%93 = bitcast double* %85 to <2 x double>*
store <2 x double> %81, <2 x double>* %93
%94 = bitcast double* %88 to <2 x double>*
store <2 x double> %84, <2 x double>* %94
br label %95
95: ; preds = %73, %76
%96 = icmp eq i32 %20, %2
br i1 %96, label %131, label %97
97: ; preds = %10, %6, %95
%98 = phi i32 [ 0, %10 ], [ 0, %6 ], [ %21, %95 ]
%99 = phi i32 [ %2, %10 ], [ %2, %6 ], [ %22, %95 ]
%100 = and i32 %99, 1
%101 = icmp eq i32 %100, 0
br i1 %101, label %110, label %102
102: ; preds = %97
%103 = add i32 %99, -1
%104 = zext i32 %98 to i64
%105 = getelementptr inbounds double, double* %0, i64 %104
%106 = load double, double* %105
%107 = getelementptr inbounds double, double* %1, i64 %104
%108 = load double, double* %107
store double %108, double* %105
store double %106, double* %107
%109 = add i32 %98, %3
br label %110
110: ; preds = %102, %97
%111 = phi i32 [ %98, %97 ], [ %109, %102 ]
%112 = phi i32 [ %99, %97 ], [ %103, %102 ]
%113 = icmp eq i32 %99, 1
br i1 %113, label %131, label %114
114: ; preds = %110, %114
%115 = phi i32 [ %129, %114 ], [ %111, %110 ]
%116 = phi i32 [ %123, %114 ], [ %112, %110 ]
%117 = zext i32 %115 to i64
%118 = getelementptr inbounds double, double* %0, i64 %117
%119 = load double, double* %118
%120 = getelementptr inbounds double, double* %1, i64 %117
%121 = load double, double* %120
store double %121, double* %118
store double %119, double* %120
%122 = add i32 %115, %3
%123 = add i32 %116, -2
%124 = zext i32 %122 to i64
%125 = getelementptr inbounds double, double* %0, i64 %124
%126 = load double, double* %125
%127 = getelementptr inbounds double, double* %1, i64 %124
%128 = load double, double* %127
store double %128, double* %125
store double %126, double* %127
%129 = add i32 %122, %3
%130 = icmp eq i32 %123, 0
br i1 %130, label %131, label %114
131: ; preds = %110, %114, %95, %4
ret void
}