// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/matrix.c
// Function: jacobi
void jacobi(matrix matrix2,double **d,matrix *v)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*Computes the eigenvectors and eigenvalues of a SYMMETRIC matrix*/
 int j,iq,ip,i,n=matrix2.row;
 double tresh,theta,tau,t,sm,s,h,g,c;
 double *b;
 double *z;
 matrix matrix1 = matrix_copy(matrix2);
 (*v) = matrix_alloc(matrix2.row,matrix2.col);
 (*d) = (double *)safemalloc(n*sizeof(double), "jacobi", 7);
 b = (double *)safemalloc(n*sizeof(double), "jacobi", 8);
 z = (double *)safemalloc(n*sizeof(double), "jacobi", 9);
 for (ip=1;ip<=n;ip++)
  {
   for (iq=1;iq<=n;iq++)
     (*v).values[ip-1][iq-1]=0.0;
   (*v).values[ip-1][ip-1]=1.0;
  }
 for (ip=1;ip<=n;ip++)
  {
   b[ip-1]=matrix1.values[ip-1][ip-1];
   (*d)[ip-1]=b[ip-1];
   z[ip-1]=0.0;
  }
 for (i=1;i<=50;i++)
  {
   sm = 0.0;
   for (ip=1;ip<=n-1;ip++)
     for (iq=ip+1;iq<=n;iq++)
       sm += (double)fabs(matrix1.values[ip-1][iq-1]);
   if (sm==0.0)
     goto devam;
   if (i<4)
     tresh=0.2*sm/pow(n,2);
   else
     tresh=0.0;
   for (ip=1;ip<=n-1;ip++)
    {
     for (iq=ip+1;iq<=n;iq++)
      {
       g = 100.0*(double)fabs(matrix1.values[ip-1][iq-1]);
       if ((i > 4)&&((double)fabs((*d)[ip-1])+g==(double)fabs((*d)[ip-1]))&&((double)fabs((*d)[iq-1])+g==(double)fabs((*d)[iq-1])))
         matrix1.values[ip-1][iq-1]=0.0;
       else
         if ((double)fabs(matrix1.values[ip-1][iq-1])>tresh)
          {
           h = (*d)[iq-1]-(*d)[ip-1];
           if ((double)fabs(h)+g==(double)fabs(h))
             t=matrix1.values[ip-1][iq-1]/h;
           else
            {
             theta=0.5*h/matrix1.values[ip-1][iq-1];
             t = 1.0/((double)fabs(theta)+sqrt(1.0+pow(theta,2)));
             if (theta < 0.0)
               t = -t;
            }
           c= 1.0/sqrt(1+pow(t,2));
           s = t*c;
           tau = s/(1.0+c);
           h = t*matrix1.values[ip-1][iq-1];
           z[ip-1] -= h;
           z[iq-1] += h;
           (*d)[ip-1] -= h;
           (*d)[iq-1] += h;
           matrix1.values[ip-1][iq-1]=0.0;
           for (j=1;j<=ip-1;j++)
            {
             g=matrix1.values[j-1][ip-1];
             h=matrix1.values[j-1][iq-1];
             matrix1.values[j-1][ip-1]=g-s*(h+g*tau);
             matrix1.values[j-1][iq-1]=h+s*(g-h*tau);
            }
           for (j=ip+1;j<=iq-1;j++)
            {
             g=matrix1.values[ip-1][j-1];
             h=matrix1.values[j-1][iq-1];
             matrix1.values[ip-1][j-1] = g-s*(h+g*tau);
             matrix1.values[j-1][iq-1] = h+s*(g-h*tau);
            }
           for (j=iq+1;j<=n;j++)
            {
             g = matrix1.values[ip-1][j-1];
             h = matrix1.values[iq-1][j-1];
             matrix1.values[ip-1][j-1] = g-s*(h+g*tau);
             matrix1.values[iq-1][j-1] = h+s*(g-h*tau);
            }
           for (j=1;j<=n;j++)
            {
             g = (*v).values[j-1][ip-1];
             h = (*v).values[j-1][iq-1];
             (*v).values[j-1][ip-1] = g-s*(h+g*tau);
             (*v).values[j-1][iq-1] = h+s*(g-h*tau);
            }
          }
      }
    }
   for (ip=1;ip<=n;ip++)
    {
     b[ip-1] = b[ip-1]+z[ip-1];
     (*d)[ip-1] = b[ip-1];
     z[ip-1] = 0.0;
    }
  }
