#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#include "constants.cuh"
#include "mesh.cuh"
#include "matrix_functions.cuh"
#include "material.cuh"
#include "sys.cuh"



void compute_xphys(struct sparse *h ,double *hs, double*x, double *xphys, struct mesh *mesh) {
	
	double  *x_lin, *xphys_tmp;

	x_lin = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));
	xphys_tmp = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));

	for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
		xphys_tmp[i] = 0;
		xphys[i] = 0;
	}

	linearize_matrix(x, x_lin, mesh->nely, mesh->nelx);
	
	for (int i = 0; i < h->nnz; i++) {		//tmp2=H*tmp1
		xphys_tmp[h->row[i] - 1] += h->val[i] * x_lin[h->col[i] - 1];
	}

	for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
		xphys[i] = xphys_tmp[i] / hs[i];
	}
	

	free(xphys_tmp);
	free(x_lin);

}
void compute_sk(double **sk, double *ke, double *xphys, struct mesh *mesh, struct material *material) {
	int k;
	double *xphys_lin, *tmp, *ke_lin;

	(*sk) = (double*)malloc(mesh->nelx*mesh->nely * 64 * sizeof(double));
	ke_lin = (double*)malloc(KEROW*KECOL * sizeof(double)); //ke linearizzato
	xphys_lin = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));	//xphys linearizzato
	tmp = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));

	linearize_matrix(ke, ke_lin, KEROW, KECOL);

	if (mesh->ft == 0 || mesh->ft == 1) {
		linearize_matrix(xphys, xphys_lin, mesh->nely, mesh->nelx);	
		for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
			tmp[i] = pow(xphys_lin[i], mesh->penal)*(material->e0 - material->emin) + material->emin;	
		}
	}
	else {
		for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
			tmp[i] = pow(xphys[i], mesh->penal)*(material->e0 - material->emin) + material->emin;	
		}
	}
	
	k = 0;
	for (int tmp_index = 0; tmp_index < mesh->nelx*mesh->nely; tmp_index++) {
		for (int i = 0; i < 64; i++) {
			(*sk)[k] = ke_lin[i] * tmp[tmp_index];
			k++;
		}
	}


	free(tmp);
	free(ke_lin);
	free(xphys_lin);

}
void compute_sm(double **sm, double *me, double *xphys, struct mesh *mesh, struct material *material) {
	int k = 0;
	double *xphys_lin, *tmp, *me_lin, pi = 3.141592653589;

	(*sm) = (double*)malloc(mesh->nelx*mesh->nely * 64 * sizeof(double));
	me_lin = (double*)malloc(MEROW*MECOL * sizeof(double)); //me linearizzato
	xphys_lin = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));	//xphys linearizzato
	tmp = (double*)malloc(mesh->nelx*mesh->nely * sizeof(double));
	
	linearize_matrix(me, me_lin, MEROW, MECOL);

	if ((mesh->ft == 0) || (mesh->ft == 1)) {
		linearize_matrix(xphys, xphys_lin, mesh->nely, mesh->nelx);
		for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
			tmp[i] = (xphys_lin[i] * sin((pi / 2)*pow(xphys_lin[i], 2))) + material->rhomin;
		}
	}
	else {
		for (int i = 0; i < mesh->nelx*mesh->nely; i++) {
			tmp[i] = (xphys[i] * sin((pi / 2)*pow(xphys[i], 2))) + material->rhomin;
		}
	}
	

	for (int tmp_index = 0; tmp_index < mesh->nelx*mesh->nely; tmp_index++) {
		for (int i = 0; i < 64; i++) {
			(*sm)[k] = (me_lin[i] * tmp[tmp_index])*(material->rho0 - material->rhomin);
			k++;
		}
	}

	free(tmp);
	free(me_lin);
	free(xphys_lin);

}
void modify_m_k(struct sparse *mat, struct mesh *mesh, int *freedofs, int *fixeddofs) {

	int *ik_tmp, *jk_tmp, index = 0, found, count, c;
	int n_freedofs = (2 * (mesh->nelx + 1)*(mesh->nely + 1)) - mesh->fixed_count;
	double *vk_tmp, value;

	ik_tmp = (int*)malloc(mat->nnz * sizeof(int));
	jk_tmp = (int*)malloc(mat->nnz * sizeof(int));
	vk_tmp = (double*)malloc(mat->nnz * sizeof(double));

	for (int i = 0; i < mat->nnz; i++) {		//MAT=(MAT+MAT')/2
		found = 0;
		for (int j = 0;j<mat->nnz; j++) {
			if ((mat->row[i] == mat->col[j]) && (mat->col[i] == mat->row[j])) {
				value = (mat->val[i] + mat->val[j]);
				if (fabs(value) > pow(10, -9)) {
					found = 1;
					ik_tmp[index] = mat->row[i];
					jk_tmp[index] = mat->col[i];
					vk_tmp[index] = value / 2;
					index++;
					break;
				}
			}
		}
		if (found == 0) {
			ik_tmp[index] = mat->row[i];
			jk_tmp[index] = mat->col[i];
			vk_tmp[index] = mat->val[i] / 2;
			index++;
		}
	}

	count = 0;				//MAT=MAT(freedofs,freedofs)
	for (int i = 0; i < n_freedofs;i++) {
		for (int j = 0; j < mat->nnz;j++) {
			if (ik_tmp[j] == freedofs[i]) {
				for (int k = 0; k < n_freedofs;k++) {
					if (jk_tmp[j] == freedofs[k]) {
						count++;
						break;
					}
				}
			}
		}
	}

	free(mat->row);
	free(mat->col);
	free(mat->val);
	mat->row = (int*)malloc(count * sizeof(int));
	mat->col = (int*)malloc(count * sizeof(int));
	mat->val = (double*)malloc(count * sizeof(double));

	count = 0;
	for (int i = 0; i < n_freedofs; i++) {
		for (int j = 0; j < mat->nnz; j++) {
			if (ik_tmp[j] == freedofs[i]) {
				for (int k = 0; k < n_freedofs; k++) {
					if (jk_tmp[j] == freedofs[k]) {
						mat->row[count] = ik_tmp[j];
						mat->col[count] = jk_tmp[j];
						mat->val[count] = vk_tmp[j];
						count++;
						//printf("(%d,%d) %f\n", ik_tmp[j], jk_tmp[j], vk_tmp[j]);
						break;
					}
				}
			}
		}
	}

	mat->nnz = count;
	for (int i = 0; i < mat->nnz; i++) {		//correct indexes
		c = 0;
		for (int j = 0; j < mesh->fixed_count;j++) {
			if (mat->row[i] > fixeddofs[j]) {
				c++;
			}
		}
		mat->row[i] -= c;
		c = 0;
		for (int j = 0; j < mesh->fixed_count; j++) {
			if (mat->col[i] > fixeddofs[j]) {
				c++;
			}
		}
		mat->col[i] -= c;
		//printf("(%d,%d) %f\n", (*ik)[i], (*jk)[i], (*vk)[i]);

	}

	free(ik_tmp);
	free(jk_tmp);
	free(vk_tmp);

}
void compute_s(struct sparse *k, struct sparse *m, struct sparse *s, struct mesh *mesh) {
	int found, count = 0;
	for (int i = 0; i < k->nnz;i++) {
		found = 0;
		for (int j = 0; j < m->nnz; j++) {
			if ((k->row[i] == m->row[j]) && (k->col[i] == m->col[j])) {
				found = 1;
				if ((k->val[i] + m->val[j]) != 0)
				{
					count++;
				}
				break;
			}
		}
		if (found == 0) {
			count++;
		}
	}
	for (int i = 0; i < m->nnz; i++) {
		found = 0;
		for (int j = 0; j < k->nnz; j++) {
			if ((m->row[i] == k->row[j]) && (m->col[i] == k->col[j])) {
				found = 1;
			}
		}
		if (found == 0) {
			count++;
		}
	}

	s->nnz = count;
	s->row = (int*)malloc(s->nnz * sizeof(int));
	s->col = (int*)malloc(s->nnz * sizeof(int));
	s->val = (double*)malloc(s->nnz * sizeof(double));

	count = 0;
	for (int i = 0; i < k->nnz; i++) {
		found = 0;
		for (int j = 0; j < m->nnz; j++) {
			if ((k->row[i] == m->row[j]) && (k->col[i] == m->col[j])) {
				found = 1;
				if (fabs(k->val[i] + m->val[j]) > pow(10, -9))
				{
					s->row[count] = k->row[i];
					s->col[count] = k->col[i];
					s->val[count] = (mesh->beta*k->val[i]) + (mesh->alpha*m->val[j]);
					count++;
				}
				break;
			}
		}
		if (found == 0) {
			s->row[count] = k->row[i];
			s->col[count] = k->col[i];
			s->val[count] = (mesh->beta*k->val[i]);
			count++;
		}
	}
	for (int i = 0; i < m->nnz; i++) {
		found = 0;
		for (int j = 0; j < k->nnz; j++) {
			if ((m->row[i] == k->row[j]) && (m->col[i] == k->col[j])) {
				found = 1;
			}
		}
		if (found == 0) {
			s->row[count] = m->row[i];
			s->col[count] = m->col[i];
			s->val[count] = mesh->alpha*m->val[i];
			count++;
		}
	}

	/*for (int i = 0; i < (*s_nnz); i++) {
	printf("(%d,%d) %f\n", (*is)[i], (*js)[i], (*vs)[i]);
	}*/

}
void g_matrix_init(int ndof, int nstate, struct sparse *a, struct sparse *b, struct sparse *c, double *dstato, struct sparse *e, struct sparse *k, struct sparse *m, struct sparse *s, int *freedofs, struct sparse *f) {

	int found;

	//-------estato init-----------
	e->val = (double*)malloc((int)(pow(ndof, 2) + ndof) * sizeof(double));
	e->row = (int*)malloc((int)(pow(ndof, 2) + ndof) * sizeof(int));
	e->col = (int*)malloc((int)(pow(ndof, 2) + ndof) * sizeof(int));
	e->nnz = 0;
	e->nrow = nstate;
	e->ncol = nstate;

	for (int i = 0; i < ndof;i++) {		//ESTATO(1:NDOF,1:NDOF)=speye(NDOF);
		e->row[i] = i + 1;
		e->col[i] = i + 1;
		e->val[i] = 1;
		e->nnz++;
	}

	for (int i = 0; i < m->nnz; i++) {	//ESTATO(NDOF+1:NSTATE,NDOF+1:NSTATE) = M;
		e->row[i + ndof] = m->row[i] + ndof;
		e->col[i + ndof] = m->col[i] + ndof;
		e->val[i + ndof] = m->val[i];
		e->nnz++;
	}

	/*for (int i = 0;i < e->nnz;i++) {
		printf("(%d,%d) %f\n", e->row[i], e->col[i], e->val[i]);
	}*/
	//-------astato init----------

	a->val = (double*)malloc((int)(2 * pow(ndof, 2) + ndof) * sizeof(double));
	a->row = (int*)malloc((int)(2 * pow(ndof, 2) + ndof) * sizeof(int));
	a->col = (int*)malloc((int)(2 * pow(ndof, 2) + ndof) * sizeof(int));
	a->nnz = 0;
	a->nrow = nstate;
	a->ncol = nstate;

	for (int i = 0; i < ndof; i++) {		//ASTATO(1:NDOF,NDOF+1:NSTATE) = speye(NDOF);
		a->row[i] = i + 1;
		a->col[i] = i + ndof + 1;
		a->val[i] = 1;
		a->nnz++;
	}

	for (int i = 0; i < k->nnz; i++) {		//ASTATO(NDOF+1:NSTATE,:) = [-K -S];
		a->row[i + ndof] = k->row[i] + ndof;
		a->col[i + ndof] = k->col[i];
		a->val[i + ndof] = -k->val[i];
		a->nnz++;
	}
	for (int i = 0; i < s->nnz; i++) {
		a->row[i + ndof + k->nnz] = k->row[i] + ndof;
		a->col[i + ndof + k->nnz] = k->col[i] + ndof;
		a->val[i + ndof + k->nnz] = -s->val[i];
		a->nnz++;
	}

	/*for (int i = 0; i < (*a_nnz); i++) {
	printf("(%d,%d) %f\n", (*astato_row)[i], (*astato_col)[i], (*astato)[i]);
	}*/

	//-------bstato init----------
	b->val = (double*)malloc(ndof * sizeof(double));
	b->row = (int*)malloc(ndof * sizeof(int));
	b->col = (int*)malloc(ndof * sizeof(int));
	b->nnz = 0;
	b->nrow = nstate;
	b->ncol = NINP;

	for (int i = 0; i < f->nnz; i++) {		//BSTATO(NDOF+1:NSTATE,1) = F(freedofs);
		found = 0;
		for (int j = 0; j < ndof;j++) {
			if (f->row[i] == freedofs[j]) {
				found = 1;
				b->row[b->nnz] = b->nnz + ndof + 1;
				b->col[b->nnz] = f->col[i];
				b->val[b->nnz] = f->val[i];
				b->nnz++;
				break;
			}
		}
	}
	/*for (int i = 0; i < (*b_nnz); i++) {
	printf("(%d,%d) %f\n", (*bstato_row)[i], (*bstato_col)[i], (*bstato)[i]);
	}*/

	//-----cstato init ------
	c->val = (double*)malloc(nstate * sizeof(double));
	c->row = (int*)malloc(nstate * sizeof(int));
	c->col = (int*)malloc(nstate * sizeof(int));
	c->nnz = 0;
	c->nrow = NOUT;
	c->ncol = nstate;

	for (int i = 0; i < f->nnz; i++) {		//BSTATO(NDOF+1:NSTATE,1) = F(freedofs);
		found = 0;
		for (int j = 0; j < ndof;j++) {
			if (f->row[i] == freedofs[j]) {
				found = 1;
				c->row[c->nnz] = f->col[i];
				c->col[c->nnz] = c->nnz + 1;
				c->val[c->nnz] = f->val[i];
				c->nnz++;
				break;
			}
		}
	}

	/*for (int i = 0; i < (*c_nnz); i++) {
	printf("(%d,%d) %f\n", (*cstato_row)[i], (*cstato_col)[i], (*cstato)[i]);
	}*/

	//-------dstato init-----

	(*dstato) = 0;

}
void filt_mod_sensitivities(struct mesh *mesh, double *x, double *df0dx,struct sparse *h, double *hs) {
	int numel;
	double *x_lin, *tmp1, *tmp2;


	numel = mesh->nelx*mesh->nely;
	tmp1 = (double*)malloc(numel * sizeof(double));

	if (mesh->ft == 1) {
		x_lin = (double*)malloc(numel * sizeof(double));
		tmp2 = (double*)malloc(numel * sizeof(double));

		linearize_matrix(x, x_lin, mesh->nely, mesh->nelx);	//x_lin=x(:)
		for (int i = 0; i < numel; i++) {
			tmp1[i] = x_lin[i] * df0dx[i];	//tmp1=x(:).*df0dx(:)
			tmp2[i] = 0;
		}

		for (int i = 0; i < h->nnz; i++) {		//tmp2=H*tmp1
			tmp2[h->row[i] - 1] += h->val[i] * tmp1[h->col[i] - 1];
		}

		for (int i = 0; i < numel; i++) {	//tmp3./Hs./max(1e-3,x(:));
			df0dx[i] = (tmp2[i] / hs[i]) / max((pow(10, -3)), x_lin[i]);
		}
		free(x_lin);
		free(tmp2);

	}
	else if (mesh->ft == 2) {
		for (int i = 0; i < numel; i++) {		//tmp1=df0dx(:)./Hs
			tmp1[i] = df0dx[i] / hs[i];
			df0dx[i] = 0;
		}
		for (int i = 0; i < h->nnz; i++) {
			df0dx[h->row[i] - 1] += h->val[i] * tmp1[h->col[i] - 1];	//H*tmp1
		}
	}


	free(tmp1);

}
void volume_constraint(double **fval, double **dfdx, double *x, struct mesh *mesh, struct sparse *h, double *hs) {

	double epsi, epsi2, sum;
	double *x_lin, *tmp, *tmp2, *dfdx2;
	int numel;

	numel = mesh->nelx*mesh->nely;
	x_lin = (double*)malloc(numel * sizeof(double));


	epsi = 0.01;

	linearize_matrix(x, x_lin, mesh->nely, mesh->nelx);
	if (IVOLUME == 0) {
		tmp = (double*)malloc(numel * sizeof(double));

		sum = 0;
		for (int i = 0; i < numel; i++) {
			sum += x_lin[i];
		}
		(*fval)[0] = ((mesh->area*sum) / (mesh->vmax*VOLFRAC)) - 1 - epsi; // fval = area*sum(x(:))/(VMAX*volfrac)-1-EPSI; 
		for (int i = 0; i < numel; i++) {	// dfdx = area/(VMAX*volfrac)*ones(length(x(:)),1);
			(*dfdx)[i] = mesh->area / (mesh->vmax*VOLFRAC);
		}
		if (mesh->ft == 2) {

			for (int i = 0; i < numel; i++) {		//tmp=dfdx(:) ./ HS
				tmp[i] = (*dfdx)[i] / hs[i];
				(*dfdx)[i] = 0;
			}

			for (int i = 0; i < h->nnz; i++) {	//dfdx=H*tmp
				(*dfdx)[h->row[i] - 1] += h->val[i] * tmp[h->col[i] - 1];
			}

		}
		free(tmp);
	}
	else {
		
		dfdx2 = (double*)malloc(numel * sizeof(double));
		tmp = (double*)malloc(numel * sizeof(double));
		tmp2 = (double*)malloc(numel * sizeof(double));

		epsi2 = 0.05;
		sum = 0;
		for (int i = 0; i < numel; i++) {
			sum += x_lin[i];
		}
		//fval = [fval1; fval2];
		(*fval)[0] = ((mesh->area*sum) / (mesh->vmax * VOLFRAC)) - 1 - epsi; // fval1 = area*sum(x(:))/(VMAX*volfrac)-1-EPSI; 
		(*fval)[1] = ((-mesh->area*sum) / (mesh->vmax * VOLFRAC)) + 1 - epsi2; // fval2 = area*sum(x(:))/(VMAX*volfrac)+1-EPSI2; 

		for (int i = 0; i < numel; i++) {	// dfdx = area/(VMAX*volfrac)*ones(length(x(:)),1);  dfdx2=-area/(VMAX*volfrac)*ones(length(x(:)),1);
			(*dfdx)[i] = mesh->area / (mesh->vmax*VOLFRAC);
			dfdx2[i] = -(mesh->area) / (mesh->vmax*VOLFRAC);
		}

		if (mesh->ft == 2) {
			for (int i = 0; i < numel; i++) {	//tmp=dfdx(:)./Hs 	tmp2=dfdx2(:)./Hs	
				tmp[i] = (*dfdx)[i] / hs[i];
				tmp2[i] = dfdx2[i] / hs[i];
				(*dfdx)[i] = 0;
				dfdx2[i] = 0;
			}

			for (int i = 0; i < h->nnz; i++) {
				(*dfdx)[h->row[i] - 1] += h->val[i] * tmp[h->col[i] - 1];	//H*tmp
				dfdx2[h->row[i] - 1] += h->val[i] * tmp2[h->col[i] - 1];
			}

		}
		for (int i = numel; i < 2 * numel; i++) {
			(*dfdx)[i] = dfdx2[i - numel];
		}

		free(tmp);
		free(dfdx2);
		free(tmp2);

	}
	free(x_lin);
}

