#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*/ _inner_vec_ddot(double *, int, double const *, double *, int,
                                   double, int);
void _dmvec_trid_dot_backward(double *Xc, const double *Ac, int unit, int incX,
                              int ldA, int nRE) {
  register int i;
  register double *xr;
  double xtmp;
  register const double *Ar, *Acl;
  Acl = Ac + (nRE - 1) * ldA;
  xr = Xc + (nRE - 1) * incX;
  for (i = 0; i < nRE; i++) {
    xtmp = unit ? xr[0] : 0.0;
    _inner_vec_ddot(&xtmp, 1, Acl, Xc, incX, 1.0, nRE - unit - i);
    xr[0] = xtmp;
    xr -= incX;
    Acl -= ldA;
  }
}


x86 assembly (clang, -O0):
<_dmvec_trid_dot_backward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1229 <_dmvec_trid_dot_backward+0x119>
cmpl   $0x0,-0x14(%rbp)
je     1195 <_dmvec_trid_dot_backward+0x85>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11a2 <_dmvec_trid_dot_backward+0x92>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11a2 <_dmvec_trid_dot_backward+0x92>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    -0x20(%rbp),%r9d
sub    -0x14(%rbp),%r9d
sub    -0x24(%rbp),%r9d
lea    -0x38(%rbp),%rdi
mov    $0x1,%esi
movsd  0xe2b(%rip),%xmm0
call   1030 <_inner_vec_ddot@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116d <_dmvec_trid_dot_backward+0x5d>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dmvec_trid_dot_backward>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x4(%rsp)
mov    %edx,(%rsp)
mov    %rdi,0x8(%rsp)
test   %r9d,%r9d
jle    11d6 <_dmvec_trid_dot_backward+0xc6>
mov    %r9d,%ebx
lea    -0x1(%rbx),%eax
mov    %eax,%ecx
mov    0x4(%rsp),%edx
imul   %edx,%ecx
movslq %ecx,%rcx
mov    0x8(%rsp),%rdi
lea    (%rdi,%rcx,8),%r13
imul   %r8d,%eax
cltq
lea    (%rsi,%rax,8),%rbp
movslq %edx,%r14
movslq %r8d,%r15
shl    $0x3,%r15
neg    %r15
mov    (%rsp),%eax
mov    %eax,%r12d
neg    %r12d
shl    $0x3,%r14
neg    %r14
jmp    11cb <_dmvec_trid_dot_backward+0xbb>
nopw   0x0(%rax,%rax,1)
movsd  0x0(%r13),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    (%r12,%rbx,1),%r9d
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    0x8(%rsp),%rcx
mov    0x4(%rsp),%r8d
movsd  0xe51(%rip),%xmm0
call   1030 <_inner_vec_ddot@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x0(%r13)
add    %r15,%rbp
add    %r14,%r13
add    $0xffffffff,%ebx
je     11d6 <_dmvec_trid_dot_backward+0xc6>
cmpl   $0x0,(%rsp)
jne    1180 <_dmvec_trid_dot_backward+0x70>
xorps  %xmm0,%xmm0
jmp    1186 <_dmvec_trid_dot_backward+0x76>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @_dmvec_trid_dot_backward(double* %0, double* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double
%8 = bitcast double* %7 to i8*
%9 = add nsw i32 %5, -1
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %39
11: ; preds = %6
%12 = mul nsw i32 %9, %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = mul nsw i32 %9, %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = icmp eq i32 %2, 0
%19 = sext i32 %3 to i64
%20 = sub nsw i64 0, %19
%21 = sext i32 %4 to i64
%22 = sub nsw i64 0, %21
br label %23
23: ; preds = %11, %29
%24 = phi double* [ %17, %11 ], [ %36, %29 ]
%25 = phi i32 [ 0, %11 ], [ %37, %29 ]
%26 = phi double* [ %14, %11 ], [ %35, %29 ]
br i1 %18, label %29, label %27
27: ; preds = %23
%28 = load double, double* %26
br label %29
29: ; preds = %23, %27
%30 = phi double [ %28, %27 ], [ 0.000000e+00, %23 ]
store double %30, double* %7
%31 = add i32 %25, %2
%32 = sub i32 %5, %31
%33 = call i32 @_inner_vec_ddot(double* %7, i32 1, double* %24, double* %0, i32 %3, double 1.000000e+00, i32 %32)
%34 = load double, double* %7
store double %34, double* %26
%35 = getelementptr inbounds double, double* %26, i64 %20
%36 = getelementptr inbounds double, double* %24, i64 %22
%37 = add nuw nsw i32 %25, 1
%38 = icmp eq i32 %37, %5
br i1 %38, label %39, label %23
39: ; preds = %29, %6
ret void
}