#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*/ c_dswap(int, double *, int, double *, int);
int /*<<< orphan*/ printf(char *, int, double);
int main() {
  double x[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
  double y[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
  int N = 4;
  int strideX = 2;
  int strideY = -2;
  c_dswap(N, x, strideX, y, strideY);
  for (int i = 0; i < 8; i++) {
    printf("x[ %i ] = %lf\n", i, x[i]);
    printf("y[ %i ] = %lf\n", i, y[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movl   $0x4,-0x94(%rbp)
movl   $0x2,-0x98(%rbp)
movl   $0xfffffffe,-0x9c(%rbp)
ff ff ff
mov    -0x94(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0x98(%rbp),%edx
lea    -0x90(%rbp),%rcx
mov    -0x9c(%rbp),%r8d
call   1060 <c_dswap@plt>
movl   $0x0,-0xa0(%rbp)
cmpl   $0x8,-0xa0(%rbp)
jge    1227 <main+0xe7>
mov    -0xa0(%rbp),%esi
movslq -0xa0(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0xa0(%rbp),%esi
movslq -0xa0(%rbp),%rax
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    11c5 <main+0x85>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
movaps 0xeff(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x40(%rsp),%rsi
mov    %rsp,%rcx
mov    $0x4,%edi
mov    $0x2,%edx
mov    $0xfffffffe,%r8d
call   1040 <c_dswap@plt>
movsd  0x40(%rsp),%xmm0
lea    0xea6(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
lea    0xe9f(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
movsd  0x48(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movsd  0x50(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
movsd  0x58(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
movsd  0x60(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
movsd  0x68(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
movsd  0x28(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
movsd  0x70(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
movsd  0x78(%rsp),%xmm0
mov    %r14,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
movsd  0x38(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.x = [8 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00]
@.str = [15 x i8] c"x[ %i ] = %lf\0A\00"
@.str.1 = [15 x i8] c"y[ %i ] = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x double]
%3 = alloca [8 x double]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [8 x double]* %2 to i8*
%9 = bitcast [8 x double]* %3 to i8*
store i32 4, i32* %4
store i32 2, i32* %5
store i32 -2, i32* %6
%10 = load i32, i32* %4
%11 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
%12 = load i32, i32* %5
%13 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 0
%14 = load i32, i32* %6
%15 = call i32 @c_dswap(i32 %10, double* %11, i32 %12, double* %13, i32 %14)
store i32 0, i32* %7
br label %16
16: ; preds = %32, %0
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 %22
%24 = load double, double* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %20, double %24)
%26 = load i32, i32* %7
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 %28
%30 = load double, double* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %26, double %30)
br label %32
32: ; preds = %19
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %16
35: ; preds = %16
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@__const.main.x = [8 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00, double 8.000000e+00]
@.str = [15 x i8] c"x[ %i ] = %lf\0A\00"
@.str.1 = [15 x i8] c"y[ %i ] = %lf\0A\00"
define i32 @main() {
%1 = alloca [8 x double]
%2 = alloca [8 x double]
%3 = bitcast [8 x double]* %1 to i8*
%4 = bitcast [8 x double]* %2 to i8*
%5 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 0
%6 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 0
%7 = call i32 @c_dswap(i32 4, double* %5, i32 2, double* %6, i32 -2)
%8 = load double, double* %5
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0, double %8)
%10 = load double, double* %6
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 0, double %10)
%12 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 1
%13 = load double, double* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 1, double %13)
%15 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 1
%16 = load double, double* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 1, double %16)
%18 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 2
%19 = load double, double* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 2, double %19)
%21 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 2
%22 = load double, double* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 2, double %22)
%24 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 3
%25 = load double, double* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 3, double %25)
%27 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 3
%28 = load double, double* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 3, double %28)
%30 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 4
%31 = load double, double* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4, double %31)
%33 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 4
%34 = load double, double* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 4, double %34)
%36 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 5
%37 = load double, double* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5, double %37)
%39 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 5
%40 = load double, double* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 5, double %40)
%42 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 6
%43 = load double, double* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 6, double %43)
%45 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 6
%46 = load double, double* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 6, double %46)
%48 = getelementptr inbounds [8 x double], [8 x double]* %1, i64 0, i64 7
%49 = load double, double* %48
%50 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 7, double %49)
%51 = getelementptr inbounds [8 x double], [8 x double]* %2, i64 0, i64 7
%52 = load double, double* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 7, double %52)
ret i32 0
}