#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 */
void vecadd(double *x, const double *y, double a, size_t n) {
  int k;
  for (k = 0; k < n; k++) {
    x[k] += a * y[k];
  }
}


x86 assembly (clang, -O0):
<vecadd>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1164 <vecadd+0x64>
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111c <vecadd+0x1c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vecadd>:
test   %rdx,%rdx
je     126f <vecadd+0x16f>
cmp    $0x4,%rdx
jb     1121 <vecadd+0x21>
lea    (%rsi,%rdx,8),%rax
cmp    %rdi,%rax
jbe    1187 <vecadd+0x87>
lea    (%rdi,%rdx,8),%rax
cmp    %rsi,%rax
jbe    1187 <vecadd+0x87>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
test   $0x1,%dl
je     1145 <vecadd+0x45>
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi,%rax,8),%xmm1
movsd  %xmm1,(%rdi,%rax,8)
or     $0x1,%rax
add    %rdx,%rcx
je     126f <vecadd+0x16f>
xchg   %ax,%ax
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi,%rax,8),%xmm1
movsd  %xmm1,(%rdi,%rax,8)
movsd  0x8(%rsi,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rdi,%rax,8),%xmm1
movsd  %xmm1,0x8(%rdi,%rax,8)
add    $0x2,%rax
cmp    %rax,%rdx
jne    1150 <vecadd+0x50>
jmp    126f <vecadd+0x16f>
mov    %rdx,%rax
and    $0xfffffffffffffffc,%rax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rax),%rcx
mov    %rcx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rcx,%rcx
je     1270 <vecadd+0x170>
mov    %r8,%r9
and    $0xfffffffffffffffe,%r9
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movupd (%rsi,%rcx,8),%xmm2
movupd 0x10(%rsi,%rcx,8),%xmm3
mulpd  %xmm1,%xmm2
movupd (%rdi,%rcx,8),%xmm4
addpd  %xmm2,%xmm4
movupd 0x10(%rdi,%rcx,8),%xmm2
movupd 0x20(%rdi,%rcx,8),%xmm5
movupd 0x30(%rdi,%rcx,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,(%rdi,%rcx,8)
movupd %xmm3,0x10(%rdi,%rcx,8)
movupd 0x20(%rsi,%rcx,8),%xmm2
movupd 0x30(%rsi,%rcx,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,0x20(%rdi,%rcx,8)
movupd %xmm3,0x30(%rdi,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%r9
jne    11c0 <vecadd+0xc0>
test   $0x1,%r8b
je     1266 <vecadd+0x166>
movupd (%rsi,%rcx,8),%xmm2
movupd 0x10(%rsi,%rcx,8),%xmm3
movupd (%rdi,%rcx,8),%xmm4
movupd 0x10(%rdi,%rcx,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rdi,%rcx,8)
movupd %xmm3,0x10(%rdi,%rcx,8)
cmp    %rdx,%rax
jne    1123 <vecadd+0x23>
ret
xor    %ecx,%ecx
test   $0x1,%r8b
jne    1235 <vecadd+0x135>
jmp    1266 <vecadd+0x166>

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

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