// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq %rdi, %r15
shrq $0x20, %r15
callq 0x3dae3
movq %rax, 0x38(%rsp)
movq %rdx, %r13
movq %rdx, 0x18(%rsp)
leaq 0x69212(%rip), %r8      # 0xa9f6c
movl $0x8, %edi
movl $0x8, %esi
movl %r12d, %edx
movl %r15d, %ecx
movl $0x3, %r9d
callq 0x3a231
movq %r12, (%rbx)
movq %rbx, 0x28(%rsp)
movq %rax, 0x8(%rbx)
movslq %r12d, %rbx
leaq (,%rbx,8), %rbp
leaq 0x6928c(%rip), %r15     # 0xaa01f
movq %rbp, %rdi
movq %r15, %rsi
movl $0x7, %edx
callq 0x3a0e1
movq %r14, 0x8(%rsp)
movq %rax, (%r14)
movq %rbp, %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x3a0e1
movq %rax, %r14
movq %rbp, %rdi
movq %r15, %rsi
movl $0x9, %edx
callq 0x3a0e1
movq %rax, %rbp
testl %ebx, %ebx
movq %r14, 0x20(%rsp)
jle 0x40e6f
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rbx
movl %r12d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x3, %rax
movq %rax, (%rsp)
leal 0x1(%r12), %r14d
decq %r14
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
xorl %esi, %esi
movq (%rsp), %rdx
callq 0x4050
movq (%rbx,%r15,8), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x40e02
testl %r12d, %r12d
movq 0x20(%rsp), %r14
jle 0x40e6f
movq 0x8(%rsp), %rax
movq (%rax), %rcx
leal 0x1(%r12), %eax
movl %r12d, %edx
xorl %esi, %esi
movq (%r13,%rsi,8), %rdi
movsd (%rdi,%rsi,8), %xmm0
movsd %xmm0, (%r14,%rsi,8)
movsd %xmm0, (%rcx,%rsi,8)
movq $0x0, (%rbp,%rsi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x40e47
jmp 0x40e74
leal 0x1(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
mulsd %xmm0, %xmm0
movslq %r12d, %rcx
movq %rcx, 0x68(%rsp)
movl %ecx, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl %eax, %eax
leaq -0x2(%rax), %rcx
movq %rcx, 0x40(%rsp)
addq $0x8, 0x18(%rsp)
movq %rax, 0x70(%rsp)
leaq -0x1(%rax), %rdi
movl $0x1, (%rsp)
movapd 0x65325(%rip), %xmm1    # 0xa61e0
xorpd %xmm2, %xmm2
movsd 0x66f49(%rip), %xmm3    # 0xa7e10
movsd 0x64ed1(%rip), %xmm4    # 0xa5da0
movsd 0x64649(%rip), %xmm5    # 0xa5520
movapd 0x652f1(%rip), %xmm6    # 0xa61d0
movsd 0x64e31(%rip), %xmm7    # 0xa5d18
movq %rbp, 0x10(%rsp)
movq %r9, 0x48(%rsp)
cmpl $0x2, %r12d
jl 0x413a2
xorpd %xmm8, %xmm8
movl $0x1, %eax
movl $0x8, %ecx
movq 0x40(%rsp), %rdx
movq -0x8(%r13,%rax,8), %rsi
addq %rcx, %rsi
incq %rax
xorl %r8d, %r8d
movsd (%rsi,%r8,8), %xmm9
andpd %xmm1, %xmm9
addsd %xmm9, %xmm8
incq %r8
cmpq %r8, %rdx
jne 0x40f1d
addq $0x8, %rcx
decq %rdx
cmpq %r9, %rax
jne 0x40f0f
ucomisd %xmm2, %xmm8
jne 0x40f4e
jnp 0x413a2
mulsd %xmm3, %xmm8
cmpl $0x4, (%rsp)
jb 0x40f60
xorpd %xmm8, %xmm8
jmp 0x40f65
divsd %xmm0, %xmm8
cmpl $0x2, %r12d
jl 0x4134e
movl $0x2, %r14d
movl $0x1, %r15d
movl $0x8, %eax
movl $0x10, %edx
movq 0x18(%rsp), %rsi
xorl %ecx, %ecx
leaq 0x1(%r15), %r8
movq %r8, 0x30(%rsp)
movq -0x8(%r13,%r15,8), %r9
movq %rax, 0x58(%rsp)
leaq (%r9,%rax), %rbx
leaq (%r9,%rdx), %r11
movq %rdx, 0x50(%rsp)
movq %rdx, %rax
xorl %r10d, %r10d
movq %r14, 0x60(%rsp)
movsd -0x8(%r9,%r14,8), %xmm11
movapd %xmm11, %xmm10
andpd %xmm1, %xmm10
movapd %xmm10, %xmm9
mulsd %xmm4, %xmm9
cmpl $0x5, (%rsp)
jb 0x4102c
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movsd -0x8(%rdx,%r15,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x4102c
jp 0x4102c
movsd -0x8(%rdx,%r14,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x4102c
jp 0x4102c
movq $0x0, -0x8(%r9,%r14,8)
jmp 0x41301
ucomisd %xmm8, %xmm10
jbe 0x41301
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movsd -0x8(%rdx,%r14,8), %xmm10
subsd -0x8(%rdx,%r15,8), %xmm10
movapd %xmm10, %xmm12
andpd %xmm1, %xmm12
addsd %xmm12, %xmm9
ucomisd %xmm12, %xmm9
jne 0x41076
jp 0x41076
movapd %xmm11, %xmm12
divsd %xmm10, %xmm12
movq 0x10(%rsp), %r8
jmp 0x410b9
mulsd %xmm7, %xmm10
divsd %xmm11, %xmm10
movapd %xmm10, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm10, %xmm2
mulsd %xmm10, %xmm10
addsd %xmm5, %xmm10
sqrtsd %xmm10, %xmm10
addsd %xmm9, %xmm10
movapd %xmm5, %xmm12
divsd %xmm10, %xmm12
movq 0x10(%rsp), %r8
jbe 0x410b9
xorpd %xmm6, %xmm12
movapd %xmm12, %xmm9
mulsd %xmm12, %xmm9
addsd %xmm5, %xmm9
sqrtsd %xmm9, %xmm9
movapd %xmm5, %xmm13
divsd %xmm9, %xmm13
movapd %xmm12, %xmm9
mulsd %xmm13, %xmm9
addsd %xmm5, %xmm13
movapd %xmm9, %xmm10
mulsd %xmm12, %xmm11
movsd -0x8(%r8,%r15,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, -0x8(%r8,%r15,8)
movsd -0x8(%r8,%r14,8), %xmm12
addsd %xmm11, %xmm12
movsd %xmm12, -0x8(%r8,%r14,8)
movsd -0x8(%rdx,%r15,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, -0x8(%rdx,%r15,8)
addsd -0x8(%rdx,%r14,8), %xmm11
divsd %xmm13, %xmm10
movsd %xmm11, -0x8(%rdx,%r14,8)
movq $0x0, -0x8(%r9,%r14,8)
cmpq $0x2, %r15
jb 0x411b2
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
xorl %edx, %edx
movq (%r13,%rdx,8), %r8
movsd -0x8(%r8,%r15,8), %xmm12
movsd -0x8(%r8,%r14,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, -0x8(%r8,%r15,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, -0x8(%r8,%r14,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x41157
cmpq %r14, 0x30(%rsp)
jae 0x4121d
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
xorl %edx, %edx
movsd (%rbx,%rdx,8), %xmm12
movq (%rsi,%rdx,8), %r8
movsd -0x8(%r8,%r14,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%rbx,%rdx,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, -0x8(%r8,%r14,8)
incq %rdx
cmpq %rdx, %r10
jne 0x411c5
cmpq 0x68(%rsp), %r14
jge 0x41291
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
movq -0x8(%r13,%r14,8), %rdx
addq %rax, %rdx
xorl %r8d, %r8d
movsd (%r11,%r8,8), %xmm12
movsd (%rdx,%r8,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r11,%r8,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%rdx,%r8,8)
incq %r8
leal (%r8,%r14), %ebp
cmpl %r12d, %ebp
jl 0x41239
jmp 0x4129b
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
movq 0x28(%rsp), %rdx
movq 0x8(%rdx), %rdx
xorl %r8d, %r8d
movq (%rdx,%r8,8), %rbp
movsd -0x8(%rbp,%r15,8), %xmm12
movsd -0x8(%rbp,%r14,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, -0x8(%rbp,%r15,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, -0x8(%rbp,%r14,8)
incq %r8
cmpq %r8, %rdi
jne 0x412a7
incq %r14
incq %r10
addq $0x8, %rax
addq $0x8, %r11
cmpq 0x70(%rsp), %r14
jne 0x40fb7
movq 0x60(%rsp), %r14
incq %r14
incq %rcx
movq 0x58(%rsp), %rax
addq $0x8, %rax
addq $0x8, %rsi
movq 0x50(%rsp), %rdx
addq $0x8, %rdx
movq 0x48(%rsp), %r9
movq 0x30(%rsp), %r15
cmpq %r9, %r15
jne 0x40f8c
testl %r12d, %r12d
movq 0x20(%rsp), %r14
movq 0x10(%rsp), %rbp
jle 0x41391
movq 0x8(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
movsd (%r14,%rcx,8), %xmm8
addsd (%rbp,%rcx,8), %xmm8
movsd %xmm8, (%r14,%rcx,8)
movsd %xmm8, (%rax,%rcx,8)
movq $0x0, (%rbp,%rcx,8)
incq %rcx
cmpq %rcx, %rdi
jne 0x41367
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
cmpl $0x33, %eax
jne 0x40ef1
movq %rbp, %rdi
callq 0x3a180
movq %r14, %rdi
callq 0x3a180
movq %r13, %rdi
movq 0x38(%rsp), %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a14b