// File: /workspace/github_cpp_makefile_star2_O2/jamesliu516[P]amrdg2d/wall4amrdg2013.cpp
// Function: gem(double*, int, double*)
void gem(double *a, int M, double *u)
{	
    int i,j,k1,p,mm,flag=1;
    double eita,ui3;

    const double nrrs=1e-8;
    //double *r=(double *)malloc((M+1)*sizeof(double));
    double *r=new double[M+1];

    //-----M*(M+1)������������ԪGauss��ȥ--------/
    for(k1=0;k1<=M-2;k1++)            
    {
        ui3=0.0;

        for(mm=k1;mm<=M-1;mm++)
        {
            if(ui3<fabs(a[mm*(M+1)+k1]))
            {
                ui3=fabs(a[mm*(M+1)+k1]);
                p=mm;
            }
        }

        if(ui3 < nrrs) 
        {
            // printf("matrix singularity.\n");
            cout<<"matrix singularity.\n";
            flag=0;
            break;
        }
        if(p!=k1)
        {
            for(j=k1;j<=M;j++) 
            {
                ui3=a[k1*(M+1)+j];
                a[k1*(M+1)+j]=a[p*(M+1)+j];
                a[p*(M+1)+j]=ui3;
            }  
        }
        for(j=k1+1;j<=M;j++)
            r[j]=a[k1*(M+1)+j];
        for(i=k1+1;i<=M-1;i++)
        {
            eita=a[i*(M+1)+k1]/a[k1*(M+1)+k1];
            a[i*(M+1)+k1]=eita;
            for(j=k1+1;j<=M;j++)
                a[i*(M+1)+j]=a[i*(M+1)+j]-eita*r[j];
        }
    }
    //-----�ش��õ�������-------
    if(flag)
    {
        for(i=M-1;i>=0;i--)
        {	
            u[i]=a[i*(M+1)+M];
            for(j=i+1;j<=M-1;j++)
                u[i]=u[i]-a[i*(M+1)+j]*u[j];
            u[i]=u[i]/a[i*(M+1)+i];
        }
    }
    //free(r);
    delete [] r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x28(%rsp)
movl %esi, %ebx
movq %rdi, %r14
leal 0x1(%rbx), %r12d
leaq (,%r12,8), %rax
cmpl $-0x1, %esi
pushq $-0x1
popq %rdi
cmovgeq %rax, %rdi
callq 0x3030
movq %rax, %r15
leal -0x2(%rbx), %eax
leal 0x2(%rbx), %ecx
movl %ecx, 0x8(%rsp)
movq %r12, 0x30(%rsp)
movslq %r12d, %rsi
movq %rbx, 0x10(%rsp)
movslq %ebx, %rdx
cltq
movq %rax, 0x40(%rsp)
leaq (,%rsi,8), %rcx
movq %rsi, 0x20(%rsp)
leaq 0x8(,%rsi,8), %rbx
pushq $0x1
popq %rsi
xorl %r10d, %r10d
movsd 0x978d(%rip), %xmm0     # 0x1b180
movapd 0x96a5(%rip), %xmm1     # 0x1b0a0
movapd 0x983d(%rip), %xmm2     # 0x1b240
movq %r14, %r11
movq %r14, 0x18(%rsp)
movq %r14, %rbp
movq %rbx, 0x38(%rsp)
movq 0x10(%rsp), %rax
cmpl %r10d, %eax
movl %r10d, %r8d
cmovgl %eax, %r8d
cmpq 0x40(%rsp), %r10
jg 0x11b67
movslq %esi, %rax
imulq %rax, %rbx
addq %rbp, %rbx
xorpd %xmm3, %xmm3
movq %r14, %r12
movq %r10, %r13
cmpq %r13, %r8
je 0x11a68
movsd (%r12), %xmm4
andpd %xmm2, %xmm4
ucomisd %xmm3, %xmm4
cmoval %r13d, %edi
maxsd %xmm3, %xmm4
incq %r13
addq %rcx, %r12
movapd %xmm4, %xmm3
jmp 0x11a41
ucomisd %xmm3, %xmm0
ja 0x11bf8
movl %esi, 0xc(%rsp)
movl %edi, %esi
cmpq %rsi, %r10
jne 0x11b27
movq %rax, %rsi
cmpq %rdx, %rsi
jg 0x11a9a
movsd (%r11,%rsi,8), %xmm3
movsd %xmm3, (%r15,%rsi,8)
incq %rsi
jmp 0x11a84
movl 0x8(%rsp), %esi
imull %r10d, %esi
movslq %esi, %r12
leaq (,%r10,8), %r13
addq %rbp, %r13
movq %rax, %r8
cmpq %rdx, %r8
jge 0x11b08
movq %r8, %rsi
imulq 0x20(%rsp), %rsi
movsd (%r13,%rsi,8), %xmm3
divsd (%rbp,%r12,8), %xmm3
movsd %xmm3, (%r13,%rsi,8)
xorpd %xmm1, %xmm3
movq %rbx, %rsi
movq %rax, %r9
cmpq %rdx, %r9
jg 0x11b00
movsd (%r15,%r9,8), %xmm4
mulsd %xmm3, %xmm4
addsd (%rsi), %xmm4
movsd %xmm4, (%rsi)
incq %r9
addq $0x8, %rsi
jmp 0x11ae0
incq %r8
addq %rcx, %rbx
jmp 0x11ab3
incq %r10
movl 0xc(%rsp), %esi
incl %esi
movq 0x38(%rsp), %rbx
addq %rbx, %r14
addq $0x8, 0x18(%rsp)
addq %rcx, %r11
jmp 0x11a13
movl %edi, %esi
imull 0x30(%rsp), %esi
movslq %esi, %rsi
movq 0x18(%rsp), %r8
leaq (%r8,%rsi,8), %rsi
xorl %r8d, %r8d
leaq (%r10,%r8), %r9
cmpq %rdx, %r9
jg 0x11a81
movsd (%r14,%r8,8), %xmm3
movsd (%rsi,%r8,8), %xmm4
movsd %xmm4, (%r14,%r8,8)
movsd %xmm3, (%rsi,%r8,8)
incq %r8
jmp 0x11b3d
movq 0x10(%rsp), %rax
decl %eax
movslq %eax, %rsi
leaq (,%rdx,8), %rdx
addq %rbp, %rdx
imulq %rsi, %rbx
leaq (%rbx,%rbp), %rdi
addq $0x8, %rdi
xorq $-0x8, %rcx
movq 0x28(%rsp), %rbx
leaq (%rbx,%rsi,8), %r8
addq $0x8, %r8
movq %rsi, %r9
testq %r9, %r9
js 0x11c0b
movq %r9, %r10
imulq 0x20(%rsp), %r10
movsd (%rdx,%r10,8), %xmm0
xorl %eax, %eax
leaq (%r9,%rax), %r11
movsd %xmm0, (%rbx,%r9,8)
cmpq %rsi, %r11
jge 0x11bd5
movsd (%rdi,%rax,8), %xmm1
mulsd (%r8,%rax,8), %xmm1
subsd %xmm1, %xmm0
incq %rax
jmp 0x11bb2
leaq (,%r10,8), %rax
addq %rbp, %rax
divsd (%rax,%r9,8), %xmm0
movsd %xmm0, (%rbx,%r9,8)
decq %r9
addq %rcx, %rdi
addq $-0x8, %r8
jmp 0x11b9c
movq 0x113c1(%rip), %rdi     # 0x22fc0
leaq 0x9d10(%rip), %rsi      # 0x1b916
callq 0x31d0
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3250