// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/kinetic_tnm.c
// Function: Compute_Jtilde
int Compute_Jtilde(struct Jacobian *J)
{
  // Jtilde = J L^t(-1)
  // Jtilde_ia = sum_b J_ib L^t(-1)_ba =  sum_b J_ib L(-1)_ab
  // Jtilde_ai = L(-1)_ab sum_b J_bi => LJtilde = J
  int a, i, b;

  if(J->Jtilde_ar==NULL)
    J->Jtilde_ar=Allocate_mat2_f(J->N_axes, J->N_Cart);
  if(J->T_sqrt_inv!=NULL){
    // T_sqrt is not lower diagonal!
    for(a=0; a<J->N_kin; a++){
      for(i=0; i<J->N_Cart; i++){
	double sum=0;
	for(b=0; b<J->N_axes; b++)
	  sum+=J->T_sqrt_inv[a][b]*J->Jacobian_ar[b][i];
	J->Jtilde_ar[a][i]=sum;
      }
    }
  }else{
    // Exploit that T_sqrt is lower diagonal
    // T_sqrt Jtilde = J
    double *X=malloc(J->N_axes*sizeof(double));
    double *Y=malloc(J->N_axes*sizeof(double));
    for(i=0; i<J->N_Cart; i++){
      for(a=0; a<J->N_axes; a++)Y[a]=J->Jacobian_ar[a][i];
      Forward_substitution(X, J->T_sqrt, Y, J->N_axes);
      for(a=0; a<J->N_axes; a++)J->Jtilde_ar[a][i]=X[a];
    }
    free(X); free(Y);
  }
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x309b4
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x69360
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x30a9b
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x30a96
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x30a86
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x30a56
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x30a00
movsd -0x20(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x309e1
jmp 0x30a88
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x309ca
jmp 0x30ba5
movq -0x8(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x1180
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x1180
movq %rax, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x30b93
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x30b21
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x30ae1
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x30(%rbp), %rdx
movq -0x8(%rbp), %rax
movl (%rax), %ecx
callq 0x697c0
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x30b83
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x30b43
jmp 0x30b85
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x30aca
movq -0x28(%rbp), %rdi
callq 0x1040
movq -0x30(%rbp), %rdi
callq 0x1040
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)