#include <stdlib.h>

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

//----------------------------------------------PROTOTIPES--------------------------------------
void create_noderns(int *noderns, struct mesh *mesh);
void create_edofvec(int *edofvec, int *noderns, struct mesh *mesh);
void create_repmat1(int *repmat, int *edofvec, struct mesh *mesh);
void create_repmat2(int *repmat, struct mesh *mesh);

//----------------------------------------------BODIES------------------------------------------
void edofmat_init(int **edofmat, struct mesh *mesh) {
	int *noderns,*edofvec,*repmat1,*repmat2;
	noderns = (int*)malloc((1 + mesh->nely)*(1 + mesh->nelx) * sizeof(int));
	edofvec = (int*)malloc((mesh->nely)*(mesh->nelx) * sizeof(int));
	repmat1 = (int*)malloc((mesh->nely)*(mesh->nelx) * EDOFMAT_COL * sizeof(int));
	repmat2 = (int*)malloc((mesh->nely)*(mesh->nelx) * EDOFMAT_COL * sizeof(int));
	(*edofmat) = (int*)malloc(mesh->nelx * mesh->nely * EDOFMAT_COL * sizeof(int));
	
	create_noderns(noderns, mesh);
	create_edofvec(edofvec, noderns, mesh);
	create_repmat1(repmat1, edofvec, mesh);
	create_repmat2(repmat2, mesh);

	matrix_sum(repmat1, repmat2, (*edofmat), mesh->nelx*mesh->nely, 8);	//edofMat = repmat(edofVec, 1, 8) + repmat([0 1 2 * nely + [2 3 0 1] - 2 - 1], nelx*nely, 1);

	free(noderns);
	free(edofvec);
	free(repmat1);
	free(repmat2);
}


void create_noderns(int *noderns, struct mesh *mesh) {		//nodenrs = reshape(1:(1+nelx)*(1+nely),1+nely,1+nelx);
	int count=1;
	for (int col_index = 0;col_index < (1+mesh->nelx);col_index++) {
		for (int row_index = 0;row_index <(1+mesh->nely);row_index++) {
			noderns[col_index + (1 + mesh->nelx)*row_index] = count;
			count++;
		}
	}
}

void create_edofvec(int *edofvec, int *noderns, struct mesh *mesh) {	//edofVec = reshape(2*nodenrs(1:end-1,1:end-1)+1,nelx*nely,1);
	int value;
	int edofvec_index=0;
	for (int col_index = 0;col_index <  mesh->nelx; col_index++) {
		for (int row_index = 0;row_index <mesh->nely;row_index++) {
			value = (noderns[col_index + (1 + mesh->nelx)*row_index]*2) + 1;
			edofvec[edofvec_index]=value;
			edofvec_index++;
		}
	}
}

void create_repmat1(int *repmat, int *edofvec, struct mesh *mesh) {		//repmat(edofVec,1,8)
	int mat_index,edofvec_index=0;
	for (int col_index = 0;col_index < 8; col_index++) {
		for (int row_index = 0;row_index <mesh->nely*mesh->nelx;row_index++) {
			mat_index = col_index + (row_index * 8);
			repmat[mat_index] = edofvec[edofvec_index];
			edofvec_index++;
		}
		edofvec_index = 0;
	}
}

void create_repmat2(int *repmat, struct mesh *mesh) {	//repmat([0 1 2*nely+[2 3 0 1] -2 -1],nelx*nely,1)
	int mat_index, vec_index = 0;
	int *vec;
	
	vec = (int*)malloc(8 * sizeof(int));
	
	vec[0] = 0;
	vec[1] = 1;
	vec[2] = 2 * mesh->nely + 2;
	vec[3] = 2 * mesh->nely + 3;
	vec[4] = 2 * mesh->nely + 0;
	vec[5] = 2 * mesh->nely + 1;
	vec[6] = -2;
	vec[7] = -1;

	for (int row_index = 0; row_index < mesh->nelx*mesh->nely; row_index++) {
		for (int col_index = 0; col_index < 8; col_index++) {
			mat_index = row_index * 8 + col_index;
			repmat[mat_index] = vec[vec_index];
			vec_index++;
		}
		vec_index = 0;
	}

	free(vec);
}
	.file	"tmpxft_00334655_00000000-6_edofmat_init.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2015:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2015:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z14create_nodernsPiP4mesh
	.type	_Z14create_nodernsPiP4mesh, @function