void free_sparse(struct sparse *a, struct sparse *b, struct sparse *c, struct sparse *e, struct sparse *k, struct sparse *m, struct sparse *s, struct sparse *invu) {
	free(a->row);
	free(a->col);
	free(a->val);
	free(b->row);
	free(b->col);
	free(b->val);
	free(c->row);
	free(c->col);
	free(c->val);
	free(e->row);
	free(e->col);
	free(e->val);
	free(k->row);
	free(k->col);
	free(k->val);
	free(m->row);
	free(m->col);
	free(m->val);
	free(s->row);
	free(s->col);
	free(s->val);
	free(invu->row);
	free(invu->col);
	free(invu->val);
}


	.file	"tmpxft_0038276f_00000000-6_hinf_functions.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z13compute_xphysP6sparsePdS1_S1_P4mesh
	.type	_Z13compute_xphysP6sparsePdS1_S1_P4mesh, @function
_Z13compute_xphysP6sparsePdS1_S1_P4mesh:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	24(%r8), %ecx
	movq	%rdx, 8(%rsp)
	movl	28(%r8), %edx
	movl	%ecx, %esi
	movl	%ecx, 28(%rsp)
	imull	%edx, %esi
	movl	%edx, 24(%rsp)
	movslq	%esi, %rbx
	movl	%esi, 20(%rsp)
	salq	$3, %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movl	20(%rsp), %esi
	movl	24(%rsp), %edx
	movl	28(%rsp), %ecx
	movq	%rax, %rbx
	xorl	%eax, %eax
