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


  double sourcef(double xval)
    {
        //source function for exact solution = (1-x)e^(-x^2)
         double yval;
         yval=-(2*xval-2*(1-2*xval)+4*xval*(xval-pow(xval,2)))*exp(-xval*xval);

        return yval;
    }


int main(int argc, char **argv)

 {
//number of subintervals
    const int nel=4,mz=3;

    int glodim,je,ie;
    double ss,penal;
    double Amat[3][3],Bmat[3][3],Cmat[3][3],Dmat[3][3],Emat[3][3],F0mat[3][3],FNmat[3][3];

FILE *f = fopen("Matrix.txt", "w");
FILE *g = fopen("rhs.txt", "w");
if (f == NULL)
{
    printf("Error opening file!\n");
    exit(1);
}
if (g == NULL)
{
    printf("Error opening file!\n");
    exit(1);
}
//symmetric interior penaltyGalerking (SIPG) method   
//    ss=-1;
//    penal=-1;

//global element method
//    ss=0;
//    penal=-1;

//nonsymmetric interior penalty Galerkin (NIPG) method
    ss=1.0;
    penal=1.0;

//NIPG 0 method
//    ss=0;
//    penal=1;

//dimension of global matrix
glodim = nel * mz;

double Aglobal[glodim][glodim];
double rhsglobal[glodim];

    for(int j=0;j<glodim;j++)
    {  
       for(int i=0;i<glodim;i++)
        {
           Aglobal[i][j]=0.0;
        }
    }

    for(int i=0;i<glodim;i++)
        {
           rhsglobal[i]=0.0;
        }


    Amat[0][0]=0.0;
    Amat[0][1]=0.0;
    Amat[0][2]=0.0;
    Amat[1][0]=0.0;
    Amat[1][1]=4.0;
    Amat[1][2]=0.0;
    Amat[2][0]=0.0;
    Amat[2][1]=0.0;
    Amat[2][2]=(16.0/3.0);
    
    for(int j=0;j<mz;j++)
    {  
      //  printf("\n");
        for(int i=0;i<mz;i++)
        {
            Amat[i][j]=nel*Amat[i][j];
     //       printf(" %f ",Amat[i][j]);
        }
    }
    
   //  printf("\n");

    Bmat[0][0]=penal;
    Bmat[0][1]=1.0-penal;
    Bmat[0][2]=-2.0+penal;
    Bmat[1][0]=-ss-penal;
    Bmat[1][1]=-1.0+ss+penal;
    Bmat[1][2]=2.0-ss-penal;
    Bmat[2][0]=2.0*ss+penal;
    Bmat[2][1]=1.0-2.0*ss-penal;
    Bmat[2][2]=-2.0+2.0*ss+penal;


    for(int i=0;i<mz;i++)
    {  
     //   printf("\n");
        for(int j=0;j<mz;j++)
        {
            Bmat[i][j]=nel*Bmat[i][j];
      //      printf(" %f ",Bmat[i][j]);
        }
    }

    // printf("\n");

    Cmat[0][0]=penal;
    Cmat[0][1]=-1+penal;
    Cmat[0][2]=-2+penal;
    Cmat[1][0]=ss+penal;
    Cmat[1][1]=-1+ss+penal;
    Cmat[1][2]=-2+ss+penal;
    Cmat[2][0]=2*ss+penal;
    Cmat[2][1]=-1+2*ss+penal;
    Cmat[2][2]=-2+2*ss+penal;


    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            Cmat[i][j]=nel*Cmat[i][j];
     //       printf(" %f ",Cmat[i][j]);
 
        }
    }

   // printf("\n");

    Dmat[0][0]=-penal;
    Dmat[0][1]=-1+penal;
    Dmat[0][2]=2-penal;
    Dmat[1][0]=-ss-penal;
    Dmat[1][1]=-1+ss+penal;
    Dmat[1][2]=2-ss-penal;
    Dmat[2][0]=-2*ss-penal;
    Dmat[2][1]=-1+2*ss+penal;
    Dmat[2][2]=2-2*ss-penal;

    for(int i=0;i<mz;i++)
    {  
//	printf("\n");
        for(int j=0;j<mz;j++)
        {
            Dmat[i][j]=nel*Dmat[i][j];
  //          printf(" %f ",Dmat[i][j]);    
        }
    }

  //  printf("\n");

    Emat[0][0]=-penal;
    Emat[0][1]=1-penal;
    Emat[0][2]=2-penal;
    Emat[1][0]=ss+penal;
    Emat[1][1]=-1+ss+penal;
    Emat[1][2]=-2+ss+penal;
    Emat[2][0]=-2*ss-penal;
    Emat[2][1]=1-2*ss-penal;
    Emat[2][2]=2-2*ss-penal;

    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            Emat[i][j]=nel*Emat[i][j];
        //    printf(" %f ",Emat[i][j]);
        }
    }

   // printf("\n");

    F0mat[0][0]=penal;
    F0mat[0][1]=2-penal;
    F0mat[0][2]=-4+penal;
    F0mat[1][0]=-2*ss-penal;
    F0mat[1][1]=-2+2*ss+penal;
    F0mat[1][2]=4-2*ss-penal;
    F0mat[2][0]=4*ss+penal;
    F0mat[2][1]=2-4*ss-penal;
    F0mat[2][2]=-4+4*ss+penal;
  
    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            F0mat[i][j]=nel*F0mat[i][j];
        //    printf(" %f ",F0mat[i][j]);
        }
    }

    // printf("\n");

    FNmat[0][0]=penal;
    FNmat[0][1]=-2+penal;
    FNmat[0][2]=-4+penal;
    FNmat[1][0]=2*ss+penal;
    FNmat[1][1]=-2+2*ss+penal;
    FNmat[1][2]=-4+2*ss+penal;
    FNmat[2][0]=4*ss+penal;
    FNmat[2][1]=-2+4*ss+penal;
    FNmat[2][2]=-4+4*ss+penal;

    for(int i=0;i<mz;i++)
    {  
       // printf("\n");  
        for(int j=0;j<mz;j++)
        {
            FNmat[i][j]=nel*FNmat[i][j];
          //  printf(" %f ",FNmat[i][j]);
        }
    }

   // printf("\n");
//Gauss quadrature weights and points
    double wg[2],sg[2];
    wg[0] = 1.0;
    wg[1] = 1.0;
    sg[0] = -0.577350269189;
    sg[1] = 0.577350269189;

    //first block row
    for(int ii=0;ii<mz;ii++)
    {
        for (int jj=0;jj<mz;jj++)
        {           
//            printf("\n");
           // printf(" %d, %d ",ii,jj);
            Aglobal[ii][jj]=Aglobal[ii][jj]+Amat[ii][jj]+F0mat[ii][jj]+Cmat[ii][jj];
            je=mz+jj; 
  
           // printf(" %d, %d ",ii,je);
            Aglobal[ii][je]=Aglobal[ii][je]+Dmat[ii][jj];
        }
    }





/*
    for(int ii=0;ii<mz;ii++)
    {
        printf("\n");
        for (int jj=0;jj<mz;jj++)
        {
           
            printf(" %f ", Aglobal[ii][jj]);
        }
    }
*/

//compute right-hand side
    rhsglobal[0]=nel*penal;
    rhsglobal[1]=nel*penal*(-1.0)-ss*2.0*nel;
    rhsglobal[2]=nel*penal+ss*4*nel;

    for(int ig=0;ig<2;ig++)
    {
        rhsglobal[0]=rhsglobal[0]+wg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        rhsglobal[1]=rhsglobal[1]+wg[ig]*sg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        rhsglobal[2]=rhsglobal[2]+wg[ig]*sg[ig]*sg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        
    }
//printf(" %d %f ",3 , rhsglobal[3]);
// for (int jj=0;jj<mz;jj++)
//        {
//            printf(" %f ", rhsglobal[jj]);
//        }

//intermediate block rows
//loop over elements
    for (int i=1;i<nel-1;i++)
    {
        for(int ii=0;ii<mz;ii++)
        {   
            ie=ii+(i)*mz;
//            printf(" %d \n",ie);
            for(int jj=0;jj<mz;jj++)
	    {
		//je=jj+(i-1)*mz;
                je=jj+(i)*mz;
      //          printf("i= %d ,j= %d\n ",ie, je);
		Aglobal[ie][je]=Aglobal[ie][je]+Amat[ii][jj]+Bmat[ii][jj]+Cmat[ii][jj];

                //printf(" %d, %f ",je, Aglobal[ie][je]);
		//je=jj+(i-2)*mz;
		je=jj+(i-1)*mz;
    //            printf("i= %d ,j= %d \n",ie, je);
                Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
		//je=jj+(i)*mz;

		je=jj+(i+1)*mz;
//                printf(" %d , %d, %d, %d, %d ",ie, je, jj,i,mz);
//                printf("i= %d ,j= %d \n",ie, je);  
                Aglobal[ie][je]=Aglobal[ie][je]+Dmat[ii][jj];
  //              printf("\n\n");
             //   printf(" %d , %d ,%f ",ie, je, Aglobal[ie][je]);
	    }

//compute right-hand side
            for(int ig=0;ig<2;ig++)
            {   
                
                double a=pow(sg[ig],ii);
               // printf("ig=%d sg[ig]=%f ii=%d a=%f",ig, sg[ig],ii+1,a);
                double b=sourcef((sg[ig]+2*(i)+1.0)/(2*nel))/(2*nel);
             // printf("ig=%d, sg[ig]= %f,i= %d nel=%d, 2*nel= %d, b= %f",ig,sg[ig],i,nel,2*nel,b);
                rhsglobal[ie]=rhsglobal[ie]+wg[ig]*a*b;            
              //  rhsglobal[ie]=rhsglobal[ie]+wg[ig]*(pow(sg[ig],(ii-1)))*sourcef((sg[ig]+2*(i-1)+1.0)/(2*nel))/(2*nel);
//                printf("\n");
//                printf("ie=%d, ii=%d, wg[ig]=%f, sg[ig]=%f, a=%f,b=%f, rhsglobal[ie]=%f",ie ,ii, wg[ig],sg[ig], a,b, rhsglobal[ie]);
            }
        }       
    }

