void Multiply_Sym_Matrix_by_Vector_ut(double *u, double *A, double *v, int n) {
  double *pA;
  double *qA;
  int i, j;
  for (pA = A, i = 0; i < n; i++) {
    for (j = i, u[i] = 0.0; j < n; j++)
      u[i] += (*pA++) * v[j];
    for (j = 0, qA = A + i; j < i; j++, qA += n - j)
      u[i] += *qA * v[j];
  }
}


x86 assembly (clang, -O0):
<Multiply_Sym_Matrix_by_Vector_ut>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1226 <Multiply_Sym_Matrix_by_Vector_ut+0x126>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1198 <Multiply_Sym_Matrix_by_Vector_ut+0x98>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x28(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1144 <Multiply_Sym_Matrix_by_Vector_ut+0x44>
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1213 <Multiply_Sym_Matrix_by_Vector_ut+0x113>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%ecx
sub    -0x38(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    11b2 <Multiply_Sym_Matrix_by_Vector_ut+0xb2>
jmp    1218 <Multiply_Sym_Matrix_by_Vector_ut+0x118>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1122 <Multiply_Sym_Matrix_by_Vector_ut+0x22>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Multiply_Sym_Matrix_by_Vector_ut>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
jle    121b <Multiply_Sym_Matrix_by_Vector_ut+0x11b>
mov    %ecx,%r9d
lea    -0x1(%r9),%r8
xor    %r15d,%r15d
mov    %r9,%r10
mov    %rdx,%r11
mov    %rsi,%rax
jmp    1145 <Multiply_Sym_Matrix_by_Vector_ut+0x45>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x8,%r11
add    $0xffffffffffffffff,%r10
cmp    %r9,%r15
je     121b <Multiply_Sym_Matrix_by_Vector_ut+0x11b>
mov    %r15,%r14
and    $0xfffffffffffffffe,%r14
movq   $0x0,(%rdi,%r15,8)
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movsd  (%rax),%xmm1
add    $0x8,%rax
mulsd  (%r11,%rcx,8),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi,%r15,8)
add    $0x1,%rcx
cmp    %rcx,%r10
jne    1160 <Multiply_Sym_Matrix_by_Vector_ut+0x60>
test   %r15,%r15
je     1130 <Multiply_Sym_Matrix_by_Vector_ut+0x30>
lea    (%rsi,%r15,8),%r12
cmp    $0x1,%r15
jne    11a0 <Multiply_Sym_Matrix_by_Vector_ut+0xa0>
xor    %ecx,%ecx
jmp    11f7 <Multiply_Sym_Matrix_by_Vector_ut+0xf7>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r8,%rbx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r12),%xmm1
mulsd  (%rdx,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%r15,8)
lea    (%r12,%rbx,8),%r13
movsd  (%r12,%rbx,8),%xmm0
mulsd  0x8(%rdx,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi,%r15,8)
add    $0x2,%rcx
lea    -0x8(,%rbx,8),%r12
ff
add    %r13,%r12
add    $0xfffffffffffffffe,%rbx
cmp    %rcx,%r14
jne    11b0 <Multiply_Sym_Matrix_by_Vector_ut+0xb0>
test   $0x1,%r15b
je     1130 <Multiply_Sym_Matrix_by_Vector_ut+0x30>
movsd  (%r12),%xmm1
mulsd  (%rdx,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%r15,8)
jmp    1130 <Multiply_Sym_Matrix_by_Vector_ut+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Multiply_Sym_Matrix_by_Vector_ut(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%13 = load double*, double** %6
store double* %13, double** %9
store i32 0, i32* %11
br label %14
14: ; preds = %79, %4
%15 = load i32, i32* %11
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %82
18: ; preds = %14
%19 = load i32, i32* %11
store i32 %19, i32* %12
%20 = load double*, double** %5
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double 0.000000e+00, double* %23
br label %24
24: ; preds = %43, %18
%25 = load i32, i32* %12
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %46
28: ; preds = %24
%29 = load double*, double** %9
%30 = getelementptr inbounds double, double* %29, i32 1
store double* %30, double** %9
%31 = load double, double* %29
%32 = load double*, double** %7
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %5
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = call double @llvm.fmuladd.f64(double %31, double %36, double %41)
store double %42, double* %40
br label %43
43: ; preds = %28
%44 = load i32, i32* %12
%45 = add nsw i32 %44, 1
store i32 %45, i32* %12
br label %24
46: ; preds = %24
store i32 0, i32* %12
%47 = load double*, double** %6
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double* %50, double** %10
br label %51
51: ; preds = %69, %46
%52 = load i32, i32* %12
%53 = load i32, i32* %11
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %78
55: ; preds = %51
%56 = load double*, double** %10
%57 = load double, double* %56
%58 = load double*, double** %7
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double*, double** %5
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = call double @llvm.fmuladd.f64(double %57, double %62, double %67)
store double %68, double* %66
br label %69
69: ; preds = %55
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
%72 = load i32, i32* %8
%73 = load i32, i32* %12
%74 = sub nsw i32 %72, %73
%75 = load double*, double** %10
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds double, double* %75, i64 %76
store double* %77, double** %10
br label %51
78: ; preds = %51
br label %79
79: ; preds = %78
%80 = load i32, i32* %11
%81 = add nsw i32 %80, 1
store i32 %81, i32* %11
br label %14
82: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @Multiply_Sym_Matrix_by_Vector_ut(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %66
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %63, %6
%10 = phi i64 [ 0, %6 ], [ %64, %63 ]
%11 = phi double* [ %1, %6 ], [ %17, %63 ]
%12 = getelementptr inbounds double, double* %0, i64 %10
store double 0.000000e+00, double* %12
br label %13
13: ; preds = %9, %13
%14 = phi double [ 0.000000e+00, %9 ], [ %21, %13 ]
%15 = phi i64 [ %10, %9 ], [ %22, %13 ]
%16 = phi double* [ %11, %9 ], [ %17, %13 ]
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %16
%19 = getelementptr inbounds double, double* %2, i64 %15
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %14)
store double %21, double* %12
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %13
24: ; preds = %13
%25 = icmp eq i64 %10, 0
br i1 %25, label %63, label %26
26: ; preds = %24
%27 = getelementptr inbounds double, double* %1, i64 %10
%28 = and i64 %10, 1
%29 = icmp eq i64 %10, 1
br i1 %29, label %53, label %30
30: ; preds = %26
%31 = and i64 %10, 9223372036854775806
br label %32
32: ; preds = %32, %30
%33 = phi double [ %21, %30 ], [ %47, %32 ]
%34 = phi i64 [ 0, %30 ], [ %48, %32 ]
%35 = phi double* [ %27, %30 ], [ %50, %32 ]
%36 = phi i64 [ 0, %30 ], [ %51, %32 ]
%37 = load double, double* %35
%38 = getelementptr inbounds double, double* %2, i64 %34
%39 = load double, double* %38
%40 = tail call double @llvm.fmuladd.f64(double %37, double %39, double %33)
store double %40, double* %12
%41 = or i64 %34, 1
%42 = sub nsw i64 %7, %41
%43 = getelementptr inbounds double, double* %35, i64 %42
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %2, i64 %41
%46 = load double, double* %45
%47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %40)
store double %47, double* %12
%48 = add nuw nsw i64 %34, 2
%49 = sub nsw i64 %7, %48
%50 = getelementptr inbounds double, double* %43, i64 %49
%51 = add i64 %36, 2
%52 = icmp eq i64 %51, %31
br i1 %52, label %53, label %32
53: ; preds = %32, %26
%54 = phi double [ %21, %26 ], [ %47, %32 ]
%55 = phi i64 [ 0, %26 ], [ %48, %32 ]
%56 = phi double* [ %27, %26 ], [ %50, %32 ]
%57 = icmp eq i64 %28, 0
br i1 %57, label %63, label %58
58: ; preds = %53
%59 = load double, double* %56
%60 = getelementptr inbounds double, double* %2, i64 %55
%61 = load double, double* %60
%62 = tail call double @llvm.fmuladd.f64(double %59, double %61, double %54)
store double %62, double* %12
br label %63
63: ; preds = %58, %53, %24
%64 = add nuw nsw i64 %10, 1
%65 = icmp eq i64 %64, %8
br i1 %65, label %66, label %9
66: ; preds = %63, %4
ret void
}