.L3:
	cmpl	%eax, %esi
	jle	.L11
	movq	$0x000000000, (%rbx,%rax,8)
	movq	$0x000000000, 0(%r13,%rax,8)
	incq	%rax
	jmp	.L3
.L11:
	movq	8(%rsp), %rdi
	movq	%r12, %rsi
	call	_Z16linearize_matrixPdS_ii@PLT
	movl	32(%r15), %ecx
	xorl	%eax, %eax
.L5:
	cmpl	%eax, %ecx
	jle	.L12
	movq	16(%r15), %rsi
	movq	8(%r15), %rdx
	movslq	(%rsi,%rax,4), %rdi
	movslq	(%rdx,%rax,4), %rdx
	movq	(%r15), %rsi
	leaq	-8(%rbx,%rdx,8), %rdx
	movsd	-8(%r12,%rdi,8), %xmm0
	mulsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	addsd	(%rdx), %xmm0
	movsd	%xmm0, (%rdx)
	jmp	.L5
.L12:
	movl	24(%rbp), %edx
	imull	28(%rbp), %edx
	xorl	%eax, %eax
.L7:
	cmpl	%eax, %edx
	jle	.L13
	movsd	(%rbx,%rax,8), %xmm0
	divsd	(%r14,%rax,8), %xmm0
	movsd	%xmm0, 0(%r13,%rax,8)
	incq	%rax
	jmp	.L7
.L13:
	movq	%rbx, %rdi
	call	free@PLT
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movq	%r12, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z13compute_xphysP6sparsePdS1_S1_P4mesh, .-_Z13compute_xphysP6sparsePdS1_S1_P4mesh
	.globl	_Z10compute_skPPdS_S_P4meshP8material
	.type	_Z10compute_skPPdS_S_P4meshP8material, @function
_Z10compute_skPPdS_S_P4meshP8material:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	24(%rcx), %ebx
	imull	28(%rcx), %ebx
	movl	%ebx, %edi
	movslq	%ebx, %rbx
	sall	$6, %edi
	salq	$3, %rbx
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movl	$512, %edi
	movq	%rax, 0(%r13)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	(%rsp), %rsi
	movq	%r15, %rdi
	movl	$8, %ecx
	movl	$8, %edx
	movq	%rax, %rbx
	xorl	%r15d, %r15d
	call	_Z16linearize_matrixPdS_ii@PLT
	cmpl	$1, 88(%r12)
	ja	.L15
	movl	24(%r12), %ecx
	movl	28(%r12), %edx
	movq	%r14, %rdi
	xorl	%r14d, %r14d
	movq	8(%rsp), %rsi
	call	_Z16linearize_matrixPdS_ii@PLT