//printf("s=%f",sourcef(1.0));

   //  printf("\n");

//last block row
//printf("Last block");
    for(int ii=0;ii<mz;ii++)
    {
        ie=ii+(nel-1)*mz;
        for(int jj=0;jj<mz;jj++)
        {
  //          printf("\n\n");
            je=jj+(nel-1)*mz;
//            printf("i= %d ,j= %d \n",ie, je);
//            if((ie==11)&&(je==11))
//            {
//                printf("ie=%d, je=%d, Aglobal=%f, ii=%d,jj=%d, Amat=%f, FNmat=%f, Bmat=%f",ie, je, Aglobal[ie][je],ii,jj,Amat[ii][jj],FNmat[ii][jj],Bmat[ii][jj]); 
//            }
            Aglobal[ie][je]=Aglobal[ie][je]+Amat[ii][jj]+FNmat[ii][jj]+Bmat[ii][jj];
            je=jj+(nel-2)*mz;
//            printf("i= %d ,j= %d \n",ie, je);
            Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
            //printf("%f", Aglobal[ie][je]);  

      }
        for(int ig=0;ig<2;ig++)
        {
     //    printf("\n");
         double c=(pow(sg[ig],(ii)));
         double d=sourcef((sg[ig]+2*(nel-1)+1.0)/(2*nel))/(2.0*nel); 
        // printf("ig=%d, sg= %f, ii= %d, c=%f, d=%f",ig,sg[ig],ii,c,d); 
         rhsglobal[ie]=rhsglobal[ie]+wg[ig]*c*d;
         //printf("%d, %f, %f, %f \n ",ie,c,d,rhsglobal[ie]);
  //       printf("\n");
        }
    }

/*
for(int ii=0;ii<mz;ii++)
  {
        ie=ii+(nel-1)*mz;
        for(int jj=0;jj<mz;jj++)
        {
            je=jj+(nel-2)*mz;
            Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
        }
    }
*/


//printf("Aglobal[11][11]=%f",Aglobal[11][11]);


    for(int i=0;i<glodim;i++)
       {
        fprintf(f,"\n");
        for(int j=0;j<glodim;j++)
            {
             fprintf(f," %f ",Aglobal[i][j]);
            }
       }

//fprintf(f, "Integer: %d, float: %f\n", i, py);

for(int i=0;i<glodim;i++)
    {
         fprintf(g," %f \n",rhsglobal[i]);
    }




    return 0;
}

  



	.file	"tmpxft_00349a9b_00000000-6_elliptic3.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7sourcefd
	.type	_Z7sourcefd, @function
_Z7sourcefd:
.LFB2027:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm4
	movaps	%xmm0, %xmm1
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	.LC0(%rip), %xmm3
	mulsd	%xmm0, %xmm4
	addsd	%xmm0, %xmm1
	movsd	%xmm0, 16(%rsp)
	movsd	%xmm1, 24(%rsp)
	movaps	%xmm4, %xmm0
	movsd	%xmm4, 8(%rsp)
	xorps	%xmm3, %xmm0
	call	exp@PLT
	movsd	24(%rsp), %xmm1
	movsd	16(%rsp), %xmm2
	movaps	%xmm0, %xmm5
	movsd	.LC1(%rip), %xmm0
	movsd	8(%rsp), %xmm4
	movq	.LC0(%rip), %xmm3
	subsd	%xmm1, %xmm0
	addsd	%xmm0, %xmm0
	subsd	%xmm0, %xmm1
	movsd	.LC2(%rip), %xmm0
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	mulsd	%xmm2, %xmm0
	subsd	%xmm4, %xmm2
	mulsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm3, %xmm0
	mulsd	%xmm5, %xmm0
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z7sourcefd, .-_Z7sourcefd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"w"
.LC4:
	.string	"Matrix.txt"
.LC5:
	.string	"rhs.txt"
.LC6:
	.string	"Error opening file!\n"
.LC21:
	.string	"\n"
.LC22:
	.string	" %f "
.LC23:
	.string	" %f \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC4(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	leaq	.LC3(%rip), %rbx
	movq	%rbx, %rsi
	subq	$744, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC5(%rip), %rdi
	movq	%rax, -704(%rbp)
	call	fopen@PLT
	cmpq	$0, -704(%rbp)
	movq	%rax, -712(%rbp)
	jne	.L5
.L6:
	movl	$2, %edi
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L5:
	cmpq	$0, -712(%rbp)
	je	.L6
	movq	%rsp, %rax
.L7:
	cmpq	%rax, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L8:
	subq	$1152, %rsp
	orq	$0, 1144(%rsp)
	movq	%rsp, %rbx
	movq	%rbx, %r12
	leaq	96(%rbx), %rsi
	movq	%rbx, %rdx
.L10:
	movq	%rdx, %rcx
	movl	$12, %eax
.L11:
	movq	$0x000000000, (%rcx)
	addq	$96, %rcx
	decl	%eax
	jne	.L11
	addq	$8, %rdx
	cmpq	%rsi, %rdx
	jne	.L10
	leaq	-128(%rbp), %rdx
	movl	$18, %ecx
	movsd	.LC2(%rip), %xmm0
	movq	$0x000000000, -656(%rbp)
	movq	$0x000000000, -648(%rbp)
	movq	%rdx, %rdi
	rep stosl
	movq	.LC8(%rip), %rax
	movq	$0x000000000, -640(%rbp)
	leaq	-632(%rbp), %rcx
	movq	$0x000000000, -632(%rbp)
	movq	$0x000000000, -616(%rbp)
	movq	$0x000000000, -608(%rbp)
	movq	$0x000000000, -600(%rbp)
	movq	%rax, -592(%rbp)
	leaq	-656(%rbp), %rax
	movsd	%xmm0, -624(%rbp)
	movq	%rax, %rdx
.L13:
	movsd	(%rax), %xmm1
	addq	$8, %rax
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, -8(%rax)
	movsd	16(%rax), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, 16(%rax)
	movsd	40(%rax), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, 40(%rax)
	cmpq	%rcx, %rax
	jne	.L13
	movsd	.LC1(%rip), %xmm2
	movsd	.LC10(%rip), %xmm5
	movq	$0x000000000, -576(%rbp)
	leaq	-584(%rbp), %rax
	movsd	.LC9(%rip), %xmm1
	movsd	.LC11(%rip), %xmm4
	movq	$0x000000000, -544(%rbp)
	leaq	-512(%rbp), %rcx
	movsd	%xmm2, -584(%rbp)
	movsd	%xmm1, -568(%rbp)
	movsd	%xmm5, -560(%rbp)
	movsd	%xmm2, -552(%rbp)
	movsd	%xmm4, -536(%rbp)
	movsd	%xmm5, -528(%rbp)
	movsd	%xmm2, -520(%rbp)
.L14:
	movsd	(%rax), %xmm3
	addq	$24, %rax
	mulsd	%xmm0, %xmm3
	movsd	%xmm3, -24(%rax)
	movsd	-16(%rax), %xmm3
	mulsd	%xmm0, %xmm3
	movsd	%xmm3, -16(%rax)
	movsd	-8(%rax), %xmm3
	mulsd	%xmm0, %xmm3
	movsd	%xmm3, -8(%rax)
	cmpq	%rcx, %rax
	jne	.L14
	movsd	.LC12(%rip), %xmm3
	movsd	%xmm2, -512(%rbp)
	movq	%rcx, %rax
	leaq	-440(%rbp), %rsi
	movq	$0x000000000, -504(%rbp)
	movq	$0x000000000, -472(%rbp)
	movsd	%xmm1, -496(%rbp)
	movsd	%xmm3, -488(%rbp)
	movsd	%xmm2, -480(%rbp)
	movsd	%xmm4, -464(%rbp)
	movsd	%xmm3, -456(%rbp)
	movsd	%xmm2, -448(%rbp)
.L15:
	movsd	(%rax), %xmm6
	addq	$24, %rax
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -24(%rax)
	movsd	-16(%rax), %xmm6
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -16(%rax)
	movsd	-8(%rax), %xmm6
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -8(%rax)
	cmpq	%rsi, %rax
	jne	.L15
	movq	.LC13(%rip), %rax
	movsd	%xmm1, -440(%rbp)
	leaq	-368(%rbp), %rdi
	movq	$0x000000000, -432(%rbp)
	movq	$0x000000000, -400(%rbp)
	movq	%rax, -392(%rbp)
	movq	%rsi, %rax
	movsd	%xmm2, -424(%rbp)
	movsd	%xmm5, -416(%rbp)
	movsd	%xmm2, -408(%rbp)
	movsd	%xmm3, -384(%rbp)
	movsd	%xmm1, -376(%rbp)
