#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 */
typedef double *__m128d;

/* Variables and functions */
double A(int, int);
double *_mm_add_pd(double *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_div_pd(double *, double *);
double *_mm_set_pd(double, double);
double *_mm_setzero_pd();
void mult_Atv(double *v, double *out, const int n) {
  int i;
#pragma omp parallel for
  for (i = 0; i < n; i++) {
    __m128d sum = _mm_setzero_pd();
    int j;
    for (j = 0; j < n; j += 2) {
      __m128d b = _mm_set_pd(v[j], v[j + 1]);
      __m128d a = _mm_set_pd(A(j, i), A(j + 1, i));
      sum = _mm_add_pd(sum, _mm_div_pd(b, a));
    }
    out[i] = sum[0] + sum[1];
  }
}


x86 assembly (clang, -O0):
<mult_Atv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1249 <mult_Atv+0xf9>
mov    $0x0,%al
call   1070 <_mm_setzero_pd@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121d <mult_Atv+0xcd>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <_mm_set_pd@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <A@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
call   1050 <A@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
call   1030 <_mm_set_pd@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <_mm_div_pd@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1040 <_mm_add_pd@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    1188 <mult_Atv+0x38>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116a <mult_Atv+0x1a>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_Atv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
test   %edx,%edx
jle    1211 <mult_Atv+0xc1>
mov    %edx,%r15d
mov    %rdi,%r12
mov    %edx,%eax
mov    %rax,(%rsp)
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <_mm_setzero_pd@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  (%r12,%rbp,8),%xmm0
movsd  0x8(%r12,%rbp,8),%xmm1
call   1030 <_mm_set_pd@plt>
mov    %rax,%r14
mov    %ebp,%edi
mov    %r13d,%esi
call   1050 <A@plt>
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbp),%edi
mov    %r13d,%esi
call   1050 <A@plt>
movaps %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <_mm_set_pd@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <_mm_div_pd@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <_mm_add_pd@plt>
mov    %rax,%rbx
add    $0x2,%rbp
cmp    %r15d,%ebp
jl     1190 <mult_Atv+0x40>
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
add    $0x1,%r13
cmp    (%rsp),%r13
jne    1180 <mult_Atv+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mult_Atv(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %63, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %66
16: ; preds = %12
%17 = call double* (...) @_mm_setzero_pd()
store double* %17, double** %8
store i32 0, i32* %9
br label %18
18: ; preds = %48, %16
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %51
22: ; preds = %18
%23 = load double*, double** %4
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
%34 = call double* @_mm_set_pd(double %27, double %33)
store double* %34, double** %10
%35 = load i32, i32* %9
%36 = load i32, i32* %7
%37 = call double @A(i32 %35, i32 %36)
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
%40 = load i32, i32* %7
%41 = call double @A(i32 %39, i32 %40)
%42 = call double* @_mm_set_pd(double %37, double %41)
store double* %42, double** %11
%43 = load double*, double** %8
%44 = load double*, double** %10
%45 = load double*, double** %11
%46 = call i32 @_mm_div_pd(double* %44, double* %45)
%47 = call double* @_mm_add_pd(double* %43, i32 %46)
store double* %47, double** %8
br label %48
48: ; preds = %22
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 2
store i32 %50, i32* %9
br label %18
51: ; preds = %18
%52 = load double*, double** %8
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double*, double** %8
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fadd double %54, %57
%59 = load double*, double** %5
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double %58, double* %62
br label %63
63: ; preds = %51
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %12
66: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @mult_Atv(double* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %38
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %30, %5
%8 = phi i64 [ 0, %5 ], [ %36, %30 ]
%9 = tail call double* (...) @_mm_setzero_pd()
%10 = trunc i64 %8 to i32
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %27, %11 ]
%13 = phi double* [ %9, %7 ], [ %26, %11 ]
%14 = getelementptr inbounds double, double* %0, i64 %12
%15 = load double, double* %14
%16 = or i64 %12, 1
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = tail call double* @_mm_set_pd(double %15, double %18)
%20 = trunc i64 %12 to i32
%21 = tail call double @A(i32 %20, i32 %10)
%22 = trunc i64 %16 to i32
%23 = tail call double @A(i32 %22, i32 %10)
%24 = tail call double* @_mm_set_pd(double %21, double %23)
%25 = tail call i32 @_mm_div_pd(double* %19, double* %24)
%26 = tail call double* @_mm_add_pd(double* %13, i32 %25)
%27 = add nuw i64 %12, 2
%28 = trunc i64 %27 to i32
%29 = icmp slt i32 %28, %2
br i1 %29, label %11, label %30
30: ; preds = %11
%31 = load double, double* %26
%32 = getelementptr inbounds double, double* %26, i64 1
%33 = load double, double* %32
%34 = fadd double %31, %33
%35 = getelementptr inbounds double, double* %1, i64 %8
store double %34, double* %35
%36 = add nuw nsw i64 %8, 1
%37 = icmp eq i64 %36, %6
br i1 %37, label %38, label %7
38: ; preds = %30, %3
ret void
}