_Z14create_nodernsPiP4mesh:
.LFB2009:
	.cfi_startproc
	endbr64
	xorl	%ecx, %ecx
	movl	$1, %r8d
.L3:
	cmpl	%ecx, 24(%rsi)
	jl	.L8
	xorl	%edx, %edx
.L5:
	movl	24(%rsi), %eax
	leal	(%r8,%rdx), %r9d
	cmpl	%edx, 28(%rsi)
	jl	.L9
	incl	%eax
	imull	%edx, %eax
	incl	%edx
	addl	%ecx, %eax
	cltq
	movl	%r9d, (%rdi,%rax,4)
	jmp	.L5
.L9:
	incl	%ecx
	movl	%r9d, %r8d
	jmp	.L3
.L8:
	ret
	.cfi_endproc
.LFE2009:
	.size	_Z14create_nodernsPiP4mesh, .-_Z14create_nodernsPiP4mesh
	.globl	_Z14create_edofvecPiS_P4mesh
	.type	_Z14create_edofvecPiS_P4mesh, @function
_Z14create_edofvecPiS_P4mesh:
.LFB2010:
	.cfi_startproc
	endbr64
	movq	%rdi, %r8
	movq	%rsi, %r9
	xorl	%edi, %edi
	xorl	%ecx, %ecx
.L11:
	cmpl	%edi, 24(%rdx)
	jle	.L10
	movslq	%ecx, %rcx
	xorl	%esi, %esi
.L14:
	movl	24(%rdx), %eax
	leaq	1(%rcx), %r10
	cmpl	%esi, 28(%rdx)
	jle	.L15
	incl	%eax
	movq	%r10, %rcx
	imull	%esi, %eax
	incl	%esi
	addl	%edi, %eax
	cltq
	movl	(%r9,%rax,4), %eax
	leal	1(%rax,%rax), %eax
	movl	%eax, -4(%r8,%r10,4)
	jmp	.L14
.L15:
	incl	%edi
	jmp	.L11
.L10:
	ret
	.cfi_endproc
.LFE2010:
	.size	_Z14create_edofvecPiS_P4mesh, .-_Z14create_edofvecPiS_P4mesh
	.globl	_Z14create_repmat1PiS_P4mesh
	.type	_Z14create_repmat1PiS_P4mesh, @function
_Z14create_repmat1PiS_P4mesh:
.LFB2011:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
.L17:
	movq	%rdi, %rcx
	xorl	%eax, %eax
.L20:
	movl	28(%rdx), %r9d
	imull	24(%rdx), %r9d
	cmpl	%eax, %r9d
	jle	.L21
	movl	(%rsi,%rax,4), %r9d
	addq	$32, %rcx
	incq	%rax
	movl	%r9d, -32(%rcx)
	jmp	.L20
.L21:
	incl	%r8d
	addq	$4, %rdi
	cmpl	$8, %r8d
	jne	.L17
	ret
	.cfi_endproc
.LFE2011:
	.size	_Z14create_repmat1PiS_P4mesh, .-_Z14create_repmat1PiS_P4mesh
	.globl	_Z14create_repmat2PiP4mesh
	.type	_Z14create_repmat2PiP4mesh, @function
_Z14create_repmat2PiP4mesh:
.LFB2012:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$32, %edi
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movq	%rax, %rdi
	movl	$1, %eax
	salq	$32, %rax
	movq	$-2, 24(%rdi)
	movq	%rax, (%rdi)
	movl	28(%rbp), %eax
	leal	2(%rax,%rax), %eax
	leal	1(%rax), %edx
	movl	%eax, 8(%rdi)
	movl	%edx, 12(%rdi)
	leal	-2(%rax), %edx
	decl	%eax
	movl	%edx, 16(%rdi)
	xorl	%edx, %edx
	movl	%eax, 20(%rdi)
	movq	%rbx, %rax
