// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/jacobi.c
// Function: jacobi
void jacobi(double **a, int n, double d[], double **v, int *nrot)
{
  int j,iq,ip,i;
  double tresh,theta,tau,t,sm,s,h,g,c,*b,*z;

  b=dvector(1,n);
  z=dvector(1,n);
  for (ip=1;ip<=n;ip++) {
    for (iq=1;iq<=n;iq++) v[ip][iq]=0.0;
    v[ip][ip]=1.0;
  }
  for (ip=1;ip<=n;ip++) {
    b[ip]=d[ip]=a[ip][ip];
    z[ip]=0.0;
  }
  *nrot=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 += fabs(a[ip][iq]);
    }
    if (sm == 0.0) {
      free_dvector(z,1,n);
      free_dvector(b,1,n);
      return;
    }
    if (i < 4)
      tresh=0.2*sm/(n*n);
    else
      tresh=0.0;
    for (ip=1;ip<=n-1;ip++) {
      for (iq=ip+1;iq<=n;iq++) {
	g=100.0*fabs(a[ip][iq]);
	if (i > 4 && (double)(fabs(d[ip])+g) == (double)fabs(d[ip])
	    && (double)(fabs(d[iq])+g) == (double)fabs(d[iq]))
	  a[ip][iq]=0.0;
	else if (fabs(a[ip][iq]) > tresh) {
	  h=d[iq]-d[ip];
	  if ((double)(fabs(h)+g) == (double)fabs(h))
	    t=(a[ip][iq])/h;
	  else {
	    theta=0.5*h/(a[ip][iq]);
	    t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
	    if (theta < 0.0) t = -t;
	  }
	  c=1.0/sqrt(1+t*t);
	  s=t*c;
	  tau=s/(1.0+c);
	  h=t*a[ip][iq];
	  z[ip] -= h;
	  z[iq] += h;
	  d[ip] -= h;
	  d[iq] += h;
	  a[ip][iq]=0.0;
	  for (j=1;j<=ip-1;j++) {
	    ROTATE(a,j,ip,j,iq)
	      }
	  for (j=ip+1;j<=iq-1;j++) {
	    ROTATE(a,ip,j,j,iq)
	      }
	  for (j=iq+1;j<=n;j++) {
	    ROTATE(a,ip,j,iq,j)
	      }
	  for (j=1;j<=n;j++) {
	    ROTATE(v,j,ip,j,iq)
	      }
	  ++(*nrot);
	}
      }
    }
    for (ip=1;ip<=n;ip++) {
      b[ip] += z[ip];
      d[ip]=b[ip];
      z[ip]=0.0;
    }
  }
  int NSHOW=30; if(NSHOW>n)NSHOW=n;
  for(i=1; i<=NSHOW; i++){
    for(j=1; j<=NSHOW; j++)printf("%.5f ", a[i][j]);
    printf("\n");
  }
  nrerror("Too many iterations in routine jacobi");
}
#undef ROTATE
#undef NRANSI


// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, 0x40(%rsp)
movq %rcx, %rbp
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
movslq %esi, %r13
movl $0x1, %r12d
movl $0x1, %edi
movq %r13, %rsi
callq 0x4af55
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movq %r13, %rsi
callq 0x4af55
movq %rax, 0x18(%rsp)
movl %r15d, %r9d
movq %r13, 0x38(%rsp)
testl %r13d, %r13d
movq %r9, 0x28(%rsp)
movq %r14, 0x30(%rsp)
jle 0x4bb03
leaq (,%r9,8), %rax
movq %rax, 0x10(%rsp)
leal 0x1(%r15), %r13d
movq (%rbp,%r12,8), %r14
leaq 0x8(%r14), %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x2110
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r14,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x4ba94
testl %r15d, %r15d
movq 0x30(%rsp), %r14
movq 0x28(%rsp), %r9
movq 0x18(%rsp), %rsi
jle 0x4bb03
movl $0x1, %eax
movq 0x20(%rsp), %rdx
movq (%rbx,%rax,8), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
movsd %xmm0, (%rdx,%rax,8)
movq $0x0, (%rsi,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x4badd
jmp 0x4bb07
leal 0x1(%r15), %r13d
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
cmpl $0x2, %r15d
jl 0x4c01a
movl %r15d, %eax
imull %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movl %r13d, %eax
leaq 0x10(%rbx), %rcx
movq %rcx, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x1, 0xc(%rsp)
movapd 0xb7a1(%rip), %xmm1     # 0x572f0
xorpd %xmm2, %xmm2
movsd 0xe16d(%rip), %xmm3     # 0x59cc8
movsd 0xb37d(%rip), %xmm4     # 0x56ee0
movsd 0x55dd(%rip), %xmm5     # 0x51148
movapd 0x551d(%rip), %xmm6     # 0x51090
movsd 0x55f5(%rip), %xmm7     # 0x51170
movl $0x1, %ecx
movq %rax, %rdx
xorl %esi, %esi
xorpd %xmm8, %xmm8
movq (%rbx,%rcx,8), %rdi
addq %rsi, %rdi
incq %rcx
movl $0x2, %r8d
movsd (%rdi,%r8,8), %xmm9
andpd %xmm1, %xmm9
addsd %xmm9, %xmm8
incq %r8
cmpq %r8, %rdx
jne 0x4bb9a
addq $0x8, %rsi
decq %rdx
cmpq %r9, %rcx
jne 0x4bb8a
ucomisd %xmm2, %xmm8
jne 0x4bbcb
jnp 0x4c01a
mulsd %xmm3, %xmm8
movl 0xc(%rsp), %edi
cmpl $0x4, %edi
jb 0x4bbe0
xorpd %xmm8, %xmm8
jmp 0x4bbe5
divsd %xmm0, %xmm8
cmpl $0x2, %r15d
jl 0x4bfbc
movl $0x2, %edx
movl $0x1, %r11d
movl $0x10, %esi
movl $0x18, %r8d
movq 0x58(%rsp), %r10
xorl %ecx, %ecx
leaq 0x1(%r11), %r9
movq %r9, 0x48(%rsp)
movq (%rbx,%r11,8), %r12
movq %rsi, 0x68(%rsp)
leaq (%r12,%rsi), %r9
movq %r12, 0x10(%rsp)
addq %r8, %r12
movq %r8, 0x60(%rsp)
xorl %esi, %esi
movq %rdx, 0x70(%rsp)
movq 0x10(%rsp), %r13
movsd (%r13,%rdx,8), %xmm11
movapd %xmm11, %xmm10
andpd %xmm1, %xmm10
movapd %xmm10, %xmm9
mulsd %xmm4, %xmm9
cmpl $0x5, %edi
jb 0x4bcaa
movsd (%r14,%r11,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x4bcaa
jp 0x4bcaa
movsd (%r14,%rdx,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x4bcaa
jp 0x4bcaa
movq 0x10(%rsp), %r13
movq $0x0, (%r13,%rdx,8)
jmp 0x4bf70
ucomisd %xmm8, %xmm10
jbe 0x4bf70
movsd (%r14,%rdx,8), %xmm10
subsd (%r14,%r11,8), %xmm10
movapd %xmm10, %xmm12
andpd %xmm1, %xmm12
addsd %xmm12, %xmm9
ucomisd %xmm12, %xmm9
jne 0x4bce5
jp 0x4bce5
movapd %xmm11, %xmm12
divsd %xmm10, %xmm12
jmp 0x4bd23
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
jbe 0x4bd23
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
movq 0x18(%rsp), %rdi
movsd (%rdi,%r11,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, (%rdi,%r11,8)
movsd (%rdi,%rdx,8), %xmm12
addsd %xmm11, %xmm12
movsd %xmm12, (%rdi,%rdx,8)
movsd (%r14,%r11,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, (%r14,%r11,8)
addsd (%r14,%rdx,8), %xmm11
divsd %xmm13, %xmm10
movsd %xmm11, (%r14,%rdx,8)
movq 0x10(%rsp), %rdi
movq $0x0, (%rdi,%rdx,8)
cmpq $0x2, %r11
jb 0x4be1a
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
xorl %edi, %edi
movq 0x8(%rbx,%rdi), %r14
movsd (%r14,%r11,8), %xmm12
movsd (%r14,%rdx,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r14,%r11,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdx,8)
addq $0x8, %rdi
cmpq %rdi, %rcx
jne 0x4bdc2
cmpq %rdx, 0x48(%rsp)
jae 0x4be83
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
xorl %edi, %edi
movsd (%r9,%rdi,8), %xmm12
movq (%r10,%rdi,8), %r14
movsd (%r14,%rdx,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r9,%rdi,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdx,8)
incq %rdi
cmpq %rdi, %rsi
jne 0x4be2d
movq 0x38(%rsp), %rdi
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
cmpq %rdi, %rdx
jge 0x4bef6
movq (%rbx,%rdx,8), %r14
addq %r8, %r14
xorl %edi, %edi
movsd (%r12,%rdi,8), %xmm12
movsd (%r14,%rdi,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r12,%rdi,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdi,8)
incq %rdi
leal (%rdi,%rdx), %r13d
cmpl %r15d, %r13d
jl 0x4bea0
movl $0x1, %edi
movq (%rbp,%rdi,8), %r14
movsd (%r14,%r11,8), %xmm12
movsd (%r14,%rdx,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r14,%r11,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdx,8)
incq %rdi
cmpq %rdi, %rax
jne 0x4befb
movq 0x50(%rsp), %r14
incl %r14d
movq 0x40(%rsp), %rdi
movq %r14, 0x50(%rsp)
movl %r14d, (%rdi)
movq 0x30(%rsp), %r14
movl 0xc(%rsp), %edi
incq %rdx
incq %rsi
addq $0x8, %r8
addq $0x8, %r12
cmpq %rax, %rdx
jne 0x4bc36
movq 0x70(%rsp), %rdx
incq %rdx
addq $0x8, %rcx
addq $0x8, %r10
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
movq 0x60(%rsp), %r8
addq $0x8, %r8
movq 0x28(%rsp), %r9
movq 0x48(%rsp), %r11
cmpq %r9, %r11
jne 0x4bc0c
testl %r15d, %r15d
jle 0x4c001
movl $0x1, %ecx
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rsi
movsd (%rsi,%rcx,8), %xmm8
addsd (%rdx,%rcx,8), %xmm8
movsd %xmm8, (%rdx,%rcx,8)
movsd %xmm8, (%r14,%rcx,8)
movq $0x0, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x4bfd0
incl %edi
cmpl $0x33, %edi
jne 0x4c00c
jmp 0x4c051
incl %edi
cmpl $0x33, %edi
je 0x4c0b2
movl %edi, 0xc(%rsp)
cmpl $0x1, %r15d
jg 0x4bb7b
movl $0x1, %esi
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rbx
movq %rbx, %rdx
callq 0x4b50b
movl $0x1, %esi
movq 0x20(%rsp), %rdi
movq %rbx, %rdx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4b50b
testl %r15d, %r15d
jle 0x4c0b2
cmpl $0x1e, %r15d
movl $0x1e, %r12d
cmovbl %r15d, %r12d
incl %r12d
cmpq $0x1e, %r9
movl $0x1e, %r15d
cmovbq %r9, %r15
movl $0x1, %r13d
leaq 0x1219b(%rip), %r14     # 0x5e21d
xorl %ebp, %ebp
movq (%rbx,%r13,8), %rax
movsd 0x8(%rax,%rbp,8), %xmm0
movq %r14, %rdi
movb $0x1, %al
callq 0x20f0
incq %rbp
cmpq %rbp, %r15
jne 0x4c084
movl $0xa, %edi
callq 0x2060
incq %r13
cmpq %r12, %r13
jne 0x4c082
leaq 0x1216a(%rip), %rdi     # 0x5e223
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4ae38