.L16:
	movl	24(%r12), %eax
	imull	28(%r12), %eax
	cmpl	%r14d, %eax
	jle	.L20
	movq	8(%rsp), %rax
	movsd	64(%r12), %xmm1
	movsd	(%rax,%r14,8), %xmm0
	call	pow@PLT
	movsd	8(%rbp), %xmm1
	movaps	%xmm0, %xmm2
	movsd	0(%rbp), %xmm0
	subsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%r14,8)
	incq	%r14
	jmp	.L16
.L20:
	movl	24(%r12), %esi
	xorl	%edx, %edx
	imull	28(%r12), %esi
	jmp	.L18
.L15:
	movl	24(%r12), %eax
	imull	28(%r12), %eax
	cmpl	%r15d, %eax
	jle	.L20
	movsd	(%r14,%r15,8), %xmm0
	movsd	64(%r12), %xmm1
	call	pow@PLT
	movsd	8(%rbp), %xmm1
	movaps	%xmm0, %xmm2
	movsd	0(%rbp), %xmm0
	subsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	movsd	%xmm0, (%rbx,%r15,8)
	incq	%r15
	jmp	.L15
.L21:
	movq	(%rsp), %rdi
	movsd	(%rdi,%rax), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, (%rcx,%rax)
	addq	$8, %rax
	cmpq	$512, %rax
	jne	.L21
	incq	%rdx
.L18:
	cmpl	%edx, %esi
	jle	.L22
	movq	%rdx, %rcx
	movsd	(%rbx,%rdx,8), %xmm0
	xorl	%eax, %eax
	salq	$9, %rcx
	addq	0(%r13), %rcx
	jmp	.L21
.L22:
	movq	%rbx, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z10compute_skPPdS_S_P4meshP8material, .-_Z10compute_skPPdS_S_P4meshP8material
	.globl	_Z10compute_smPPdS_S_P4meshP8material
	.type	_Z10compute_smPPdS_S_P4meshP8material, @function
_Z10compute_smPPdS_S_P4meshP8material:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	24(%rcx), %ebx
	imull	28(%rcx), %ebx
	movl	%ebx, %edi
	movslq	%ebx, %rbx
	sall	$6, %edi
	salq	$3, %rbx
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	malloc@PLT
	movl	$512, %edi
	movq	%rax, 0(%r13)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	(%rsp), %rsi
	movl	$8, %ecx
	movq	%r14, %rdi
	movl	$8, %edx
	movq	%rax, %rbx
	call	_Z16linearize_matrixPdS_ii@PLT
	cmpl	$1, 88(%r12)
	movl	24(%r12), %ecx
	jbe	.L29
	imull	28(%r12), %ecx
	xorl	%r14d, %r14d
	movl	%ecx, 16(%rsp)
	jmp	.L30
.L29:
	movl	28(%r12), %edx
	movq	8(%rsp), %rsi
	movq	%r15, %rdi
	xorl	%r15d, %r15d
	call	_Z16linearize_matrixPdS_ii@PLT
	movl	24(%r12), %r14d
	imull	28(%r12), %r14d
.L31:
	cmpl	%r15d, %r14d
	jle	.L35
	movq	8(%rsp), %rax
	movsd	(%rax,%r15,8), %xmm1
	movaps	%xmm1, %xmm0
	movsd	%xmm1, 16(%rsp)
	mulsd	%xmm1, %xmm0
	mulsd	.LC1(%rip), %xmm0
	call	sin@PLT
	movsd	16(%rsp), %xmm1
	mulsd	%xmm0, %xmm1
	addsd	24(%rbp), %xmm1
	movsd	%xmm1, (%rbx,%r15,8)
	incq	%r15
	jmp	.L31
.L35:
	movl	24(%r12), %esi
	xorl	%edx, %edx
	imull	28(%r12), %esi
	jmp	.L33
.L30:
	cmpl	%r14d, 16(%rsp)
	jle	.L35
	movsd	(%r15,%r14,8), %xmm1
	movaps	%xmm1, %xmm0
	movsd	%xmm1, 24(%rsp)
	mulsd	%xmm1, %xmm0
	mulsd	.LC1(%rip), %xmm0
	call	sin@PLT
	movsd	24(%rsp), %xmm1
	mulsd	%xmm0, %xmm1
	addsd	24(%rbp), %xmm1
	movsd	%xmm1, (%rbx,%r14,8)
	incq	%r14
	jmp	.L30
.L36:
	movq	(%rsp), %rdi
	movsd	16(%rbp), %xmm0
	subsd	24(%rbp), %xmm0
	movsd	(%rdi,%rax), %xmm2
	mulsd	%xmm1, %xmm2
	mulsd	%xmm2, %xmm0
	movsd	%xmm0, (%rcx,%rax)
	addq	$8, %rax
	cmpq	$512, %rax
	jne	.L36
	incq	%rdx
.L33:
	cmpl	%edx, %esi
	jle	.L37
	movq	%rdx, %rcx
	movsd	(%rbx,%rdx,8), %xmm1
	xorl	%eax, %eax
	salq	$9, %rcx
	addq	0(%r13), %rcx
	jmp	.L36
.L37:
	movq	%rbx, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z10compute_smPPdS_S_P4meshP8material, .-_Z10compute_smPPdS_S_P4meshP8material
	.globl	_Z10modify_m_kP6sparseP4meshPiS3_
	.type	_Z10modify_m_kP6sparseP4meshPiS3_, @function
_Z10modify_m_kP6sparseP4meshPiS3_:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	24(%rsi), %eax
	movslq	32(%rdi), %r15
	movq	%rcx, 24(%rsp)
	movl	28(%rsi), %ecx
	incl	%eax
	leaq	0(,%r15,4), %rbp
	movq	%rdx, 32(%rsp)
	movq	%r15, %r13
	incl	%ecx
	movq	%rbp, %rdi
	imull	%ecx, %eax
	addl	%eax, %eax
	subl	120(%rsi), %eax
	movl	%eax, 12(%rsp)
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	0(,%r15,8), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	32(%rsp), %rdx
	movl	$1, %edi
	movq	.LC2(%rip), %xmm2
	movq	%rax, 16(%rsp)
	movsd	.LC3(%rip), %xmm3
	movl	%r15d, %eax
	movsd	.LC4(%rip), %xmm4
	leaq	0(,%rax,4), %rcx
	xorl	%eax, %eax
.L41:
	leal	-1(%rdi), %esi
	cmpl	%esi, %r13d
	jle	.L68
	movq	8(%rbx), %r15
	movq	16(%rbx), %r10
	xorl	%esi, %esi
	movq	(%rbx), %r8
	movl	(%r15,%rax), %r11d
	movl	(%r10,%rax), %r9d
	movsd	(%r8,%rax,2), %xmm0
.L47:
	cmpq	%rcx, %rsi
	je	.L74
	cmpl	%r11d, (%r10,%rsi)
	jne	.L42
	cmpl	%r9d, (%r15,%rsi)
	jne	.L42
	movsd	(%r8,%rsi,2), %xmm1
	addsd	%xmm0, %xmm1
	movaps	%xmm1, %xmm5
	andps	%xmm2, %xmm5
	comisd	%xmm3, %xmm5
	jbe	.L42
	mulsd	.LC4(%rip), %xmm1
	movaps	%xmm1, %xmm0
	jmp	.L44
.L42:
	addq	$4, %rsi
	jmp	.L47
.L74:
	mulsd	%xmm4, %xmm0
.L44:
	movq	16(%rsp), %rsi
	movl	%r11d, (%r12,%rax)
	incl	%edi
	movl	%r9d, 0(%rbp,%rax)
	movsd	%xmm0, (%rsi,%rax,2)
	addq	$4, %rax
	jmp	.L41
.L68:
	xorl	%esi, %esi
	xorl	%r15d, %r15d
.L46:
	cmpl	%esi, 12(%rsp)
	jle	.L75
	xorl	%eax, %eax
.L52:
	cmpl	%eax, %r13d
	jle	.L76
	movl	(%rdx,%rsi,4), %ecx
	cmpl	%ecx, (%r12,%rax,4)
	jne	.L48
	movl	0(%rbp,%rax,4), %edi
	xorl	%r8d, %r8d
