void init(double *a1, double *a2, int N) {
  double s = -1;
  int i;
  for (i = 0; i < N; i++) {
    a1[i] = s;
    a2[i] = i;
    s = -s;
  }
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1182 <init+0x82>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1123 <init+0x23>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
test   %edx,%edx
jle    1174 <init+0x74>
mov    %edx,%r8d
movabs $0xbff0000000000000,%r9
cmp    $0x1,%edx
jne    111a <init+0x1a>
xor    %edx,%edx
jmp    115e <init+0x5e>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
xor    %edx,%edx
movabs $0x3ff0000000000000,%r10
nopl   0x0(%rax)
mov    %r9,(%rdi,%rdx,8)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,(%rsi,%rdx,8)
lea    0x1(%rdx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r10,0x8(%rdi,%rdx,8)
movsd  %xmm0,0x8(%rsi,%rdx,8)
add    $0x2,%rdx
cmp    %rcx,%rdx
jne    1130 <init+0x30>
test   $0x1,%r8b
je     1174 <init+0x74>
mov    %r9,(%rdi,%rdx,8)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,(%rsi,%rdx,8)
ret

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

LLVM IR (-O2):
define void @init(double* nocapture writeonly %0, double* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %34
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %2, 1
br i1 %8, label %26, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %23, %11 ]
%13 = phi i64 [ 0, %9 ], [ %24, %11 ]
%14 = getelementptr inbounds double, double* %0, i64 %12
store double -1.000000e+00, double* %14
%15 = trunc i64 %12 to i32
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds double, double* %1, i64 %12
store double %16, double* %17
%18 = or i64 %12, 1
%19 = getelementptr inbounds double, double* %0, i64 %18
store double 1.000000e+00, double* %19
%20 = trunc i64 %18 to i32
%21 = sitofp i32 %20 to double
%22 = getelementptr inbounds double, double* %1, i64 %18
store double %21, double* %22
%23 = add nuw nsw i64 %12, 2
%24 = add i64 %13, 2
%25 = icmp eq i64 %24, %10
br i1 %25, label %26, label %11
26: ; preds = %11, %5
%27 = phi i64 [ 0, %5 ], [ %23, %11 ]
%28 = icmp eq i64 %7, 0
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = getelementptr inbounds double, double* %0, i64 %27
store double -1.000000e+00, double* %30
%31 = trunc i64 %27 to i32
%32 = sitofp i32 %31 to double
%33 = getelementptr inbounds double, double* %1, i64 %27
store double %32, double* %33
br label %34
34: ; preds = %29, %26, %3
ret void
}