.L16:
	movsd	(%rax), %xmm6
	addq	$24, %rax
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -24(%rax)
	movsd	-16(%rax), %xmm6
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -16(%rax)
	movsd	-8(%rax), %xmm6
	mulsd	%xmm0, %xmm6
	movsd	%xmm6, -8(%rax)
	cmpq	%rdi, %rax
	jne	.L16
	movsd	%xmm3, -344(%rbp)
	movsd	.LC13(%rip), %xmm3
	leaq	-368(%rbp), %rax
	leaq	-296(%rbp), %rdi
	movq	$0x000000000, -360(%rbp)
	movq	$0x000000000, -328(%rbp)
	movsd	%xmm1, -368(%rbp)
	movsd	%xmm2, -352(%rbp)
	movsd	%xmm2, -336(%rbp)
	movsd	%xmm3, -320(%rbp)
	movsd	%xmm5, -312(%rbp)
	movsd	%xmm1, -304(%rbp)
.L17:
	movsd	(%rax), %xmm5
	addq	$24, %rax
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -24(%rax)
	movsd	-16(%rax), %xmm5
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -16(%rax)
	movsd	-8(%rax), %xmm5
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -8(%rax)
	cmpq	%rdi, %rax
	jne	.L17
	movq	.LC14(%rip), %rax
	movsd	%xmm2, -296(%rbp)
	leaq	-224(%rbp), %r8
	movsd	%xmm2, -288(%rbp)
	movq	%rax, -248(%rbp)
	movq	%rdi, %rax
	movsd	%xmm3, -280(%rbp)
	movsd	%xmm3, -272(%rbp)
	movsd	%xmm2, -264(%rbp)
	movsd	%xmm2, -256(%rbp)
	movsd	%xmm3, -240(%rbp)
	movsd	%xmm2, -232(%rbp)
.L18:
	movsd	(%rax), %xmm5
	addq	$24, %rax
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -24(%rax)
	movsd	-16(%rax), %xmm5
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -16(%rax)
	movsd	-8(%rax), %xmm5
	mulsd	%xmm0, %xmm5
	movsd	%xmm5, -8(%rax)
	cmpq	%r8, %rax
	jne	.L18
	movq	.LC14(%rip), %rax
	movsd	%xmm2, -224(%rbp)
	leaq	-152(%rbp), %r8
	movsd	%xmm1, -216(%rbp)
	movq	%rax, -176(%rbp)
	leaq	-224(%rbp), %rax
	movsd	%xmm3, -208(%rbp)
	movsd	%xmm4, -200(%rbp)
	movsd	%xmm2, -192(%rbp)
	movsd	%xmm1, -184(%rbp)
	movsd	%xmm4, -168(%rbp)
	movsd	%xmm2, -160(%rbp)
.L19:
	movsd	(%rax), %xmm1
	addq	$24, %rax
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, -24(%rax)
	movsd	-16(%rax), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, -16(%rax)
	movsd	-8(%rax), %xmm1
	mulsd	%xmm0, %xmm1
	movsd	%xmm1, -8(%rax)
	cmpq	%r8, %rax
	jne	.L19
	movq	.LC15(%rip), %rax
	movsd	%xmm2, -688(%rbp)
	xorl	%r9d, %r9d
	movsd	%xmm2, -680(%rbp)
	movq	%rax, -672(%rbp)
	movq	.LC16(%rip), %rax
	movq	%rax, -664(%rbp)
.L20:
	leaq	(%rbx,%r9,4), %r8
	movq	%r9, %rax
	xorl	%r10d, %r10d
.L21:
	movsd	(%r8), %xmm1
	addsd	(%rdx,%rax), %xmm1
	incl	%r10d
	addq	$8, %r8
	addsd	(%rdi,%rax), %xmm1
	addsd	(%rcx,%rax), %xmm1
	movsd	%xmm1, -8(%r8)
	movsd	16(%r8), %xmm1
	addsd	(%rsi,%rax), %xmm1
	addq	$8, %rax
	movsd	%xmm1, 16(%r8)
	cmpl	$3, %r10d
	jne	.L21
	addq	$24, %r9
	cmpq	$72, %r9
	jne	.L20
	movq	.LC17(%rip), %rax
	movsd	%xmm0, -152(%rbp)
	xorl	%r14d, %r14d
	movq	%rax, -144(%rbp)
	movq	.LC18(%rip), %rax
	movq	%rax, -136(%rbp)
.L23:
	movsd	-152(%rbp), %xmm7
	leaq	-672(%rbp), %rax
	movsd	-688(%rbp,%r14), %xmm1
	movq	%rax, -720(%rbp)
	movsd	%xmm7, -728(%rbp)
	movsd	-672(%rbp,%r14), %xmm7
	addq	$8, %r14
	movsd	%xmm1, -736(%rbp)
	movaps	%xmm7, %xmm0
	movsd	%xmm7, -696(%rbp)
	addsd	%xmm2, %xmm0
	mulsd	.LC19(%rip), %xmm0
	movq	%xmm0, %r13
	call	_Z7sourcefd
	movsd	-736(%rbp), %xmm1
	movsd	-144(%rbp), %xmm4
	mulsd	%xmm1, %xmm0
	mulsd	.LC19(%rip), %xmm0
	mulsd	-696(%rbp), %xmm1
	addsd	-728(%rbp), %xmm0
	movsd	%xmm4, -728(%rbp)
	movsd	%xmm0, -152(%rbp)
	movq	%r13, %xmm0
	movsd	%xmm1, -736(%rbp)
	call	_Z7sourcefd
	movsd	-736(%rbp), %xmm1
	movsd	-136(%rbp), %xmm7
	mulsd	%xmm1, %xmm0
	mulsd	.LC19(%rip), %xmm0
	mulsd	-696(%rbp), %xmm1
	addsd	-728(%rbp), %xmm0
	movsd	%xmm7, -728(%rbp)
	movsd	%xmm0, -144(%rbp)
	movq	%r13, %xmm0
	movsd	%xmm1, -696(%rbp)
	call	_Z7sourcefd
	mulsd	-696(%rbp), %xmm0
	cmpq	$16, %r14
	movsd	.LC1(%rip), %xmm2
	mulsd	.LC19(%rip), %xmm0
	addsd	-728(%rbp), %xmm0
	movsd	%xmm0, -136(%rbp)
	jne	.L23
	leaq	-152(%rbp), %rax
	movl	$24, %r15d
	movl	$2, %r13d
	movq	%rax, -744(%rbp)
.L24:
	movq	-744(%rbp), %rax
	xorl	%r14d, %r14d
	leaq	(%rax,%r15), %rcx
	imulq	$13, %r15, %rax
	addq	%rbx, %rax
	movq	%rax, -728(%rbp)
	leaq	-656(%rbp), %rax
	movq	%rax, -736(%rbp)
.L27:
	imulq	$96, %r14, %rax
	movq	-728(%rbp), %rsi
	movl	%r14d, -696(%rbp)
	leaq	-584(%rbp), %r11
	imulq	$24, %r14, %rdx
	leaq	-512(%rbp), %r10
	leaq	-368(%rbp), %r9
	leaq	-440(%rbp), %r8
	addq	%rsi, %rax
	xorl	%esi, %esi
.L25:
	movsd	(%rax), %xmm0
	incl	%esi
	addq	$8, %rax
	addq	$8, %rdx
	movq	-736(%rbp), %rdi
	addsd	-8(%rdx,%rdi), %xmm0
	addsd	-8(%rdx,%r11), %xmm0
	addsd	-8(%rdx,%r10), %xmm0
	movsd	%xmm0, -8(%rax)
	movsd	-32(%rax), %xmm0
	addsd	-8(%rdx,%r9), %xmm0
	movsd	%xmm0, -32(%rax)
	movsd	16(%rax), %xmm0
	addsd	-8(%rdx,%r8), %xmm0
	movsd	%xmm0, 16(%rax)
	cmpl	$3, %esi
	jne	.L25
	cvtsi2sdl	-696(%rbp), %xmm1
	xorl	%eax, %eax
.L26:
	movq	%rcx, -776(%rbp)
	movq	-720(%rbp), %rcx
	movq	%rax, -768(%rbp)
	movsd	(%rcx,%rax), %xmm7
	movsd	%xmm1, -760(%rbp)
	movaps	%xmm7, %xmm0
	movsd	%xmm7, -696(%rbp)
	call	pow@PLT
	movsd	.LC1(%rip), %xmm2
	movsd	%xmm0, -752(%rbp)
	cvtsi2sdl	%r13d, %xmm0
	addsd	-696(%rbp), %xmm0
	addsd	%xmm2, %xmm0
	mulsd	.LC19(%rip), %xmm0
	call	_Z7sourcefd
	movq	-768(%rbp), %rax
	mulsd	.LC19(%rip), %xmm0
	leaq	-688(%rbp), %rsi
	movsd	-752(%rbp), %xmm3
	movq	-776(%rbp), %rcx
	mulsd	-688(%rbp,%rax), %xmm3
	addq	$8, %rax
	movsd	-760(%rbp), %xmm1
	cmpq	$16, %rax
	mulsd	%xmm0, %xmm3
	addsd	(%rcx), %xmm3
	movsd	%xmm3, (%rcx)
	jne	.L26
	incq	%r14
	addq	$8, %rcx
	cmpq	$3, %r14
	jne	.L27
	addl	$2, %r13d
	addq	$24, %r15
	cmpl	$6, %r13d
	jne	.L24
	leaq	864(%rbx), %r15
	xorl	%r14d, %r14d