.L50:
	cmpl	(%rdx,%r8,4), %edi
	jne	.L49
	incl	%r15d
	jmp	.L48
.L49:
	incq	%r8
	cmpl	%r8d, 12(%rsp)
	jg	.L50
.L48:
	incq	%rax
	jmp	.L52
.L76:
	incq	%rsi
	jmp	.L46
.L75:
	movq	8(%rbx), %rdi
	movq	%rdx, 40(%rsp)
	call	free@PLT
	movq	16(%rbx), %rdi
	call	free@PLT
	movq	(%rbx), %rdi
	call	free@PLT
	movslq	%r15d, %rsi
	leaq	0(,%rsi,4), %r15
	movq	%rsi, 32(%rsp)
	movq	%r15, %rdi
	call	malloc@PLT
	movq	%r15, %rdi
	movq	%rax, 8(%rbx)
	movq	%rax, %r13
	call	malloc@PLT
	movq	32(%rsp), %rsi
	movq	%rax, 16(%rbx)
	movq	%rax, %r15
	leaq	0(,%rsi,8), %rdi
	call	malloc@PLT
	movq	40(%rsp), %rdx
	xorl	%edi, %edi
	xorl	%esi, %esi
	movq	%rax, (%rbx)
	movq	%rax, %r8
.L53:
	cmpl	%edi, 12(%rsp)
	jle	.L58
	movl	32(%rbx), %ecx
	xorl	%eax, %eax
.L59:
	cmpl	%eax, %ecx
	jle	.L77
	movl	(%r12,%rax,4), %r10d
	cmpl	(%rdx,%rdi,4), %r10d
	jne	.L54
	movl	0(%rbp,%rax,4), %r11d
	xorl	%r9d, %r9d
.L56:
	cmpl	(%rdx,%r9,4), %r11d
	jne	.L55
	movslq	%esi, %r9
	incl	%esi
	movl	%r10d, 0(%r13,%r9,4)
	movq	16(%rsp), %r10
	movl	%r11d, (%r15,%r9,4)
	movsd	(%r10,%rax,8), %xmm0
	movsd	%xmm0, (%r8,%r9,8)
	jmp	.L54
.L55:
	incq	%r9
	cmpl	%r9d, 12(%rsp)
	jg	.L56
.L54:
	incq	%rax
	jmp	.L59
.L77:
	incq	%rdi
	jmp	.L53
.L58:
	movl	%esi, 32(%rbx)
	xorl	%edi, %edi
.L60:
	cmpl	%edi, %esi
	jle	.L66
	movl	120(%r14), %r8d
	movl	0(%r13,%rdi,4), %edx
	xorl	%eax, %eax
	xorl	%r9d, %r9d
.L67:
	cmpl	%eax, %r8d
	jle	.L78
	movq	24(%rsp), %rbx
	cmpl	%edx, (%rbx,%rax,4)
	jge	.L61
	incl	%r9d
.L61:
	incq	%rax
	jmp	.L67
.L78:
	subl	%r9d, %edx
	movl	(%r15,%rdi,4), %eax
	xorl	%r9d, %r9d
	movl	%edx, 0(%r13,%rdi,4)
	xorl	%edx, %edx
.L63:
	cmpl	%edx, %r8d
	jle	.L79
	movq	24(%rsp), %rcx
	cmpl	%eax, (%rcx,%rdx,4)
	jge	.L64
	incl	%r9d
.L64:
	incq	%rdx
	jmp	.L63
.L79:
	subl	%r9d, %eax
	movl	%eax, (%r15,%rdi,4)
	incq	%rdi
	jmp	.L60
.L66:
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z10modify_m_kP6sparseP4meshPiS3_, .-_Z10modify_m_kP6sparseP4meshPiS3_
	.globl	_Z9compute_sP6sparseS0_S0_P4mesh
	.type	_Z9compute_sP6sparseS0_S0_P4mesh, @function
_Z9compute_sP6sparseS0_S0_P4mesh:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorps	%xmm1, %xmm1
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	xorl	%edx, %edx
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	32(%rsi), %r9d
	movl	32(%rdi), %r8d
	xorl	%edi, %edi
.L81:
	cmpl	%edx, %r8d
	jle	.L105
	leaq	0(,%rdx,4), %rcx
	xorl	%eax, %eax
.L87:
	cmpl	%eax, %r9d
	jle	.L112
	movq	8(%rbx), %rsi
	movq	8(%rbp), %r10
	movl	(%rsi,%rax,4), %esi
	cmpl	%esi, (%r10,%rcx)
	jne	.L82
	movq	16(%rbx), %rsi
	movq	16(%rbp), %r10
	movl	(%rsi,%rax,4), %esi
	cmpl	%esi, (%r10,%rcx)
	jne	.L82
	movq	0(%rbp), %rsi
	movq	(%rbx), %rcx
	movsd	(%rsi,%rdx,8), %xmm0
	addsd	(%rcx,%rax,8), %xmm0
	ucomisd	%xmm1, %xmm0
	jp	.L112
	je	.L83
	jmp	.L112
.L82:
	incq	%rax
	jmp	.L87
.L112:
	incl	%edi
.L83:
	incq	%rdx
	jmp	.L81
.L105:
	xorl	%edx, %edx
	movl	$1, %r10d
.L86:
	cmpl	%edx, %r9d
	jle	.L91
	leaq	0(,%rdx,4), %rsi
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.L92:
	cmpl	%eax, %r8d
	jle	.L114
	movq	8(%rbp), %r11
	movq	8(%rbx), %r12
	movl	(%r11,%rax,4), %r11d
	cmpl	%r11d, (%r12,%rsi)
	jne	.L88
	movq	16(%rbx), %r12
	movq	16(%rbp), %r11
	movl	(%r11,%rax,4), %r11d
	cmpl	%r11d, (%r12,%rsi)
	cmove	%r10d, %ecx
.L88:
	incq	%rax
	jmp	.L92
.L114:
	cmpl	$1, %ecx
	adcl	$0, %edi
	incq	%rdx
	jmp	.L86
.L91:
	movslq	%edi, %rdx
	movl	%edi, 32(%r14)
	leaq	0(,%rdx,4), %r13
	movq	%rdx, 8(%rsp)
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, 8(%r14)
	movq	%rax, %r12
	call	malloc@PLT
	movq	8(%rsp), %rdx
	movq	%rax, 16(%r14)
	movq	%rax, %r13
	leaq	0(,%rdx,8), %rdi
	call	malloc@PLT
	movl	32(%rbp), %r9d
	movl	32(%rbx), %r10d
	xorl	%edi, %edi
	movq	.LC2(%rip), %xmm3
	movq	%rax, (%r14)
	movq	%rax, %rdx
	xorl	%esi, %esi
	movsd	.LC3(%rip), %xmm4
	xorl	%eax, %eax
.L93:
	cmpl	%esi, %r9d
	jle	.L107
	movq	8(%rbp), %rcx
	movl	(%rcx,%rsi,4), %r11d
	movq	16(%rbp), %rcx
	leaq	(%rcx,%rsi,4), %r8
	xorl	%ecx, %ecx
.L99:
	cmpl	%ecx, %r10d
	jle	.L115
	movq	8(%rbx), %r14
	cmpl	%r11d, (%r14,%rcx,4)
	jne	.L94
	movq	16(%rbx), %r14
	movl	(%r14,%rcx,4), %r14d
	cmpl	%r14d, (%r8)
	jne	.L94
	movq	0(%rbp), %r14
	movsd	(%r14,%rdi), %xmm0
	movq	(%rbx), %r14
	movsd	(%r14,%rcx,8), %xmm1
	movaps	%xmm0, %xmm2
	addsd	%xmm1, %xmm2
	andps	%xmm3, %xmm2
	comisd	%xmm4, %xmm2
	jbe	.L95
	mulsd	104(%r15), %xmm0
	movslq	%eax, %rcx
	mulsd	96(%r15), %xmm1
	movl	%r11d, (%r12,%rcx,4)
	movl	(%r8), %r8d
	movl	%r8d, 0(%r13,%rcx,4)
	addsd	%xmm1, %xmm0
	jmp	.L113
