#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 */
double tensor_dot(double const *, double *, unsigned int);
int /*<<< orphan*/ tensor_mxm(double *, unsigned int, double const *,
                              unsigned int, double const *, int);
double tensor_ig2(double g[2], const double *wtr, unsigned int nr,
                  const double *wts, unsigned int ns, const double *u,
                  double *work) {
  tensor_mxm(work, nr, u, ns, wts, 2);
  g[0] = tensor_dot(wtr + nr, work, nr);
  g[1] = tensor_dot(wtr, work + nr, nr);
  return tensor_dot(wtr, work, nr);
}


x86 assembly (clang, -O0):
<tensor_ig2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x2,%r9d
call   1040 <tensor_mxm@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <tensor_dot@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1030 <tensor_dot@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <tensor_dot@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tensor_ig2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x30(%rsp),%r15
mov    %r15,%rdi
mov    %edx,%esi
mov    %r9,%rdx
mov    %r8d,%ecx
mov    %rax,%r8
mov    $0x2,%r9d
call   1040 <tensor_mxm@plt>
mov    %ebx,%r13d
lea    (%r14,%r13,8),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <tensor_dot@plt>
movsd  %xmm0,(%r12)
lea    (%r15,%r13,8),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <tensor_dot@plt>
movsd  %xmm0,0x8(%r12)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <tensor_dot@plt>

LLVM IR (-O0):
define double @tensor_ig2(double* %0, double* %1, i32 %2, double* %3, i32 %4, double* %5, double* %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
store double* %0, double** %8
store double* %1, double** %9
store i32 %2, i32* %10
store double* %3, double** %11
store i32 %4, i32* %12
store double* %5, double** %13
store double* %6, double** %14
%15 = load double*, double** %14
%16 = load i32, i32* %10
%17 = load double*, double** %13
%18 = load i32, i32* %12
%19 = load double*, double** %11
%20 = call i32 @tensor_mxm(double* %15, i32 %16, double* %17, i32 %18, double* %19, i32 2)
%21 = load double*, double** %9
%22 = load i32, i32* %10
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double*, double** %14
%26 = load i32, i32* %10
%27 = call double @tensor_dot(double* %24, double* %25, i32 %26)
%28 = load double*, double** %8
%29 = getelementptr inbounds double, double* %28, i64 0
store double %27, double* %29
%30 = load double*, double** %9
%31 = load double*, double** %14
%32 = load i32, i32* %10
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load i32, i32* %10
%36 = call double @tensor_dot(double* %30, double* %34, i32 %35)
%37 = load double*, double** %8
%38 = getelementptr inbounds double, double* %37, i64 1
store double %36, double* %38
%39 = load double*, double** %9
%40 = load double*, double** %14
%41 = load i32, i32* %10
%42 = call double @tensor_dot(double* %39, double* %40, i32 %41)
ret double %42
}

LLVM IR (-O2):
define double @tensor_ig2(double* nocapture writeonly %0, double* %1, i32 %2, double* %3, i32 %4, double* %5, double* %6) {
%8 = tail call i32 @tensor_mxm(double* %6, i32 %2, double* %5, i32 %4, double* %3, i32 2)
%9 = zext i32 %2 to i64
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = tail call double @tensor_dot(double* %10, double* %6, i32 %2)
store double %11, double* %0
%12 = getelementptr inbounds double, double* %6, i64 %9
%13 = tail call double @tensor_dot(double* %1, double* %12, i32 %2)
%14 = getelementptr inbounds double, double* %0, i64 1
store double %13, double* %14
%15 = tail call double @tensor_dot(double* %1, double* %6, i32 %2)
ret double %15
}