.L31:
	imulq	$24, %r14, %rax
	movl	%r14d, %edi
	movq	%r15, %rdx
	xorl	%ecx, %ecx
	leaq	-656(%rbp), %r11
	leaq	-224(%rbp), %r10
	leaq	-584(%rbp), %r9
	leaq	-368(%rbp), %r8
.L29:
	movsd	72(%rdx), %xmm0
	incl	%ecx
	addq	$8, %rdx
	addq	$8, %rax
	addsd	-8(%rax,%r11), %xmm0
	addsd	-8(%rax,%r10), %xmm0
	addsd	-8(%rax,%r9), %xmm0
	movsd	%xmm0, 64(%rdx)
	movsd	40(%rdx), %xmm0
	addsd	-8(%rax,%r8), %xmm0
	movsd	%xmm0, 40(%rdx)
	cmpl	$3, %ecx
	jne	.L29
	xorl	%eax, %eax
.L30:
	movq	-720(%rbp), %rcx
	cvtsi2sdl	%edi, %xmm1
	movq	%rsi, -744(%rbp)
	movq	%rax, -736(%rbp)
	movq	(%rcx,%rax), %r13
	movl	%edi, -728(%rbp)
	movq	%r13, %xmm0
	call	pow@PLT
	movsd	.LC1(%rip), %xmm2
	movsd	%xmm0, -696(%rbp)
	movq	%r13, %xmm0
	addsd	.LC20(%rip), %xmm0
	leaq	-152(%rbp), %r13
	addsd	%xmm2, %xmm0
	mulsd	.LC19(%rip), %xmm0
	call	_Z7sourcefd
	movq	-736(%rbp), %rax
	movq	-744(%rbp), %rsi
	mulsd	.LC19(%rip), %xmm0
	movsd	-696(%rbp), %xmm1
	mulsd	(%rsi,%rax), %xmm1
	addq	$8, %rax
	movl	-728(%rbp), %edi
	cmpq	$16, %rax
	mulsd	%xmm0, %xmm1
	addsd	-80(%rbp,%r14,8), %xmm1
	movsd	%xmm1, -80(%rbp,%r14,8)
	jne	.L30
	incq	%r14
	addq	$96, %r15
	cmpq	$3, %r14
	jne	.L31
	addq	$1152, %rbx
.L33:
	movq	-704(%rbp), %rdi
	leaq	.LC21(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	.LC22(%rip), %r15
	call	__fprintf_chk@PLT
.L32:
	movsd	(%r12,%r14,8), %xmm0
	movq	%r15, %rdx
	movl	$2, %esi
	movb	$1, %al
	movq	-704(%rbp), %rdi
	incq	%r14
	call	__fprintf_chk@PLT
	cmpq	$12, %r14
	jne	.L32
	addq	$96, %r12
	cmpq	%r12, %rbx
	jne	.L33
	xorl	%ebx, %ebx
	leaq	.LC23(%rip), %r12
.L34:
	movsd	0(%r13,%rbx,8), %xmm0
	movq	%r12, %rdx
	movl	$2, %esi
	movb	$1, %al
	movq	-712(%rbp), %rdi
	incq	%rbx
	call	__fprintf_chk@PLT
	cmpq	$12, %rbx
	jne	.L34
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2054:
	.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
.LFE2054:
	.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.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1072693248
	.align 8
.LC2:
	.long	0
	.long	1074790400
	.align 8
.LC8:
	.long	1431655765
	.long	1075139925
	.align 8
.LC9:
	.long	0
	.long	-1074790400
	.align 8
.LC10:
	.long	0
	.long	-1073741824
	.align 8
.LC11:
	.long	0
	.long	1074266112
	.align 8
.LC12:
	.long	0
	.long	1073741824
	.align 8
.LC13:
	.long	0
	.long	-1073217536
	.align 8
.LC14:
	.long	0
	.long	1075052544
	.align 8
.LC15:
	.long	1167072536
	.long	-1075676761
	.align 8
.LC16:
	.long	1167072536
	.long	1071806887
	.align 8
.LC17:
	.long	0
	.long	-1071120384
	.align 8
.LC18:
	.long	0
	.long	1077149696
	.align 8
.LC19:
	.long	0
	.long	1069547520
	.align 8
.LC20:
	.long	0
	.long	1075314688
	.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 <math.h>
#include "stdio.h" 


  double sourcef(double xval)
    {
        //source function for exact solution = (1-x)e^(-x^2)
         double yval;
         yval=-(2*xval-2*(1-2*xval)+4*xval*(xval-pow(xval,2)))*exp(-xval*xval);

        return yval;
    }


int main(int argc, char **argv)

 {
//number of subintervals
    const int nel=4,mz=3;

    int glodim,je,ie;
    double ss,penal;
    double Amat[3][3],Bmat[3][3],Cmat[3][3],Dmat[3][3],Emat[3][3],F0mat[3][3],FNmat[3][3];

FILE *f = fopen("Matrix.txt", "w");
FILE *g = fopen("rhs.txt", "w");
if (f == NULL)
{
    printf("Error opening file!\n");
    exit(1);
}
if (g == NULL)
{
    printf("Error opening file!\n");
    exit(1);
}
//symmetric interior penaltyGalerking (SIPG) method   
//    ss=-1;
//    penal=-1;

//global element method
//    ss=0;
//    penal=-1;

//nonsymmetric interior penalty Galerkin (NIPG) method
    ss=1.0;
    penal=1.0;

//NIPG 0 method
//    ss=0;
//    penal=1;

//dimension of global matrix
glodim = nel * mz;

double Aglobal[glodim][glodim];
double rhsglobal[glodim];

    for(int j=0;j<glodim;j++)
    {  
       for(int i=0;i<glodim;i++)
        {
           Aglobal[i][j]=0.0;
        }
    }

    for(int i=0;i<glodim;i++)
        {
           rhsglobal[i]=0.0;
        }


    Amat[0][0]=0.0;
    Amat[0][1]=0.0;
    Amat[0][2]=0.0;
    Amat[1][0]=0.0;
    Amat[1][1]=4.0;
    Amat[1][2]=0.0;
    Amat[2][0]=0.0;
    Amat[2][1]=0.0;
    Amat[2][2]=(16.0/3.0);
    
    for(int j=0;j<mz;j++)
    {  
      //  printf("\n");
        for(int i=0;i<mz;i++)
        {
            Amat[i][j]=nel*Amat[i][j];
     //       printf(" %f ",Amat[i][j]);
        }
    }
    
   //  printf("\n");

    Bmat[0][0]=penal;
    Bmat[0][1]=1.0-penal;
    Bmat[0][2]=-2.0+penal;
    Bmat[1][0]=-ss-penal;
    Bmat[1][1]=-1.0+ss+penal;
    Bmat[1][2]=2.0-ss-penal;
    Bmat[2][0]=2.0*ss+penal;
    Bmat[2][1]=1.0-2.0*ss-penal;
    Bmat[2][2]=-2.0+2.0*ss+penal;


    for(int i=0;i<mz;i++)
    {  
     //   printf("\n");
        for(int j=0;j<mz;j++)
        {
            Bmat[i][j]=nel*Bmat[i][j];
      //      printf(" %f ",Bmat[i][j]);
        }
    }

    // printf("\n");

    Cmat[0][0]=penal;
    Cmat[0][1]=-1+penal;
    Cmat[0][2]=-2+penal;
    Cmat[1][0]=ss+penal;
    Cmat[1][1]=-1+ss+penal;
    Cmat[1][2]=-2+ss+penal;
    Cmat[2][0]=2*ss+penal;
    Cmat[2][1]=-1+2*ss+penal;
    Cmat[2][2]=-2+2*ss+penal;


    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            Cmat[i][j]=nel*Cmat[i][j];
     //       printf(" %f ",Cmat[i][j]);
 
        }
    }

   // printf("\n");

    Dmat[0][0]=-penal;
    Dmat[0][1]=-1+penal;
    Dmat[0][2]=2-penal;
    Dmat[1][0]=-ss-penal;
    Dmat[1][1]=-1+ss+penal;
    Dmat[1][2]=2-ss-penal;
    Dmat[2][0]=-2*ss-penal;
    Dmat[2][1]=-1+2*ss+penal;
    Dmat[2][2]=2-2*ss-penal;

    for(int i=0;i<mz;i++)
    {  
//	printf("\n");
        for(int j=0;j<mz;j++)
        {
            Dmat[i][j]=nel*Dmat[i][j];
  //          printf(" %f ",Dmat[i][j]);    
        }
    }

  //  printf("\n");

    Emat[0][0]=-penal;
    Emat[0][1]=1-penal;
    Emat[0][2]=2-penal;
    Emat[1][0]=ss+penal;
    Emat[1][1]=-1+ss+penal;
    Emat[1][2]=-2+ss+penal;
    Emat[2][0]=-2*ss-penal;
    Emat[2][1]=1-2*ss-penal;
    Emat[2][2]=2-2*ss-penal;

    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            Emat[i][j]=nel*Emat[i][j];
        //    printf(" %f ",Emat[i][j]);
        }
    }

   // printf("\n");

    F0mat[0][0]=penal;
    F0mat[0][1]=2-penal;
    F0mat[0][2]=-4+penal;
    F0mat[1][0]=-2*ss-penal;
    F0mat[1][1]=-2+2*ss+penal;
    F0mat[1][2]=4-2*ss-penal;
    F0mat[2][0]=4*ss+penal;
    F0mat[2][1]=2-4*ss-penal;
    F0mat[2][2]=-4+4*ss+penal;
  
    for(int i=0;i<mz;i++)
    {  
      //  printf("\n");
        for(int j=0;j<mz;j++)
        {
            F0mat[i][j]=nel*F0mat[i][j];
        //    printf(" %f ",F0mat[i][j]);
        }
    }

    // printf("\n");

    FNmat[0][0]=penal;
    FNmat[0][1]=-2+penal;
    FNmat[0][2]=-4+penal;
    FNmat[1][0]=2*ss+penal;
    FNmat[1][1]=-2+2*ss+penal;
    FNmat[1][2]=-4+2*ss+penal;
    FNmat[2][0]=4*ss+penal;
    FNmat[2][1]=-2+4*ss+penal;
    FNmat[2][2]=-4+4*ss+penal;

    for(int i=0;i<mz;i++)
    {  
       // printf("\n");  
        for(int j=0;j<mz;j++)
        {
            FNmat[i][j]=nel*FNmat[i][j];
          //  printf(" %f ",FNmat[i][j]);
        }
    }

   // printf("\n");