.L94:
	incq	%rcx
	jmp	.L99
.L115:
	movslq	%eax, %rcx
	movl	%r11d, (%r12,%rcx,4)
	movl	(%r8), %r8d
	movl	%r8d, 0(%r13,%rcx,4)
	movq	0(%rbp), %r8
	movsd	(%r8,%rdi), %xmm0
	mulsd	104(%r15), %xmm0
.L113:
	movsd	%xmm0, (%rdx,%rcx,8)
	incl	%eax
.L95:
	incq	%rsi
	addq	$8, %rdi
	jmp	.L93
.L107:
	xorl	%esi, %esi
.L98:
	cmpl	%esi, %r10d
	jle	.L80
	leaq	0(,%rsi,4), %rdi
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
.L104:
	cmpl	%ecx, %r9d
	jle	.L116
	movq	8(%rbp), %r11
	movq	8(%rbx), %r14
	movl	(%r11,%rcx,4), %r11d
	cmpl	%r11d, (%r14,%rdi)
	jne	.L100
	movq	16(%rbx), %r14
	movq	16(%rbp), %r11
	movl	(%r11,%rcx,4), %r11d
	cmpl	%r11d, (%r14,%rdi)
	movl	$1, %r14d
	cmove	%r14d, %r8d
.L100:
	incq	%rcx
	jmp	.L104
.L116:
	testl	%r8d, %r8d
	jne	.L102
	movq	8(%rbx), %r8
	movslq	%eax, %rcx
	incl	%eax
	movl	(%r8,%rdi), %r8d
	movl	%r8d, (%r12,%rcx,4)
	movq	16(%rbx), %r8
	movl	(%r8,%rdi), %edi
	movl	%edi, 0(%r13,%rcx,4)
	movq	(%rbx), %rdi
	movsd	(%rdi,%rsi,8), %xmm0
	mulsd	96(%r15), %xmm0
	movsd	%xmm0, (%rdx,%rcx,8)
.L102:
	incq	%rsi
	jmp	.L98
.L80:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z9compute_sP6sparseS0_S0_P4mesh, .-_Z9compute_sP6sparseS0_S0_P4mesh
	.globl	_Z13g_matrix_initiiP6sparseS0_S0_PdS0_S0_S0_S0_PiS0_
	.type	_Z13g_matrix_initiiP6sparseS0_S0_PdS0_S0_S0_S0_PiS0_, @function
_Z13g_matrix_initiiP6sparseS0_S0_PdS0_S0_S0_S0_PiS0_:
.LFB2033:
	.cfi_startproc
	endbr64
	cvtsi2sdl	%edi, %xmm1
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r8, %r12
	movaps	%xmm1, %xmm0
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdx, %rbp
	mulsd	%xmm1, %xmm0
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edi, %ebx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	128(%rsp), %r13
	movl	%esi, 12(%rsp)
	movaps	%xmm0, %xmm2
	movq	%r9, 32(%rsp)
	movq	168(%rsp), %r14
	addsd	%xmm1, %xmm2
	movsd	%xmm0, 56(%rsp)
	movsd	%xmm1, 48(%rsp)
	cvttsd2sil	%xmm2, %r8d
	movslq	%r8d, %r8
	leaq	0(,%r8,8), %rdi
	movq	%r8, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %r8
	movq	%rax, 0(%r13)
	leaq	0(,%r8,4), %rdi
	movq	%rax, 40(%rsp)
	movq	%rdi, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rdi
	movq	%rax, 8(%r13)
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	xorl	%ecx, %ecx
	movq	24(%rsp), %r8
	movsd	.LC5(%rip), %xmm2
	movq	40(%rsp), %rsi
	movsd	48(%rsp), %xmm1
	movq	%rax, 16(%rsp)
	movq	%rax, 16(%r13)
	movl	12(%rsp), %eax
	movl	%ecx, 32(%r13)
	movsd	56(%rsp), %xmm0
	movq	144(%rsp), %r9
	movq	136(%rsp), %rcx
	movl	%eax, 24(%r13)
	movl	%eax, 28(%r13)
	xorl	%eax, %eax
.L118:
	cmpl	%eax, %ebx
	jle	.L141
	movq	16(%rsp), %rdx
	leal	1(%rax), %r10d
	movsd	%xmm2, (%rsi,%rax,8)
	movl	%r10d, (%r8,%rax,4)
	movl	%r10d, (%rdx,%rax,4)
	incq	%rax
	incl	32(%r13)
	jmp	.L118
.L141:
	movslq	%ebx, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, 24(%rsp)
	movq	%rax, %r10
	xorl	%eax, %eax
.L120:
	cmpl	%eax, 32(%r9)
	jle	.L142
	movq	8(%r9), %r11
	movl	(%r11,%rax,4), %edi
	movq	16(%r9), %r11
	addl	%ebx, %edi
	movl	%edi, (%r8,%r10)
	movl	(%r11,%rax,4), %edi
	addl	%ebx, %edi
	movl	%edi, %r11d
	movq	16(%rsp), %rdi
	movl	%r11d, (%rdi,%r10)
	movq	(%r9), %r11
	movsd	(%r11,%rax,8), %xmm2
	incl	32(%r13)
	incq	%rax
	movsd	%xmm2, (%rsi,%r10,2)
	addq	$4, %r10
	jmp	.L120
.L142:
	addsd	%xmm0, %xmm0
	movq	%rcx, 136(%rsp)
	movq	%rdx, 48(%rsp)
	addsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %edi
	movslq	%edi, %rsi
	leaq	0(,%rsi,8), %rdi
	movq	%rsi, 16(%rsp)
	call	malloc@PLT
	movq	16(%rsp), %rsi
	movq	%rax, 0(%rbp)
	movq	%rax, %r13
	leaq	0(,%rsi,4), %rdi
	movq	%rdi, 40(%rsp)
	call	malloc@PLT
	movq	40(%rsp), %rdi
	movq	%rax, 8(%rbp)
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	xorl	%edx, %edx
	movsd	.LC5(%rip), %xmm0
	movq	16(%rsp), %r8
	movq	%rax, 16(%rbp)
	movq	%rax, %rdi
	movl	12(%rsp), %eax
	movl	%edx, 32(%rbp)
	movq	136(%rsp), %rcx
	movq	48(%rsp), %rdx
	movl	%eax, 24(%rbp)
	movl	%eax, 28(%rbp)
	xorl	%eax, %eax
.L122:
	incq	%rax
	leal	-1(%rax), %esi
	cmpl	%ebx, %esi
	jge	.L143
	leal	(%rbx,%rax), %esi
	incl	32(%rbp)
	movl	%eax, -4(%r8,%rax,4)
	movl	%esi, -4(%rdi,%rax,4)
	movsd	%xmm0, -8(%r13,%rax,8)
	jmp	.L122
.L143:
	movq	24(%rsp), %rsi
	movq	.LC6(%rip), %xmm1
	xorl	%eax, %eax
.L124:
	cmpl	%eax, 32(%rcx)
	jle	.L144
	movq	8(%rcx), %r9
	movl	(%r9,%rax,4), %r10d
	movq	16(%rcx), %r9
	addl	%ebx, %r10d
	movl	%r10d, (%r8,%rsi)
	movl	(%r9,%rax,4), %r9d
	movl	%r9d, (%rdi,%rsi)
	movq	(%rcx), %r9
	movsd	(%r9,%rax,8), %xmm0
	incl	32(%rbp)
	incq	%rax
	xorps	%xmm1, %xmm0
	movsd	%xmm0, 0(%r13,%rsi,2)
	addq	$4, %rsi
	jmp	.L124
.L144:
	movq	.LC6(%rip), %xmm1
	xorl	%eax, %eax