devam:
 safe_free(z);
 safe_free(b);
 matrix_free(matrix1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq %rdi, %r15
shrq $0x20, %r15
callq 0x3ca3c
movq %rax, 0x78(%rsp)
movq %rdx, 0x20(%rsp)
leaq 0x674be(%rip), %r8      # 0xa6ecc
movl $0x8, %edi
movl $0x8, %esi
movl %r12d, %edx
movl %r15d, %ecx
movl $0x3, %r9d
callq 0x39245
movq %r12, (%rbx)
movq %rbx, 0x48(%rsp)
movq %rax, 0x8(%rbx)
movq %r12, 0x18(%rsp)
movslq %r12d, %rbx
leaq (,%rbx,8), %r15
leaq 0x67533(%rip), %r12     # 0xa6f7f
movq %r15, %rdi
movq %r12, %rsi
movl $0x7, %edx
callq 0x390f5
movq %r14, 0x28(%rsp)
movq %rax, (%r14)
movq %r15, %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x390f5
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
movl $0x9, %edx
callq 0x390f5
movq %rax, 0x10(%rsp)
testl %ebx, %ebx
jle 0x3fadc
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rbx
movq 0x18(%rsp), %rax
movl %eax, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
shlq $0x3, %rbp
leal 0x1(%rax), %r14d
decq %r14
xorl %r15d, %r15d
movabsq $0x3ff0000000000000, %r12 # imm = 0x3FF0000000000000
movq (%rbx,%r15,8), %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x4050
movq (%rbx,%r15,8), %rax
movq %r12, (%rax,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x3fabe
movq 0x18(%rsp), %r9
testl %r9d, %r9d
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r10
movq 0x10(%rsp), %rdi
jle 0x3fb26
movq (%r8), %rax
leal 0x1(%r9), %ecx
decq %rcx
xorl %edx, %edx
movq (%r10,%rdx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movsd %xmm0, (%r13,%rdx,8)
movsd %xmm0, (%rax,%rdx,8)
movq $0x0, (%rdi,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x3fb01
xorps %xmm0, %xmm0
cvtsi2sd %r9d, %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
leal 0x1(%r9), %eax
movslq %r9d, %rcx
movq %rcx, 0xb0(%rsp)
movl %ecx, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
leaq -0x2(%rax), %rcx
movq %rcx, 0x90(%rsp)
movq %r10, %rcx
addq $0x8, %rcx
movq %rcx, 0x80(%rsp)
movq %rax, 0x30(%rsp)
leaq -0x1(%rax), %rbx
movl $0x1, 0xc(%rsp)
movapd 0x63658(%rip), %xmm6    # 0xa31e0
xorpd %xmm7, %xmm7
movsd 0x6320b(%rip), %xmm8    # 0xa2da0
movsd 0x62982(%rip), %xmm9    # 0xa2520
movapd 0x63629(%rip), %xmm10   # 0xa31d0
movq %r13, 0x98(%rsp)
movq %r14, 0xa0(%rsp)
xorpd %xmm11, %xmm11
cmpl $0x2, %r9d
jl 0x3fc05
movl $0x1, %eax
movl $0x8, %ecx
movq 0x90(%rsp), %rdx
movq -0x8(%r10,%rax,8), %rsi
addq %rcx, %rsi
incq %rax
xorl %r11d, %r11d
movsd (%rsi,%r11,8), %xmm0
andpd %xmm6, %xmm0
addsd %xmm0, %xmm11
incq %r11
cmpq %r11, %rdx
jne 0x3fbe2
addq $0x8, %rcx
decq %rdx
cmpq %r14, %rax
jne 0x3fbd4
ucomisd %xmm7, %xmm11
movq 0x10(%rsp), %rdi
jne 0x3fc17
jnp 0x400d7
mulsd 0x65168(%rip), %xmm11   # 0xa4d88
movl 0xc(%rsp), %esi
cmpl $0x4, %esi
jb 0x3fc30
xorpd %xmm11, %xmm11
jmp 0x3fc3a
divsd 0x88(%rsp), %xmm11
cmpl $0x2, %r9d
movq 0x30(%rsp), %rdi
jl 0x40089
movl $0x2, %ebp
movl $0x1, %r15d
movl $0x8, %eax
movq %rax, 0x38(%rsp)
movq 0x80(%rsp), %rax
xorl %r12d, %r12d
movsd %xmm11, 0x40(%rsp)
movq %rax, 0x58(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0x50(%rsp)
movq %r12, %r14
xorl %r13d, %r13d
movq %rbp, 0xa8(%rsp)
movq -0x8(%r10,%r15,8), %rax
movsd -0x8(%rax,%rbp,8), %xmm4
movapd %xmm4, %xmm1
andpd %xmm6, %xmm1
movapd %xmm1, %xmm0
mulsd %xmm8, %xmm0
cmpl $0x5, %esi
jb 0x3fcf3
movq (%r8), %rcx
movsd -0x8(%rcx,%r15,8), %xmm2
andpd %xmm6, %xmm2
movapd %xmm0, %xmm3
addsd %xmm2, %xmm3
ucomisd %xmm2, %xmm3
jne 0x3fcf3
jp 0x3fcf3
movsd -0x8(%rcx,%rbp,8), %xmm2
andpd %xmm6, %xmm2
movapd %xmm0, %xmm3
addsd %xmm2, %xmm3
ucomisd %xmm2, %xmm3
jne 0x3fcf3
jp 0x3fcf3
movq $0x0, -0x8(%rax,%rbp,8)
jmp 0x40044
ucomisd %xmm11, %xmm1
jbe 0x40044
movq (%r8), %rax
movsd -0x8(%rax,%rbp,8), %xmm2
subsd -0x8(%rax,%r15,8), %xmm2
movapd %xmm2, %xmm1
andpd %xmm6, %xmm1
addsd %xmm1, %xmm0
ucomisd %xmm1, %xmm0
jne 0x3fd2b
jp 0x3fd2b
divsd %xmm2, %xmm4
jmp 0x3fdbf
mulsd 0x62fe5(%rip), %xmm2    # 0xa2d18
divsd %xmm4, %xmm2
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm9, %xmm0
ucomisd %xmm7, %xmm0
jb 0x3fd50
sqrtsd %xmm0, %xmm0
jmp 0x3fda3
movapd %xmm2, 0x60(%rsp)
callq 0x4300
movapd 0x60(%rsp), %xmm2
movsd 0x40(%rsp), %xmm11
movapd 0x6345f(%rip), %xmm10   # 0xa31d0
movsd 0x627a6(%rip), %xmm9    # 0xa2520
movsd 0x6301d(%rip), %xmm8    # 0xa2da0
xorpd %xmm7, %xmm7
movapd 0x63451(%rip), %xmm6    # 0xa31e0
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %r9
movq 0x28(%rsp), %r8
ucomisd %xmm2, %xmm7
andpd %xmm6, %xmm2
addsd %xmm0, %xmm2
movapd %xmm9, %xmm4
divsd %xmm2, %xmm4
jbe 0x3fdbf
xorpd %xmm10, %xmm4
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm9, %xmm0
ucomisd %xmm7, %xmm0
jb 0x3fddd
sqrtsd %xmm0, %xmm0
movq 0x10(%rsp), %rcx
jmp 0x3fe35
movapd %xmm4, 0x60(%rsp)
callq 0x4300
movapd 0x60(%rsp), %xmm4
movsd 0x40(%rsp), %xmm11
movapd 0x633d2(%rip), %xmm10   # 0xa31d0
movsd 0x62719(%rip), %xmm9    # 0xa2520
movsd 0x62f90(%rip), %xmm8    # 0xa2da0
xorpd %xmm7, %xmm7
movapd 0x633c4(%rip), %xmm6    # 0xa31e0
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %r9
movq 0x28(%rsp), %r8
movapd %xmm9, %xmm2
divsd %xmm0, %xmm2
movapd %xmm4, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm9, %xmm2
movq -0x8(%r10,%r15,8), %rax
mulsd -0x8(%rax,%rbp,8), %xmm4
movsd -0x8(%rcx,%r15,8), %xmm1
subsd %xmm4, %xmm1
movsd %xmm1, -0x8(%rcx,%r15,8)
movsd -0x8(%rcx,%rbp,8), %xmm1
addsd %xmm4, %xmm1
movsd %xmm1, -0x8(%rcx,%rbp,8)
movq %r8, %r11
movq (%r8), %rcx
movsd -0x8(%rcx,%r15,8), %xmm1
subsd %xmm4, %xmm1
movsd %xmm1, -0x8(%rcx,%r15,8)
movapd %xmm0, %xmm1
addsd -0x8(%rcx,%rbp,8), %xmm4
divsd %xmm2, %xmm1
movsd %xmm4, -0x8(%rcx,%rbp,8)
movq $0x0, -0x8(%rax,%rbp,8)
cmpq $0x2, %r15
jb 0x3ff0c
movapd %xmm0, %xmm2
xorpd %xmm10, %xmm2
xorl %ecx, %ecx
movq (%r10,%rcx,8), %rdx
movsd -0x8(%rdx,%r15,8), %xmm3
movsd -0x8(%rdx,%rbp,8), %xmm4
movapd %xmm3, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, -0x8(%rdx,%r15,8)
movapd %xmm4, %xmm5
mulsd %xmm1, %xmm5
subsd %xmm5, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, -0x8(%rdx,%rbp,8)
incq %rcx
cmpq %rcx, %r12
jne 0x3febe
cmpq %rbp, 0x50(%rsp)
movq 0x58(%rsp), %r8
jae 0x3ff75
movapd %xmm0, %xmm2
xorpd %xmm10, %xmm2
movq 0x38(%rsp), %rcx
addq %rax, %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm3
movq (%r8,%rdx,8), %rsi
movsd -0x8(%rsi,%rbp,8), %xmm4
movapd %xmm3, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, (%rcx,%rdx,8)
movapd %xmm4, %xmm5
mulsd %xmm1, %xmm5
subsd %xmm5, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, -0x8(%rsi,%rbp,8)
incq %rdx
cmpq %rdx, %r13
jne 0x3ff2b
cmpq 0xb0(%rsp), %rbp
jge 0x3ffdb
movq -0x8(%r10,%rbp,8), %rcx
movapd %xmm0, %xmm2
xorpd %xmm10, %xmm2
movq %r14, %rdx
movsd 0x10(%rax,%rdx,8), %xmm3
movsd 0x10(%rcx,%rdx,8), %xmm4
movapd %xmm3, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, 0x10(%rax,%rdx,8)
movapd %xmm4, %xmm5
mulsd %xmm1, %xmm5
subsd %xmm5, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, 0x10(%rcx,%rdx,8)
incq %rdx
leal 0x2(%rdx), %esi
cmpl %r9d, %esi
jl 0x3ff90
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movapd %xmm0, %xmm2
xorpd %xmm10, %xmm2
xorl %ecx, %ecx
movl 0xc(%rsp), %esi
movq %r11, %r8
movq (%rax,%rcx,8), %rdx
movsd -0x8(%rdx,%r15,8), %xmm3
movsd -0x8(%rdx,%rbp,8), %xmm4
movapd %xmm3, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, -0x8(%rdx,%r15,8)
movapd %xmm4, %xmm5
mulsd %xmm1, %xmm5
subsd %xmm5, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, -0x8(%rdx,%rbp,8)
incq %rcx
cmpq %rcx, %rbx
jne 0x3fff6
incq %rbp
incq %r13
incq %r14
cmpq %rdi, %rbp
jne 0x3fc8c
movq 0xa8(%rsp), %rbp
incq %rbp
incq %r12
addq $0x8, 0x38(%rsp)
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq 0xa0(%rsp), %r14
movq 0x50(%rsp), %r15
cmpq %r14, %r15
jne 0x3fc70
testl %r9d, %r9d
movq 0x98(%rsp), %r13
movq 0x10(%rsp), %rdi
jle 0x400c8
movq (%r8), %rax
xorl %ecx, %ecx
movsd (%r13,%rcx,8), %xmm0
addsd (%rdi,%rcx,8), %xmm0
movsd %xmm0, (%r13,%rcx,8)
movsd %xmm0, (%rax,%rcx,8)
movq $0x0, (%rdi,%rcx,8)
incq %rcx
cmpq %rcx, %rbx
jne 0x400a0
incl %esi
movl %esi, 0xc(%rsp)
cmpl $0x33, %esi
jne 0x3fbb7
movq %r10, %rbx
callq 0x39194
movq %r13, %rdi
callq 0x39194
movq %rbx, %rdi
movq 0x78(%rsp), %rsi
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3915f