.L23:
	movl	24(%rbp), %ecx
	imull	28(%rbp), %ecx
	cmpl	%edx, %ecx
	jle	.L26
	movups	(%rdi), %xmm0
	incl	%edx
	addq	$32, %rax
	movups	%xmm0, -32(%rax)
	movups	16(%rdi), %xmm1
	movups	%xmm1, -16(%rax)
	jmp	.L23
.L26:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE2012:
	.size	_Z14create_repmat2PiP4mesh, .-_Z14create_repmat2PiP4mesh
	.globl	_Z12edofmat_initPPiP4mesh
	.type	_Z12edofmat_initPPiP4mesh, @function
_Z12edofmat_initPPiP4mesh:
.LFB2008:
	.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	%rdi, %r13
	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	%rsi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	24(%rsi), %ebp
	movl	28(%rsi), %r12d
	leal	1(%rbp), %eax
	leal	1(%r12), %edi
	imull	%eax, %edi
	imull	%ebp, %r12d
	movslq	%edi, %rdi
	salq	$2, %rdi
	leal	0(,%r12,8), %ebp
	call	malloc@PLT
	movslq	%ebp, %rbp
	movslq	%r12d, %rdi
	salq	$2, %rbp
	salq	$2, %rdi
	movq	%rax, %r15
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r14
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rbx, %rsi
	movq	%r15, %rdi
	movq	%rax, 0(%r13)
	movq	%rax, %rbp
	call	_Z14create_nodernsPiP4mesh
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movq	%r14, %rdi
	call	_Z14create_edofvecPiS_P4mesh
	movq	(%rsp), %rdi
	movq	%r14, %rsi
	call	_Z14create_repmat1PiS_P4mesh
	movq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	_Z14create_repmat2PiP4mesh
	movq	8(%rsp), %rsi
	movl	%r12d, %ecx
	movq	%rbp, %rdx
	movq	(%rsp), %rdi
	movl	$8, %r8d
	call	_Z10matrix_sumPiS_S_ii@PLT
	movq	%r15, %rdi
	call	free@PLT
	movq	%r14, %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
.LFE2008:
	.size	_Z12edofmat_initPPiP4mesh, .-_Z12edofmat_initPPiP4mesh
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2038:
	.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
.LFE2038:
	.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
	.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:


#include <hip/hip_runtime.h>
#include <stdlib.h>

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

//----------------------------------------------PROTOTIPES--------------------------------------
void create_noderns(int *noderns, struct mesh *mesh);
void create_edofvec(int *edofvec, int *noderns, struct mesh *mesh);
void create_repmat1(int *repmat, int *edofvec, struct mesh *mesh);
void create_repmat2(int *repmat, struct mesh *mesh);

//----------------------------------------------BODIES------------------------------------------
void edofmat_init(int **edofmat, struct mesh *mesh) {
	int *noderns,*edofvec,*repmat1,*repmat2;
	noderns = (int*)malloc((1 + mesh->nely)*(1 + mesh->nelx) * sizeof(int));
	edofvec = (int*)malloc((mesh->nely)*(mesh->nelx) * sizeof(int));
	repmat1 = (int*)malloc((mesh->nely)*(mesh->nelx) * EDOFMAT_COL * sizeof(int));
	repmat2 = (int*)malloc((mesh->nely)*(mesh->nelx) * EDOFMAT_COL * sizeof(int));
	(*edofmat) = (int*)malloc(mesh->nelx * mesh->nely * EDOFMAT_COL * sizeof(int));
	
	create_noderns(noderns, mesh);
	create_edofvec(edofvec, noderns, mesh);
	create_repmat1(repmat1, edofvec, mesh);
	create_repmat2(repmat2, mesh);

	matrix_sum(repmat1, repmat2, (*edofmat), mesh->nelx*mesh->nely, 8);	//edofMat = repmat(edofVec, 1, 8) + repmat([0 1 2 * nely + [2 3 0 1] - 2 - 1], nelx*nely, 1);

	free(noderns);
	free(edofvec);
	free(repmat1);
	free(repmat2);
}


