#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_mtxv(double *, unsigned int, double const *,
                               double const *, unsigned int);
double tensor_i3(const double *Jr, unsigned int nr, const double *Js,
                 unsigned int ns, const double *Jt, unsigned int nt,
                 const double *u, double *work) {
  double *work2 = work + nt;
  tensor_mtxv(work2, ns * nt, u, Jr, nr);
  tensor_mtxv(work, nt, work2, Js, ns);
  return tensor_dot(Jt, work, nt);
}


x86 assembly (clang, -O0):
<tensor_i3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
imul   -0x2c(%rbp),%esi
mov    0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
call   1040 <tensor_mtxv@plt>
mov    0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <tensor_mtxv@plt>
mov    -0x28(%rbp),%rdi
mov    0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <tensor_dot@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tensor_i3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebx
mov    %r8,%r14
mov    %ecx,%r12d
mov    %rdx,%r15
mov    %esi,%r8d
mov    %rdi,%rcx
mov    0x40(%rsp),%rdx
mov    0x48(%rsp),%rbp
mov    %r9d,%eax
lea    0x0(,%rax,8),%r13
add    %rbp,%r13
mov    %r9d,%esi
imul   %r12d,%esi
mov    %r13,%rdi
call   1040 <tensor_mtxv@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12d,%r8d
call   1040 <tensor_mtxv@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <tensor_dot@plt>

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

LLVM IR (-O2):
define double @tensor_i3(double* %0, i32 %1, double* %2, i32 %3, double* %4, i32 %5, double* %6, double* %7) {
%9 = zext i32 %5 to i64
%10 = getelementptr inbounds double, double* %7, i64 %9
%11 = mul i32 %5, %3
%12 = tail call i32 @tensor_mtxv(double* %10, i32 %11, double* %6, double* %0, i32 %1)
%13 = tail call i32 @tensor_mtxv(double* %7, i32 %5, double* %10, double* %2, i32 %3)
%14 = tail call double @tensor_dot(double* %4, double* %7, i32 %5)
ret double %14
}