//Gauss quadrature weights and points
    double wg[2],sg[2];
    wg[0] = 1.0;
    wg[1] = 1.0;
    sg[0] = -0.577350269189;
    sg[1] = 0.577350269189;

    //first block row
    for(int ii=0;ii<mz;ii++)
    {
        for (int jj=0;jj<mz;jj++)
        {           
//            printf("\n");
           // printf(" %d, %d ",ii,jj);
            Aglobal[ii][jj]=Aglobal[ii][jj]+Amat[ii][jj]+F0mat[ii][jj]+Cmat[ii][jj];
            je=mz+jj; 
  
           // printf(" %d, %d ",ii,je);
            Aglobal[ii][je]=Aglobal[ii][je]+Dmat[ii][jj];
        }
    }





/*
    for(int ii=0;ii<mz;ii++)
    {
        printf("\n");
        for (int jj=0;jj<mz;jj++)
        {
           
            printf(" %f ", Aglobal[ii][jj]);
        }
    }
*/

//compute right-hand side
    rhsglobal[0]=nel*penal;
    rhsglobal[1]=nel*penal*(-1.0)-ss*2.0*nel;
    rhsglobal[2]=nel*penal+ss*4*nel;

    for(int ig=0;ig<2;ig++)
    {
        rhsglobal[0]=rhsglobal[0]+wg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        rhsglobal[1]=rhsglobal[1]+wg[ig]*sg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        rhsglobal[2]=rhsglobal[2]+wg[ig]*sg[ig]*sg[ig]*sourcef((sg[ig]+1)/(2*nel))/(2*nel);
        
    }
//printf(" %d %f ",3 , rhsglobal[3]);
// for (int jj=0;jj<mz;jj++)
//        {
//            printf(" %f ", rhsglobal[jj]);
//        }

//intermediate block rows
//loop over elements
    for (int i=1;i<nel-1;i++)
    {
        for(int ii=0;ii<mz;ii++)
        {   
            ie=ii+(i)*mz;
//            printf(" %d \n",ie);
            for(int jj=0;jj<mz;jj++)
	    {
		//je=jj+(i-1)*mz;
                je=jj+(i)*mz;
      //          printf("i= %d ,j= %d\n ",ie, je);
		Aglobal[ie][je]=Aglobal[ie][je]+Amat[ii][jj]+Bmat[ii][jj]+Cmat[ii][jj];

                //printf(" %d, %f ",je, Aglobal[ie][je]);
		//je=jj+(i-2)*mz;
		je=jj+(i-1)*mz;
    //            printf("i= %d ,j= %d \n",ie, je);
                Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
		//je=jj+(i)*mz;

		je=jj+(i+1)*mz;
//                printf(" %d , %d, %d, %d, %d ",ie, je, jj,i,mz);
//                printf("i= %d ,j= %d \n",ie, je);  
                Aglobal[ie][je]=Aglobal[ie][je]+Dmat[ii][jj];
  //              printf("\n\n");
             //   printf(" %d , %d ,%f ",ie, je, Aglobal[ie][je]);
	    }

//compute right-hand side
            for(int ig=0;ig<2;ig++)
            {   
                
                double a=pow(sg[ig],ii);
               // printf("ig=%d sg[ig]=%f ii=%d a=%f",ig, sg[ig],ii+1,a);
                double b=sourcef((sg[ig]+2*(i)+1.0)/(2*nel))/(2*nel);
             // printf("ig=%d, sg[ig]= %f,i= %d nel=%d, 2*nel= %d, b= %f",ig,sg[ig],i,nel,2*nel,b);
                rhsglobal[ie]=rhsglobal[ie]+wg[ig]*a*b;            
              //  rhsglobal[ie]=rhsglobal[ie]+wg[ig]*(pow(sg[ig],(ii-1)))*sourcef((sg[ig]+2*(i-1)+1.0)/(2*nel))/(2*nel);
//                printf("\n");
//                printf("ie=%d, ii=%d, wg[ig]=%f, sg[ig]=%f, a=%f,b=%f, rhsglobal[ie]=%f",ie ,ii, wg[ig],sg[ig], a,b, rhsglobal[ie]);
            }
        }       
    }

//printf("s=%f",sourcef(1.0));

   //  printf("\n");

//last block row
//printf("Last block");
    for(int ii=0;ii<mz;ii++)
    {
        ie=ii+(nel-1)*mz;
        for(int jj=0;jj<mz;jj++)
        {
  //          printf("\n\n");
            je=jj+(nel-1)*mz;
//            printf("i= %d ,j= %d \n",ie, je);
//            if((ie==11)&&(je==11))
//            {
//                printf("ie=%d, je=%d, Aglobal=%f, ii=%d,jj=%d, Amat=%f, FNmat=%f, Bmat=%f",ie, je, Aglobal[ie][je],ii,jj,Amat[ii][jj],FNmat[ii][jj],Bmat[ii][jj]); 
//            }
            Aglobal[ie][je]=Aglobal[ie][je]+Amat[ii][jj]+FNmat[ii][jj]+Bmat[ii][jj];
            je=jj+(nel-2)*mz;
//            printf("i= %d ,j= %d \n",ie, je);
            Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
            //printf("%f", Aglobal[ie][je]);  

      }
        for(int ig=0;ig<2;ig++)
        {
     //    printf("\n");
         double c=(pow(sg[ig],(ii)));
         double d=sourcef((sg[ig]+2*(nel-1)+1.0)/(2*nel))/(2.0*nel); 
        // printf("ig=%d, sg= %f, ii= %d, c=%f, d=%f",ig,sg[ig],ii,c,d); 
         rhsglobal[ie]=rhsglobal[ie]+wg[ig]*c*d;
         //printf("%d, %f, %f, %f \n ",ie,c,d,rhsglobal[ie]);
  //       printf("\n");
        }
    }

/*
for(int ii=0;ii<mz;ii++)
  {
        ie=ii+(nel-1)*mz;
        for(int jj=0;jj<mz;jj++)
        {
            je=jj+(nel-2)*mz;
            Aglobal[ie][je]=Aglobal[ie][je]+Emat[ii][jj];
        }
    }
*/


//printf("Aglobal[11][11]=%f",Aglobal[11][11]);


    for(int i=0;i<glodim;i++)
       {
        fprintf(f,"\n");
        for(int j=0;j<glodim;j++)
            {
             fprintf(f," %f ",Aglobal[i][j]);
            }
       }

//fprintf(f, "Integer: %d, float: %f\n", i, py);

for(int i=0;i<glodim;i++)
    {
         fprintf(g," %f \n",rhsglobal[i]);
    }




    return 0;
}

  



	.text
	.file	"elliptic3.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z7sourcefd
.LCPI0_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI0_1:
	.quad	0x4010000000000000              # double 4
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI0_2:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.text
	.globl	_Z7sourcefd
	.type	_Z7sourcefd,@function
_Z7sourcefd:                            # @_Z7sourcefd
	.cfi_startproc