void create_noderns(int *noderns, struct mesh *mesh) {		//nodenrs = reshape(1:(1+nelx)*(1+nely),1+nely,1+nelx);
	int count=1;
	for (int col_index = 0;col_index < (1+mesh->nelx);col_index++) {
		for (int row_index = 0;row_index <(1+mesh->nely);row_index++) {
			noderns[col_index + (1 + mesh->nelx)*row_index] = count;
			count++;
		}
	}
}

void create_edofvec(int *edofvec, int *noderns, struct mesh *mesh) {	//edofVec = reshape(2*nodenrs(1:end-1,1:end-1)+1,nelx*nely,1);
	int value;
	int edofvec_index=0;
	for (int col_index = 0;col_index <  mesh->nelx; col_index++) {
		for (int row_index = 0;row_index <mesh->nely;row_index++) {
			value = (noderns[col_index + (1 + mesh->nelx)*row_index]*2) + 1;
			edofvec[edofvec_index]=value;
			edofvec_index++;
		}
	}
}

void create_repmat1(int *repmat, int *edofvec, struct mesh *mesh) {		//repmat(edofVec,1,8)
	int mat_index,edofvec_index=0;
	for (int col_index = 0;col_index < 8; col_index++) {
		for (int row_index = 0;row_index <mesh->nely*mesh->nelx;row_index++) {
			mat_index = col_index + (row_index * 8);
			repmat[mat_index] = edofvec[edofvec_index];
			edofvec_index++;
		}
		edofvec_index = 0;
	}
}

void create_repmat2(int *repmat, struct mesh *mesh) {	//repmat([0 1 2*nely+[2 3 0 1] -2 -1],nelx*nely,1)
	int mat_index, vec_index = 0;
	int *vec;
	
	vec = (int*)malloc(8 * sizeof(int));
	
	vec[0] = 0;
	vec[1] = 1;
	vec[2] = 2 * mesh->nely + 2;
	vec[3] = 2 * mesh->nely + 3;
	vec[4] = 2 * mesh->nely + 0;
	vec[5] = 2 * mesh->nely + 1;
	vec[6] = -2;
	vec[7] = -1;

	for (int row_index = 0; row_index < mesh->nelx*mesh->nely; row_index++) {
		for (int col_index = 0; col_index < 8; col_index++) {
			mat_index = row_index * 8 + col_index;
			repmat[mat_index] = vec[vec_index];
			vec_index++;
		}
		vec_index = 0;
	}

	free(vec);
}
	.text
	.file	"edofmat_init.hip"
	.globl	_Z12edofmat_initPPiP4mesh       # -- Begin function _Z12edofmat_initPPiP4mesh
	.type	_Z12edofmat_initPPiP4mesh,@function
_Z12edofmat_initPPiP4mesh:              # @_Z12edofmat_initPPiP4mesh
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	movl	24(%rsi), %r15d
	movl	28(%rsi), %r14d
	leal	1(%r14), %eax
	leal	1(%r15), %ecx
	imull	%eax, %ecx
	movslq	%ecx, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %rbp
	imull	%r14d, %r15d
	movslq	%r15d, %r13
	leaq	(,%r13,4), %rdi
	callq	malloc
	movq	%rax, %r12
	leal	(,%r13,8), %eax
	movslq	%eax, %r14
	shlq	$2, %r14
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	%r14, %rdi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	movq	16(%rsp), %r14                  # 8-byte Reload
	callq	malloc
	movq	%rax, (%r14)
	movq	%rbp, %rdi
	movq	%rbx, %rsi
	callq	_Z14create_nodernsPiP4mesh
	movq	%r12, %rdi
	movq	%rbp, 32(%rsp)                  # 8-byte Spill
	movq	%rbp, %rsi
	movq	%rbx, %rdx
	callq	_Z14create_edofvecPiS_P4mesh
	cmpq	$2, %r13
	movl	$1, %eax
	cmovgeq	%r13, %rax
	movq	8(%rsp), %r13                   # 8-byte Reload
	shlq	$2, %rax
	xorl	%ecx, %ecx
	movq	%r13, %rdx
.LBB0_1:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	testl	%r15d, %r15d
	jle	.LBB0_4
# %bb.2:                                # %.lr.ph.preheader.i
                                        #   in Loop: Header=BB0_1 Depth=1
	xorl	%esi, %esi