.L126:
	movq	152(%rsp), %rsi
	cmpl	%eax, 32(%rsi)
	jle	.L145
	movq	8(%rcx), %r9
	leal	(%rbx,%rax), %esi
	addl	32(%rcx), %esi
	movslq	%esi, %rsi
	movl	(%r9,%rax,4), %r11d
	movq	16(%rcx), %r9
	addl	%ebx, %r11d
	movl	%r11d, (%r8,%rsi,4)
	movq	152(%rsp), %r11
	movl	(%r9,%rax,4), %r10d
	movq	(%r11), %r9
	addl	%ebx, %r10d
	movsd	(%r9,%rax,8), %xmm0
	movl	%r10d, (%rdi,%rsi,4)
	incq	%rax
	incl	32(%rbp)
	xorps	%xmm1, %xmm0
	movsd	%xmm0, 0(%r13,%rsi,8)
	jmp	.L126
.L145:
	leaq	0(,%rdx,8), %rdi
	call	malloc@PLT
	movq	24(%rsp), %rdi
	movq	%rax, (%r15)
	movq	%rax, %rbp
	call	malloc@PLT
	movq	24(%rsp), %rdi
	movq	%rax, 8(%r15)
	movq	%rax, %r13
	call	malloc@PLT
	movq	$1, 28(%r15)
	xorl	%esi, %esi
	movq	%rax, 16(%r15)
	movq	%rax, %rdi
	movl	12(%rsp), %eax
	movl	%eax, 24(%r15)
.L128:
	cmpl	%esi, 32(%r14)
	jle	.L132
	leaq	0(,%rsi,4), %r8
	xorl	%eax, %eax
.L129:
	cmpl	%eax, %ebx
	jle	.L130
	movq	160(%rsp), %rdx
	movq	8(%r14), %rcx
	incq	%rax
	movl	-4(%rdx,%rax,4), %edx
	cmpl	%edx, (%rcx,%r8)
	jne	.L129
	movslq	32(%r15), %rcx
	leal	1(%rcx,%rbx), %r9d
	movq	%rcx, %rax
	movl	%r9d, 0(%r13,%rcx,4)
	movq	16(%r14), %r9
	incl	%eax
	movl	(%r9,%r8), %r8d
	movl	%r8d, (%rdi,%rcx,4)
	movq	(%r14), %r8
	movsd	(%r8,%rsi,8), %xmm0
	movl	%eax, 32(%r15)
	movsd	%xmm0, 0(%rbp,%rcx,8)
.L130:
	incq	%rsi
	jmp	.L128
.L132:
	movslq	12(%rsp), %rbp
	leaq	0(,%rbp,8), %rdi
	salq	$2, %rbp
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, (%r12)
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 8(%r12)
	movq	%rax, %r15
	call	malloc@PLT
	xorl	%ecx, %ecx
	movl	$1, 24(%r12)
	movq	%rax, 16(%r12)
	movq	%rax, %rdi
	xorl	%eax, %eax
	movl	%eax, 32(%r12)
	movl	12(%rsp), %eax
	movl	%eax, 28(%r12)
.L133:
	cmpl	%ecx, 32(%r14)
	jle	.L137
	leaq	0(,%rcx,4), %rsi
	xorl	%eax, %eax
.L134:
	cmpl	%eax, %ebx
	jle	.L135
	movq	160(%rsp), %rdx
	movq	8(%r14), %r8
	incq	%rax
	movl	-4(%rdx,%rax,4), %edx
	cmpl	%edx, (%r8,%rsi)
	jne	.L134
	movq	16(%r14), %r9
	movslq	32(%r12), %r8
	movl	(%r9,%rsi), %esi
	movq	%r8, %rax
	incl	%eax
	movl	%esi, (%r15,%r8,4)
	movq	(%r14), %rsi
	movl	%eax, (%rdi,%r8,4)
	movsd	(%rsi,%rcx,8), %xmm0
	movl	%eax, 32(%r12)
	movsd	%xmm0, 0(%r13,%r8,8)
.L135:
	incq	%rcx
	jmp	.L133
.L137:
	movq	32(%rsp), %rax
	movq	$0x000000000, (%rax)
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z13g_matrix_initiiP6sparseS0_S0_PdS0_S0_S0_S0_PiS0_, .-_Z13g_matrix_initiiP6sparseS0_S0_PdS0_S0_S0_S0_PiS0_
	.globl	_Z22filt_mod_sensitivitiesP4meshPdS1_P6sparseS1_
	.type	_Z22filt_mod_sensitivitiesP4meshPdS1_P6sparseS1_, @function
_Z22filt_mod_sensitivitiesP4meshPdS1_P6sparseS1_:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r8, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	24(%rdi), %eax
	movq	%rsi, 24(%rsp)
	movl	%eax, 16(%rsp)
	movl	28(%rdi), %eax
	movl	%eax, 20(%rsp)
	movl	16(%rsp), %eax
	movl	20(%rsp), %ebx
	imull	%ebx, %eax
	movl	%eax, 12(%rsp)
	cltq
	leaq	0(,%rax,8), %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rax, %rbx
	movl	88(%r12), %eax
	cmpl	$1, %eax
	jne	.L147
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movl	16(%rsp), %ecx
	movl	20(%rsp), %edx
	movq	%r12, %rsi
	movq	24(%rsp), %rdi
	movq	%rax, %rbp
	call	_Z16linearize_matrixPdS_ii@PLT
	xorl	%eax, %eax
.L148:
	cmpl	%eax, 12(%rsp)
	jle	.L162
	movq	$0x000000000, 0(%rbp,%rax,8)
	movsd	(%r12,%rax,8), %xmm0
	mulsd	0(%r13,%rax,8), %xmm0
	movsd	%xmm0, (%rbx,%rax,8)
	incq	%rax
	jmp	.L148
.L162:
	movl	32(%r15), %ecx
	xorl	%eax, %eax
.L150:
	cmpl	%eax, %ecx
	jle	.L163
	movq	16(%r15), %rsi
	movq	8(%r15), %rdx
	movslq	(%rsi,%rax,4), %rdi
	movslq	(%rdx,%rax,4), %rdx
	movq	(%r15), %rsi
	leaq	-8(%rbp,%rdx,8), %rdx
	movsd	-8(%rbx,%rdi,8), %xmm0
	mulsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	addsd	(%rdx), %xmm0
	movsd	%xmm0, (%rdx)
	jmp	.L150
.L163:
	xorl	%r15d, %r15d
.L152:
	cmpl	%r15d, 12(%rsp)
	jle	.L164
	movsd	(%r12,%r15,8), %xmm0
	movsd	.LC7(%rip), %xmm1
	call	fmax@PLT
	movaps	%xmm0, %xmm1
	movsd	0(%rbp,%r15,8), %xmm0
	divsd	(%r14,%r15,8), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 0(%r13,%r15,8)
	incq	%r15
	jmp	.L152
.L164:
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	jmp	.L154
.L147:
	cmpl	$2, %eax
	jne	.L154
	xorl	%eax, %eax
.L155:
	cmpl	%eax, 12(%rsp)
	jle	.L165
	movsd	0(%r13,%rax,8), %xmm0
	divsd	(%r14,%rax,8), %xmm0
	movq	$0x000000000, 0(%r13,%rax,8)
	movsd	%xmm0, (%rbx,%rax,8)
	incq	%rax
	jmp	.L155
.L165:
	movl	32(%r15), %ecx
	xorl	%eax, %eax
.L157:
	cmpl	%eax, %ecx
	jle	.L154
	movq	16(%r15), %rsi
	movq	8(%r15), %rdx
	movslq	(%rsi,%rax,4), %rdi
	movslq	(%rdx,%rax,4), %rdx
	movq	(%r15), %rsi
	leaq	-8(%r13,%rdx,8), %rdx
	movsd	-8(%rbx,%rdi,8), %xmm0
	mulsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	addsd	(%rdx), %xmm0
	movsd	%xmm0, (%rdx)
	jmp	.L157
.L154:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z22filt_mod_sensitivitiesP4meshPdS1_P6sparseS1_, .-_Z22filt_mod_sensitivitiesP4meshPdS1_P6sparseS1_
	.globl	_Z17volume_constraintPPdS0_S_P4meshP6sparseS_
	.type	_Z17volume_constraintPPdS0_S_P4meshP6sparseS_, @function