# %bb.0:
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movapd	%xmm0, %xmm1
	addsd	%xmm0, %xmm1
	movsd	.LCPI0_0(%rip), %xmm2           # xmm2 = mem[0],zero
	subsd	%xmm1, %xmm2
	addsd	%xmm2, %xmm2
	subsd	%xmm2, %xmm1
	movsd	.LCPI0_1(%rip), %xmm2           # xmm2 = mem[0],zero
	mulsd	%xmm0, %xmm2
	movapd	%xmm0, %xmm3
	mulsd	%xmm0, %xmm3
	movapd	%xmm0, %xmm4
	subsd	%xmm3, %xmm4
	mulsd	%xmm2, %xmm4
	addsd	%xmm1, %xmm4
	movapd	.LCPI0_2(%rip), %xmm1           # xmm1 = [-0.0E+0,-0.0E+0]
	xorpd	%xmm1, %xmm4
	movapd	%xmm4, (%rsp)                   # 16-byte Spill
	xorpd	%xmm0, %xmm1
	mulsd	%xmm1, %xmm0
	callq	exp
	mulsd	(%rsp), %xmm0                   # 16-byte Folded Reload
	addq	$24, %rsp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z7sourcefd, .Lfunc_end0-_Z7sourcefd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_0:
	.quad	0x4010000000000000              # double 4
.LCPI1_1:
	.quad	0x4034000000000000              # double 20
.LCPI1_2:
	.quad	0xc028000000000000              # double -12
.LCPI1_3:
	.quad	0x3ff0000000000000              # double 1
.LCPI1_4:
	.quad	0x3fc0000000000000              # double 0.125
.LCPI1_6:
	.quad	0x4018000000000000              # double 6
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI1_5:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$744, %rsp                      # imm = 0x2E8
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$.L.str.2, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	testq	%rbx, %rbx
	je	.LBB1_61
# %bb.1:
	movq	%rax, %r14
	testq	%rax, %rax
	je	.LBB1_61
# %bb.2:
	movq	%rsp, -176(%rbp)                # 8-byte Spill
	movq	%rsp, %rcx
	addq	$-1152, %rcx                    # imm = 0xFB80
	movq	%rcx, %rsp
	movq	%rsp, %r13
	addq	$-96, %r13
	movq	%r13, %rsp
	xorl	%eax, %eax
	movq	%rcx, -104(%rbp)                # 8-byte Spill
.LBB1_3:                                # %.preheader350
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
	movq	$-1152, %rdx                    # imm = 0xFB80
.LBB1_4:                                #   Parent Loop BB1_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	$0, 1152(%rcx,%rdx)
	addq	$96, %rdx
	jne	.LBB1_4
# %bb.5:                                #   in Loop: Header=BB1_3 Depth=1
	incq	%rax
	addq	$8, %rcx
	cmpq	$12, %rax
	jne	.LBB1_3
# %bb.6:                                # %.preheader349.preheader
	xorpd	%xmm0, %xmm0
	movapd	%xmm0, 80(%r13)
	movapd	%xmm0, 64(%r13)
	movapd	%xmm0, 48(%r13)
	movapd	%xmm0, 32(%r13)
	movapd	%xmm0, 16(%r13)
	movapd	%xmm0, (%r13)
	leaq	-304(%rbp), %rax
	movapd	%xmm0, 16(%rax)
	movapd	%xmm0, (%rax)
	movabsq	$4616189618054758400, %rcx      # imm = 0x4010000000000000
	movq	%rcx, 32(%rax)
	movupd	%xmm0, 40(%rax)
	movq	$0, 56(%rax)
	movabsq	$4617690817930548565, %rcx      # imm = 0x4015555555555555
	movq	%rcx, 64(%rax)
	xorl	%ecx, %ecx
	movsd	.LCPI1_0(%rip), %xmm4           # xmm4 = mem[0],zero
.LBB1_7:                                # %.preheader348
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_8 Depth 2
	xorl	%edx, %edx
.LBB1_8:                                #   Parent Loop BB1_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rax,%rdx), %xmm0              # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%rax,%rdx)
	addq	$24, %rdx
	cmpq	$72, %rdx
	jne	.LBB1_8
# %bb.9:                                #   in Loop: Header=BB1_7 Depth=1
	incq	%rcx
	addq	$8, %rax
	cmpq	$3, %rcx
	jne	.LBB1_7
# %bb.10:
	movabsq	$4607182418800017408, %rax      # imm = 0x3FF0000000000000
	leaq	-624(%rbp), %rdi
	movq	%rax, (%rdi)
	xorl	%r8d, %r8d
	movq	%r8, 8(%rdi)
	movabsq	$-4616189618054758400, %rcx     # imm = 0xBFF0000000000000
	movq	%rcx, 16(%rdi)
	movabsq	$-4611686018427387904, %rsi     # imm = 0xC000000000000000
	movq	%rsi, 24(%rdi)
	movq	%rax, 32(%rdi)
	movq	%r8, 40(%rdi)
	movabsq	$4613937818241073152, %rdx      # imm = 0x4008000000000000
	movq	%rdx, 48(%rdi)
	movq	%rsi, 56(%rdi)
	movq	%rax, 64(%rdi)
.LBB1_11:                               # %.preheader347
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_12 Depth 2
	xorl	%r9d, %r9d
.LBB1_12:                               #   Parent Loop BB1_11 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r9,8), %xmm0             # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%rdi,%r9,8)
	incq	%r9
	cmpq	$3, %r9
	jne	.LBB1_12
# %bb.13:                               #   in Loop: Header=BB1_11 Depth=1
	incq	%r8
	addq	$24, %rdi
	cmpq	$3, %r8
	jne	.LBB1_11
# %bb.14:
	leaq	-544(%rbp), %rdi
	movq	%rax, (%rdi)
	xorl	%r9d, %r9d
	movq	%r9, 8(%rdi)
	movq	%rcx, 16(%rdi)
	movabsq	$4611686018427387904, %r8       # imm = 0x4000000000000000
	movq	%r8, 24(%rdi)
	movq	%rax, 32(%rdi)
	movq	%r9, 40(%rdi)
	movq	%rdx, 48(%rdi)
	movq	%r8, 56(%rdi)
	movq	%rax, 64(%rdi)
.LBB1_15:                               # %.preheader346
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_16 Depth 2
	xorl	%r10d, %r10d
.LBB1_16:                               #   Parent Loop BB1_15 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r10,8), %xmm0            # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%rdi,%r10,8)
	incq	%r10
	cmpq	$3, %r10
	jne	.LBB1_16
# %bb.17:                               #   in Loop: Header=BB1_15 Depth=1
	incq	%r9
	addq	$24, %rdi
	cmpq	$3, %r9
	jne	.LBB1_15
# %bb.18:
	leaq	-464(%rbp), %r9
	movq	%rcx, (%r9)
	xorl	%r10d, %r10d
	movq	%r10, 8(%r9)
	movq	%rax, 16(%r9)
	movq	%rsi, 24(%r9)
	movq	%rax, 32(%r9)
	movq	%r10, 40(%r9)
	movabsq	$-4609434218613702656, %rdi     # imm = 0xC008000000000000
	movq	%rdi, 48(%r9)
	movq	%r8, 56(%r9)
	movq	%rcx, 64(%r9)
.LBB1_19:                               # %.preheader345
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_20 Depth 2
	xorl	%r11d, %r11d
.LBB1_20:                               #   Parent Loop BB1_19 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r9,%r11,8), %xmm0             # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%r9,%r11,8)
	incq	%r11
	cmpq	$3, %r11
	jne	.LBB1_20
# %bb.21:                               #   in Loop: Header=BB1_19 Depth=1
	incq	%r10
	addq	$24, %r9
	cmpq	$3, %r10
	jne	.LBB1_19
# %bb.22:
	leaq	-384(%rbp), %r9
	movq	%rcx, (%r9)
	xorl	%r10d, %r10d
	movq	%r10, 8(%r9)
	movq	%rax, 16(%r9)
	movq	%r8, 24(%r9)
	movq	%rax, 32(%r9)
	movq	%r10, 40(%r9)
	movq	%rdi, 48(%r9)
	movq	%rsi, 56(%r9)
	movq	%rcx, 64(%r9)
.LBB1_23:                               # %.preheader344
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_24 Depth 2
	xorl	%esi, %esi
.LBB1_24:                               #   Parent Loop BB1_23 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r9,%rsi,8), %xmm0             # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%r9,%rsi,8)
	incq	%rsi
	cmpq	$3, %rsi
	jne	.LBB1_24
# %bb.25:                               #   in Loop: Header=BB1_23 Depth=1
	incq	%r10
	addq	$24, %r9
	cmpq	$3, %r10
	jne	.LBB1_23
# %bb.26:
	leaq	-784(%rbp), %r8
	movq	%rax, (%r8)
	movq	%rax, 8(%r8)
	movq	%rdi, 16(%r8)
	movq	%rdi, 24(%r8)
	movq	%rax, 32(%r8)
	movq	%rax, 40(%r8)
	movabsq	$4617315517961601024, %rsi      # imm = 0x4014000000000000
	movq	%rsi, 48(%r8)
	movq	%rdi, 56(%r8)
	movq	%rax, 64(%r8)
	xorl	%r9d, %r9d
.LBB1_27:                               # %.preheader343
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_28 Depth 2
	xorl	%r10d, %r10d
.LBB1_28:                               #   Parent Loop BB1_27 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r8,%r10,8), %xmm0             # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%r8,%r10,8)
	incq	%r10
	cmpq	$3, %r10
	jne	.LBB1_28
# %bb.29:                               #   in Loop: Header=BB1_27 Depth=1
	incq	%r9
	addq	$24, %r8
	cmpq	$3, %r9
	jne	.LBB1_27