.LBB0_3:                                # %.lr.ph.i
                                        #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%r12,%rsi), %edi
	movl	%edi, (%rdx,%rsi,8)
	addq	$4, %rsi
	cmpq	%rsi, %rax
	jne	.LBB0_3
.LBB0_4:                                # %._crit_edge.i
                                        #   in Loop: Header=BB0_1 Depth=1
	incq	%rcx
	addq	$4, %rdx
	cmpq	$8, %rcx
	jne	.LBB0_1
# %bb.5:                                # %_Z14create_repmat1PiS_P4mesh.exit
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_Z14create_repmat2PiP4mesh
	movq	(%r14), %rdx
	movl	28(%rbx), %ecx
	imull	24(%rbx), %ecx
	movq	%r13, %rdi
	movq	%r15, %rsi
	movl	$8, %r8d
	callq	_Z10matrix_sumPiS_S_ii
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r12, %rdi
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	%r15, %rdi
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end0:
	.size	_Z12edofmat_initPPiP4mesh, .Lfunc_end0-_Z12edofmat_initPPiP4mesh
	.cfi_endproc
                                        # -- End function
	.globl	_Z14create_nodernsPiP4mesh      # -- Begin function _Z14create_nodernsPiP4mesh
	.type	_Z14create_nodernsPiP4mesh,@function
_Z14create_nodernsPiP4mesh:             # @_Z14create_nodernsPiP4mesh
	.cfi_startproc
# %bb.0:
	movl	24(%rsi), %r8d
	testl	%r8d, %r8d
	js	.LBB1_7
# %bb.1:                                # %.preheader.lr.ph
	movl	28(%rsi), %edx
	movl	$1, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	testl	%edx, %edx
	js	.LBB1_6
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB1_2 Depth=1
	xorl	%r9d, %r9d
.LBB1_4:                                # %.lr.ph
                                        #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r9d, %r8d
	leal	(%rax,%r8), %edx
	movl	24(%rsi), %r9d
	incl	%r9d
	imull	%r8d, %r9d
	addl	%ecx, %r9d
	movslq	%r9d, %r9
	movl	%edx, (%rdi,%r9,4)
	leal	1(%r8), %r9d
	movl	28(%rsi), %edx
	cmpl	%edx, %r8d
	jl	.LBB1_4
# %bb.5:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB1_2 Depth=1
	movl	24(%rsi), %r8d
	addl	%r9d, %eax
.LBB1_6:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	leal	1(%rcx), %r9d
	cmpl	%r8d, %ecx
	movl	%r9d, %ecx
	jl	.LBB1_2
.LBB1_7:                                # %._crit_edge20
	retq
.Lfunc_end1:
	.size	_Z14create_nodernsPiP4mesh, .Lfunc_end1-_Z14create_nodernsPiP4mesh
	.cfi_endproc
                                        # -- End function
	.globl	_Z14create_edofvecPiS_P4mesh    # -- Begin function _Z14create_edofvecPiS_P4mesh
	.type	_Z14create_edofvecPiS_P4mesh,@function
_Z14create_edofvecPiS_P4mesh:           # @_Z14create_edofvecPiS_P4mesh
	.cfi_startproc
# %bb.0:
	movl	24(%rdx), %r9d
	testl	%r9d, %r9d
	jle	.LBB2_7
# %bb.1:                                # %.preheader.lr.ph
	movl	28(%rdx), %r8d
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB2_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_4 Depth 2
	testl	%r8d, %r8d
	jle	.LBB2_6
# %bb.3:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_2 Depth=1
	movslq	%ecx, %r8
	leaq	(%rdi,%r8,4), %r10
	xorl	%r9d, %r9d
.LBB2_4:                                # %.lr.ph
                                        #   Parent Loop BB2_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	24(%rdx), %r8d
	incl	%r8d
	movl	%r9d, %r11d
	imull	%r8d, %r11d
	addl	%eax, %r11d
	movslq	%r11d, %r8
	movl	(%rsi,%r8,4), %r8d
	leal	1(,%r8,2), %r8d
	movl	%r8d, (%r10,%r9,4)
	movl	28(%rdx), %r8d
	incq	%r9
	cmpl	%r8d, %r9d
	jl	.LBB2_4