_Z17volume_constraintPPdS0_S_P4meshP6sparseS_:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rcx, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	24(%rcx), %ecx
	movq	%rdx, (%rsp)
	movl	28(%rbx), %edx
	movl	%ecx, %r15d
	movq	%rdi, 24(%rsp)
	imull	%edx, %r15d
	movq	%r9, 16(%rsp)
	movl	%ecx, 12(%rsp)
	movl	%edx, 8(%rsp)
	movslq	%r15d, %r14
	salq	$3, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	movl	12(%rsp), %ecx
	movl	8(%rsp), %edx
	movq	(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, %r12
	call	_Z16linearize_matrixPdS_ii@PLT
	movq	%r14, %rdi
	call	malloc@PLT
	movq	16(%rsp), %r9
	movq	24(%rsp), %r10
	xorps	%xmm0, %xmm0
	movq	%rax, %rdi
	xorl	%eax, %eax
.L167:
	cmpl	%eax, %r15d
	jle	.L178
	addsd	(%r12,%rax,8), %xmm0
	incq	%rax
	jmp	.L167
.L178:
	movsd	16(%rbx), %xmm2
	movsd	.LC8(%rip), %xmm1
	mulsd	56(%rbx), %xmm0
	movq	(%r10), %rax
	mulsd	%xmm1, %xmm2
	divsd	%xmm2, %xmm0
	subsd	.LC5(%rip), %xmm0
	subsd	.LC9(%rip), %xmm0
	movsd	%xmm0, (%rax)
	xorl	%eax, %eax
.L169:
	cmpl	%eax, %r15d
	jle	.L179
	movsd	16(%rbx), %xmm2
	movsd	56(%rbx), %xmm0
	movq	0(%r13), %rdx
	mulsd	%xmm1, %xmm2
	divsd	%xmm2, %xmm0
	movsd	%xmm0, (%rdx,%rax,8)
	incq	%rax
	jmp	.L169
.L179:
	cmpl	$2, 88(%rbx)
	je	.L176
.L175:
	call	free@PLT
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r12, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
.L176:
	.cfi_restore_state
	xorl	%eax, %eax
.L171:
	cmpl	%eax, %r15d
	jle	.L180
	movq	0(%r13), %rdx
	leaq	(%rdx,%rax,8), %rdx
	movsd	(%rdx), %xmm0
	divsd	(%r9,%rax,8), %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	incq	%rax
	movq	$0x000000000, (%rdx)
	jmp	.L171
.L180:
	movl	32(%rbp), %ecx
	xorl	%eax, %eax
.L173:
	cmpl	%eax, %ecx
	jle	.L175
	movq	8(%rbp), %rdx
	movslq	(%rdx,%rax,4), %rsi
	movq	0(%r13), %rdx
	leaq	-8(%rdx,%rsi,8), %rdx
	movq	16(%rbp), %rsi
	movslq	(%rsi,%rax,4), %r8
	movq	0(%rbp), %rsi
	movsd	-8(%rdi,%r8,8), %xmm0
	mulsd	(%rsi,%rax,8), %xmm0
	incq	%rax
	addsd	(%rdx), %xmm0
	movsd	%xmm0, (%rdx)
	jmp	.L173
	.cfi_endproc
.LFE2035:
	.size	_Z17volume_constraintPPdS0_S_P4meshP6sparseS_, .-_Z17volume_constraintPPdS0_S_P4meshP6sparseS_
	.globl	_Z11free_sparseP6sparseS0_S0_S0_S0_S0_S0_S0_
	.type	_Z11free_sparseP6sparseS0_S0_S0_S0_S0_S0_S0_, @function
_Z11free_sparseP6sparseS0_S0_S0_S0_S0_S0_S0_:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r8, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r9, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	8(%rdi), %rdi
	movq	88(%rsp), %rax
	movq	80(%rsp), %rdx
	movq	%rax, 8(%rsp)
	movq	%rdx, (%rsp)
	call	free@PLT
	movq	16(%r14), %rdi
	call	free@PLT
	movq	(%r14), %rdi
	call	free@PLT
	movq	8(%r15), %rdi
	call	free@PLT
	movq	16(%r15), %rdi
	call	free@PLT
	movq	(%r15), %rdi
	call	free@PLT
	movq	8(%r13), %rdi
	call	free@PLT
	movq	16(%r13), %rdi
	call	free@PLT
	movq	0(%r13), %rdi
	call	free@PLT
	movq	8(%r12), %rdi
	call	free@PLT
	movq	16(%r12), %rdi
	call	free@PLT
	movq	(%r12), %rdi
	call	free@PLT
	movq	8(%rbp), %rdi
	call	free@PLT
	movq	16(%rbp), %rdi
	call	free@PLT
	movq	0(%rbp), %rdi
	call	free@PLT
	movq	8(%rbx), %rdi
	call	free@PLT
	movq	16(%rbx), %rdi
	call	free@PLT
	movq	(%rbx), %rdi
	call	free@PLT
	movq	(%rsp), %rdx
	movq	8(%rdx), %rdi
	call	free@PLT
	movq	(%rsp), %rdx
	movq	16(%rdx), %rdi
	call	free@PLT
	movq	(%rsp), %rdx
	movq	(%rdx), %rdi
	call	free@PLT
	movq	8(%rsp), %rax
	movq	8(%rax), %rdi
	movq	%rax, (%rsp)
	call	free@PLT
	movq	(%rsp), %rax
	movq	16(%rax), %rdi
	call	free@PLT
	movq	(%rsp), %rax
	movq	(%rax), %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2036:
	.size	_Z11free_sparseP6sparseS0_S0_S0_S0_S0_S0_S0_, .-_Z11free_sparseP6sparseS0_S0_S0_S0_S0_S0_S0_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2062:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2062:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	1413752350
	.long	1073291771
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	-1
	.long	2147483647
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC3:
	.long	-400107883
	.long	1041313291
	.align 8
.LC4:
	.long	0
	.long	1071644672
	.align 8
.LC5:
	.long	0
	.long	1072693248
	.section	.rodata.cst16
	.align 16
.LC6:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC7:
	.long	-755914244
	.long	1062232653
	.align 8
.LC8:
	.long	-858993459
	.long	1071434956
	.align 8
.LC9:
	.long	1202590843
	.long	1065646817
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#pragma once
#include <hip/hip_runtime.h>

#include "mesh.cuh"
#include "material.cuh"
#include "sparse_struc.cuh"

void compute_xphys(struct sparse *h, double *hs, double*x, double *xphys, struct mesh *mesh);
void compute_sk(double **sk, double *ke, double *xphys, struct mesh *mesh, struct material *material);
void compute_sm(double **sm, double *me, double *xphys, struct mesh *mesh, struct material *material);
void modify_m_k(struct sparse *mat, struct mesh *mesh, int *freedofs, int *fixeddofs);
void compute_s(struct sparse *k, struct sparse *m, struct sparse *s, struct mesh *mesh);
void g_matrix_init(int ndof, int nstate, struct sparse *a, struct sparse *b, struct sparse *c, double *dstato, struct sparse *e, struct sparse *k, struct sparse *m, struct sparse *s, int *freedofs, struct sparse *f);

void invforsens2(struct sparse *invu, struct sys *g, double h_inf_peak_frq);
void prosenshinf_2017(double *xphys, struct sparse *invu, int us, int vs, double h_inf_peak_frq, double *df0dx, double *me, double *ke, int *edofmat, struct mesh *mesh, struct material *material, int ntutto, int *freedofs, int *fixeddofs, struct sparse *bstato, struct sparse *cstato);
void filt_mod_sensitivities(struct mesh *mesh, double *x, double *df0dx, struct sparse *h, double *hs);
void volume_constraint(double **fval, double **dfdx, double *x, struct mesh *mesh, struct sparse *h, double *hs);

void free_sparse(struct sparse *a, struct sparse *b, struct sparse *c, struct sparse *e, struct sparse *k, struct sparse *m, struct sparse *s, struct sparse *invu);
	.text
	.file	"hinf_functions.hip"
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