# %bb.30:
	leaq	-704(%rbp), %r8
	movq	%rax, (%r8)
	movq	%rcx, 8(%r8)
	movq	%rdi, 16(%r8)
	movq	%rdx, 24(%r8)
	movq	%rax, 32(%r8)
	movq	%rcx, 40(%r8)
	movq	%rsi, 48(%r8)
	movq	%rdx, 56(%r8)
	movq	%rax, 64(%r8)
	xorl	%ecx, %ecx
.LBB1_31:                               # %.preheader342
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_32 Depth 2
	xorl	%edx, %edx
.LBB1_32:                               #   Parent Loop BB1_31 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r8,%rdx,8), %xmm0             # xmm0 = mem[0],zero
	mulsd	%xmm4, %xmm0
	movsd	%xmm0, (%r8,%rdx,8)
	incq	%rdx
	cmpq	$3, %rdx
	jne	.LBB1_32
# %bb.33:                               #   in Loop: Header=BB1_31 Depth=1
	incq	%rcx
	addq	$24, %r8
	cmpq	$3, %rcx
	jne	.LBB1_31
# %bb.34:
	movq	%rbx, -168(%rbp)                # 8-byte Spill
	movq	%rax, -160(%rbp)
	movq	%rax, -152(%rbp)
	movabsq	$-4619996508395135720, %rax     # imm = 0xBFE279A745901D18
	movq	%rax, -144(%rbp)
	movabsq	$4603375528459640088, %rax      # imm = 0x3FE279A745901D18
	movq	%rax, -136(%rbp)
	leaq	-304(%rbp), %rax
	leaq	-784(%rbp), %rcx
	leaq	-544(%rbp), %rdx
	leaq	-464(%rbp), %rsi
	xorl	%edi, %edi
	movq	-104(%rbp), %r8                 # 8-byte Reload
.LBB1_35:                               # %.preheader341
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_36 Depth 2
	xorl	%r9d, %r9d
.LBB1_36:                               #   Parent Loop BB1_35 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r8,%r9), %xmm0                # xmm0 = mem[0],zero
	movsd	24(%r8,%r9), %xmm1              # xmm1 = mem[0],zero
	addsd	(%rax,%r9), %xmm0
	addsd	(%rcx,%r9), %xmm0
	addsd	(%rdx,%r9), %xmm0
	addsd	(%rsi,%r9), %xmm1
	movsd	%xmm0, (%r8,%r9)
	movsd	%xmm1, 24(%r8,%r9)
	addq	$8, %r9
	cmpq	$24, %r9
	jne	.LBB1_36
# %bb.37:                               #   in Loop: Header=BB1_35 Depth=1
	incq	%rdi
	addq	$96, %r8
	addq	$24, %rax
	addq	$24, %rcx
	addq	$24, %rdx
	addq	$24, %rsi
	cmpq	$3, %rdi
	jne	.LBB1_35