# %bb.5:                                # %._crit_edge.loopexit
                                        #   in Loop: Header=BB2_2 Depth=1
	addl	%r9d, %ecx
	movl	24(%rdx), %r9d
.LBB2_6:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=1
	incl	%eax
	cmpl	%r9d, %eax
	jl	.LBB2_2
.LBB2_7:                                # %._crit_edge19
	retq
.Lfunc_end2:
	.size	_Z14create_edofvecPiS_P4mesh, .Lfunc_end2-_Z14create_edofvecPiS_P4mesh
	.cfi_endproc
                                        # -- End function
	.globl	_Z14create_repmat1PiS_P4mesh    # -- Begin function _Z14create_repmat1PiS_P4mesh
	.type	_Z14create_repmat1PiS_P4mesh,@function
_Z14create_repmat1PiS_P4mesh:           # @_Z14create_repmat1PiS_P4mesh
	.cfi_startproc
# %bb.0:
	movl	24(%rdx), %ecx
	movl	28(%rdx), %r8d
	xorl	%eax, %eax
.LBB3_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_3 Depth 2
	movl	%ecx, %r9d
	imull	%r8d, %r9d
	testl	%r9d, %r9d
	jle	.LBB3_4
# %bb.2:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB3_1 Depth=1
	movq	%rdi, %r9
	xorl	%r10d, %r10d
.LBB3_3:                                # %.lr.ph
                                        #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rsi,%r10,4), %ecx
	movl	%ecx, (%r9)
	incq	%r10
	movl	24(%rdx), %ecx
	movl	28(%rdx), %r8d
	movl	%ecx, %r11d
	imull	%r8d, %r11d
	movslq	%r11d, %r11
	addq	$32, %r9
	cmpq	%r11, %r10
	jl	.LBB3_3
.LBB3_4:                                # %._crit_edge
                                        #   in Loop: Header=BB3_1 Depth=1
	incq	%rax
	addq	$4, %rdi
	cmpq	$8, %rax
	jne	.LBB3_1
# %bb.5:
	retq
.Lfunc_end3:
	.size	_Z14create_repmat1PiS_P4mesh, .Lfunc_end3-_Z14create_repmat1PiS_P4mesh
	.cfi_endproc
                                        # -- End function
	.globl	_Z14create_repmat2PiP4mesh      # -- Begin function _Z14create_repmat2PiP4mesh
	.type	_Z14create_repmat2PiP4mesh,@function
_Z14create_repmat2PiP4mesh:             # @_Z14create_repmat2PiP4mesh
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$32, %edi
	callq	malloc
	movabsq	$4294967296, %rcx               # imm = 0x100000000
	movq	%rcx, (%rax)
	movl	28(%rbx), %ecx
	leal	(%rcx,%rcx), %edx
	leal	2(%rcx,%rcx), %esi
	movl	%esi, 8(%rax)
	leal	3(%rcx,%rcx), %esi
	movl	%esi, 12(%rax)
	movl	%edx, 16(%rax)
	leal	1(,%rcx,2), %edx
	movl	%edx, 20(%rax)
	movq	$-2, 24(%rax)
	imull	24(%rbx), %ecx
	testl	%ecx, %ecx
	jle	.LBB4_3
# %bb.1:                                # %.preheader.preheader
	xorl	%ecx, %ecx
.LBB4_2:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movups	(%rax), %xmm0
	movups	16(%rax), %xmm1
	movups	%xmm1, 16(%r14)
	movups	%xmm0, (%r14)
	movl	28(%rbx), %edx
	imull	24(%rbx), %edx
	addq	$32, %r14
	incl	%ecx
	cmpl	%ecx, %edx
	jg	.LBB4_2
.LBB4_3:                                # %._crit_edge
	movq	%rax, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	free                            # TAILCALL
.Lfunc_end4:
	.size	_Z14create_repmat2PiP4mesh, .Lfunc_end4-_Z14create_repmat2PiP4mesh
	.cfi_endproc
                                        # -- End function
	.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