# %bb.38:
	movsd	.LCPI1_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movsd	.LCPI1_2(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	%xmm1, -64(%rbp)                # 8-byte Spill
	movb	$1, %bl
	xorl	%eax, %eax
	movsd	.LCPI1_4(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	%xmm4, -56(%rbp)                # 8-byte Spill
.LBB1_39:                               # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, -72(%rbp)                # 8-byte Spill
	movsd	-144(%rbp,%rax,8), %xmm0        # xmm0 = mem[0],zero
	movsd	%xmm0, -80(%rbp)                # 8-byte Spill
	movsd	.LCPI1_3(%rip), %xmm3           # xmm3 = mem[0],zero
	addsd	%xmm3, %xmm0
	mulsd	%xmm1, %xmm0
	movapd	%xmm0, %xmm1
	movapd	%xmm0, %xmm2
	movapd	%xmm0, %xmm5
	movapd	%xmm0, %xmm6
	xorpd	.LCPI1_5(%rip), %xmm6
	mulsd	%xmm0, %xmm6
	movapd	%xmm6, -128(%rbp)               # 16-byte Spill
	addsd	%xmm0, %xmm0
	subsd	%xmm0, %xmm3
	addsd	%xmm3, %xmm3
	subsd	%xmm3, %xmm0
	movsd	-160(%rbp,%rax,8), %xmm3        # xmm3 = mem[0],zero
	movsd	%xmm3, -48(%rbp)                # 8-byte Spill
	mulsd	%xmm4, %xmm1
	mulsd	%xmm2, %xmm2
	subsd	%xmm2, %xmm5
	mulsd	%xmm1, %xmm5
	addsd	%xmm0, %xmm5
	movapd	%xmm5, -96(%rbp)                # 16-byte Spill
	movapd	%xmm6, %xmm0
	callq	exp
	mulsd	-96(%rbp), %xmm0                # 16-byte Folded Reload
	movsd	-48(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm0
	mulsd	.LCPI1_4(%rip), %xmm0
	movsd	-56(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	movsd	%xmm1, -56(%rbp)                # 8-byte Spill
	mulsd	-80(%rbp), %xmm2                # 8-byte Folded Reload
	movsd	%xmm2, -48(%rbp)                # 8-byte Spill
	movapd	-128(%rbp), %xmm0               # 16-byte Reload
	callq	exp
	mulsd	-96(%rbp), %xmm0                # 16-byte Folded Reload
	movsd	-48(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	mulsd	%xmm2, %xmm0
	mulsd	.LCPI1_4(%rip), %xmm0
	movsd	-64(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	movsd	%xmm1, -64(%rbp)                # 8-byte Spill
	mulsd	-80(%rbp), %xmm2                # 8-byte Folded Reload
	movsd	%xmm2, -48(%rbp)                # 8-byte Spill
	movapd	-128(%rbp), %xmm0               # 16-byte Reload
	callq	exp
	movsd	.LCPI1_4(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	.LCPI1_0(%rip), %xmm4           # xmm4 = mem[0],zero
	mulsd	-96(%rbp), %xmm0                # 16-byte Folded Reload
	mulsd	-48(%rbp), %xmm0                # 8-byte Folded Reload
	mulsd	%xmm1, %xmm0
	movsd	-72(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	subsd	%xmm0, %xmm2
	movsd	%xmm2, -72(%rbp)                # 8-byte Spill
	movsd	-72(%rbp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	$1, %eax
	testb	$1, %bl
	movl	$0, %ebx
	jne	.LBB1_39
# %bb.40:                               # %.preheader340
	movq	%r14, -184(%rbp)                # 8-byte Spill
	movsd	-56(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	%xmm1, (%r13)
	movsd	-64(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movsd	%xmm1, 8(%r13)
	movsd	%xmm0, 16(%r13)
	movq	-104(%rbp), %rax                # 8-byte Reload
	leaq	336(%rax), %r15
	movl	$1, %ecx
	movq	%r13, -112(%rbp)                # 8-byte Spill
.LBB1_41:                               # %.preheader339
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_42 Depth 2
                                        #       Child Loop BB1_43 Depth 3
                                        #       Child Loop BB1_45 Depth 3
	leal	(%rcx,%rcx), %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	%xmm0, -128(%rbp)               # 8-byte Spill
	movq	%rcx, -192(%rbp)                # 8-byte Spill
	leaq	(%rcx,%rcx,2), %rax
	movq	%rax, -208(%rbp)                # 8-byte Spill
	leaq	-464(%rbp), %rcx
	leaq	-384(%rbp), %rdx
	leaq	-544(%rbp), %rsi
	leaq	-624(%rbp), %r12
	leaq	-304(%rbp), %r14
	movq	%r15, -200(%rbp)                # 8-byte Spill
	xorl	%edi, %edi
.LBB1_42:                               #   Parent Loop BB1_41 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_43 Depth 3
                                        #       Child Loop BB1_45 Depth 3
	movq	-208(%rbp), %rax                # 8-byte Reload
	leaq	(%rdi,%rax), %r8
	xorl	%eax, %eax
.LBB1_43:                               #   Parent Loop BB1_41 Depth=1
                                        #     Parent Loop BB1_42 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	-24(%r15,%rax), %xmm0           # xmm0 = mem[0],zero
	addsd	(%r14,%rax), %xmm0
	addsd	(%r12,%rax), %xmm0
	addsd	(%rsi,%rax), %xmm0
	movsd	-48(%r15,%rax), %xmm1           # xmm1 = mem[0],zero
	movsd	%xmm0, -24(%r15,%rax)
	addsd	(%rdx,%rax), %xmm1
	movsd	%xmm1, -48(%r15,%rax)
	movsd	(%r15,%rax), %xmm0              # xmm0 = mem[0],zero
	addsd	(%rcx,%rax), %xmm0
	movsd	%xmm0, (%r15,%rax)
	addq	$8, %rax
	cmpq	$24, %rax
	jne	.LBB1_43
# %bb.44:                               # %.preheader338
                                        #   in Loop: Header=BB1_42 Depth=2
	movq	%rsi, -232(%rbp)                # 8-byte Spill
	movq	%rdx, -56(%rbp)                 # 8-byte Spill
	movq	%rcx, -64(%rbp)                 # 8-byte Spill
	movq	%rdi, -224(%rbp)                # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edi, %xmm0
	movsd	%xmm0, -80(%rbp)                # 8-byte Spill
	movq	%r8, -216(%rbp)                 # 8-byte Spill
	movsd	(%r13,%r8,8), %xmm1             # xmm1 = mem[0],zero
	movb	$1, %r13b
	xorl	%ebx, %ebx
.LBB1_45:                               #   Parent Loop BB1_41 Depth=1
                                        #     Parent Loop BB1_42 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movsd	%xmm1, -48(%rbp)                # 8-byte Spill
	movsd	-144(%rbp,%rbx,8), %xmm0        # xmm0 = mem[0],zero
	movaps	%xmm0, -96(%rbp)                # 16-byte Spill
	movsd	-80(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	callq	pow
	movsd	%xmm0, -72(%rbp)                # 8-byte Spill
	movapd	-96(%rbp), %xmm3                # 16-byte Reload
	addsd	-128(%rbp), %xmm3               # 8-byte Folded Reload
	movsd	.LCPI1_3(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm3
	mulsd	.LCPI1_4(%rip), %xmm3
	movapd	%xmm3, %xmm0
	addsd	%xmm3, %xmm0
	subsd	%xmm0, %xmm1
	addsd	%xmm1, %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm3, %xmm1
	mulsd	.LCPI1_0(%rip), %xmm1
	movapd	%xmm3, %xmm2
	mulsd	%xmm3, %xmm2
	movapd	%xmm3, %xmm4
	subsd	%xmm2, %xmm4
	mulsd	%xmm1, %xmm4
	addsd	%xmm0, %xmm4
	movapd	%xmm4, -96(%rbp)                # 16-byte Spill
	movapd	%xmm3, %xmm0
	xorpd	.LCPI1_5(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	callq	exp
	movsd	-48(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	mulsd	-96(%rbp), %xmm0                # 16-byte Folded Reload
	mulsd	.LCPI1_4(%rip), %xmm0
	movsd	-72(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	mulsd	-160(%rbp,%rbx,8), %xmm2
	mulsd	%xmm0, %xmm2
	subsd	%xmm2, %xmm1
	movl	$1, %ebx
	testb	$1, %r13b
	movl	$0, %r13d
	jne	.LBB1_45
# %bb.46:                               #   in Loop: Header=BB1_42 Depth=2
	movq	-112(%rbp), %r13                # 8-byte Reload
	movq	-216(%rbp), %rax                # 8-byte Reload
	movsd	%xmm1, (%r13,%rax,8)
	movq	-224(%rbp), %rdi                # 8-byte Reload
	incq	%rdi
	addq	$96, %r15
	addq	$24, %r14
	addq	$24, %r12
	movq	-232(%rbp), %rsi                # 8-byte Reload
	addq	$24, %rsi
	movq	-56(%rbp), %rdx                 # 8-byte Reload
	addq	$24, %rdx
	movq	-64(%rbp), %rcx                 # 8-byte Reload
	addq	$24, %rcx
	cmpq	$3, %rdi
	jne	.LBB1_42
# %bb.47:                               #   in Loop: Header=BB1_41 Depth=1
	movq	-192(%rbp), %rcx                # 8-byte Reload
	incq	%rcx
	movq	-200(%rbp), %r15                # 8-byte Reload
	addq	$312, %r15                      # imm = 0x138
	cmpq	$3, %rcx
	jne	.LBB1_41
# %bb.48:                               # %.preheader337.preheader
	movq	-104(%rbp), %rax                # 8-byte Reload
	leaq	936(%rax), %rbx
	leaq	-384(%rbp), %rcx
	leaq	-624(%rbp), %rdx
	leaq	-704(%rbp), %r12
	leaq	-304(%rbp), %r13
	xorl	%esi, %esi
.LBB1_49:                               # %.preheader337
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_50 Depth 2
                                        #     Child Loop BB1_52 Depth 2
	xorl	%eax, %eax
.LBB1_50:                               #   Parent Loop BB1_49 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	-24(%rbx,%rax), %xmm0           # xmm0 = mem[0],zero
	movsd	(%rbx,%rax), %xmm1              # xmm1 = mem[0],zero
	addsd	(%r13,%rax), %xmm1
	addsd	(%r12,%rax), %xmm1
	addsd	(%rdx,%rax), %xmm1
	addsd	(%rcx,%rax), %xmm0
	movsd	%xmm1, (%rbx,%rax)
	movsd	%xmm0, -24(%rbx,%rax)
	addq	$8, %rax
	cmpq	$24, %rax
	jne	.LBB1_50
# %bb.51:                               # %.preheader336
                                        #   in Loop: Header=BB1_49 Depth=1
	movq	%rdx, -64(%rbp)                 # 8-byte Spill
	movq	%rcx, -128(%rbp)                # 8-byte Spill
	xorps	%xmm0, %xmm0
	cvtsi2sd	%esi, %xmm0
	movsd	%xmm0, -80(%rbp)                # 8-byte Spill
	movq	-112(%rbp), %rax                # 8-byte Reload
	movq	%rsi, -56(%rbp)                 # 8-byte Spill
	movsd	72(%rax,%rsi,8), %xmm1          # xmm1 = mem[0],zero
	movb	$1, %r14b
	xorl	%r15d, %r15d
.LBB1_52:                               #   Parent Loop BB1_49 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm1, -48(%rbp)                # 8-byte Spill
	movsd	-144(%rbp,%r15,8), %xmm0        # xmm0 = mem[0],zero
	movaps	%xmm0, -96(%rbp)                # 16-byte Spill
	movsd	-80(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	callq	pow
	movsd	%xmm0, -72(%rbp)                # 8-byte Spill
	movapd	-96(%rbp), %xmm3                # 16-byte Reload
	addsd	.LCPI1_6(%rip), %xmm3
	movsd	.LCPI1_3(%rip), %xmm1           # xmm1 = mem[0],zero
	addsd	%xmm1, %xmm3
	mulsd	.LCPI1_4(%rip), %xmm3
	movapd	%xmm3, %xmm0
	addsd	%xmm3, %xmm0
	subsd	%xmm0, %xmm1
	addsd	%xmm1, %xmm1
	subsd	%xmm1, %xmm0
	movapd	%xmm3, %xmm1
	mulsd	.LCPI1_0(%rip), %xmm1
	movapd	%xmm3, %xmm2
	mulsd	%xmm3, %xmm2
	movapd	%xmm3, %xmm4
	subsd	%xmm2, %xmm4
	mulsd	%xmm1, %xmm4
	addsd	%xmm0, %xmm4
	movapd	%xmm4, -96(%rbp)                # 16-byte Spill
	movapd	%xmm3, %xmm0
	xorpd	.LCPI1_5(%rip), %xmm0
	mulsd	%xmm3, %xmm0
	callq	exp
	movsd	-48(%rbp), %xmm1                # 8-byte Reload
                                        # xmm1 = mem[0],zero
	mulsd	-96(%rbp), %xmm0                # 16-byte Folded Reload
	mulsd	.LCPI1_4(%rip), %xmm0
	movsd	-72(%rbp), %xmm2                # 8-byte Reload
                                        # xmm2 = mem[0],zero
	mulsd	-160(%rbp,%r15,8), %xmm2
	mulsd	%xmm0, %xmm2
	subsd	%xmm2, %xmm1
	movl	$1, %r15d
	testb	$1, %r14b
	movl	$0, %r14d
	jne	.LBB1_52
# %bb.53:                               #   in Loop: Header=BB1_49 Depth=1
	movq	-112(%rbp), %rax                # 8-byte Reload
	movq	-56(%rbp), %rsi                 # 8-byte Reload
	movsd	%xmm1, 72(%rax,%rsi,8)
	incq	%rsi
	addq	$96, %rbx
	movq	-128(%rbp), %rcx                # 8-byte Reload
	addq	$24, %rcx
	movq	-64(%rbp), %rdx                 # 8-byte Reload
	addq	$24, %rdx
	addq	$24, %r12
	addq	$24, %r13
	cmpq	$3, %rsi
	jne	.LBB1_49
# %bb.54:                               # %.preheader335.preheader
	xorl	%ebx, %ebx
	movq	-168(%rbp), %r15                # 8-byte Reload
	movq	-112(%rbp), %r12                # 8-byte Reload
	movq	-104(%rbp), %r13                # 8-byte Reload
.LBB1_55:                               # %.preheader335
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_56 Depth 2
	movl	$10, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	xorl	%r14d, %r14d
.LBB1_56:                               #   Parent Loop BB1_55 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r13,%r14,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.5, %esi
	movq	%r15, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r14
	cmpq	$12, %r14
	jne	.LBB1_56
# %bb.57:                               #   in Loop: Header=BB1_55 Depth=1
	incq	%rbx
	addq	$96, %r13
	cmpq	$12, %rbx
	jne	.LBB1_55
# %bb.58:                               # %.preheader.preheader
	xorl	%ebx, %ebx
	movq	-184(%rbp), %r14                # 8-byte Reload
.LBB1_59:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r12,%rbx,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.6, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%rbx
	cmpq	$12, %rbx
	jne	.LBB1_59
# %bb.60:
	movq	-176(%rbp), %rsp                # 8-byte Reload
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.LBB1_61:
	.cfi_def_cfa %rbp, 16
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Matrix.txt"
	.size	.L.str, 11

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"w"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"rhs.txt"
	.size	.L.str.2, 8

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	" %f "
	.size	.L.str.5, 5

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" %f \n"
	.size	.L.str.6, 6

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"Error opening file!"
	.size	.Lstr.1, 20

	.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
