// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %r8, 0x10(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movl %esi, %ebp
movq %rdi, %rbx
movslq %esi, %r14
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x44ea8
movq %rax, %r15
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x44ea8
pushq $0x1
popq %r11
xorl %edx, %edx
testl %r14d, %r14d
cmovgl %ebp, %edx
leal 0x1(%r14), %ecx
leal 0x1(%rdx), %esi
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
movq %r11, %r8
cmpq %rsi, %r8
je 0x45972
movq (%r12,%r8,8), %r9
movq %r11, %r10
cmpq %r10, %rcx
je 0x45969
andq $0x0, (%r9,%r10,8)
incq %r10
jmp 0x4595a
movq %rdi, (%r9,%r8,8)
incq %r8
jmp 0x4594e
movl %edx, %edx
movq %rdx, 0x28(%rsp)
negq %rdx
pushq $0x1
popq %rsi
leaq (%rdx,%rsi), %rdi
cmpq $0x1, %rdi
je 0x459a9
movq (%rbx,%rsi,8), %rdi
movsd (%rdi,%rsi,8), %xmm0
movsd %xmm0, (%r13,%rsi,8)
movsd %xmm0, (%r15,%rsi,8)
andq $0x0, (%rax,%rsi,8)
incq %rsi
jmp 0x4597f
movq 0x10(%rsp), %rdx
andl $0x0, (%rdx)
movl %ebp, %edx
imull %ebp, %edx
cvtsi2sd %edx, %xmm0
pushq $0x1
popq %rsi
xorl %edi, %edi
movapd 0xb879(%rip), %xmm1     # 0x51240
xorpd %xmm2, %xmm2
movsd 0xe255(%rip), %xmm3     # 0x53c28
movsd 0xb455(%rip), %xmm4     # 0x50e30
movsd 0x5665(%rip), %xmm5     # 0x4b048
movapd 0x56d5(%rip), %xmm6     # 0x4b0c0
movsd 0x567d(%rip), %xmm7     # 0x4b070
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
cmpl $0x33, %esi
je 0x45de9
xorpd %xmm8, %xmm8
pushq $0x1
popq %rdx
pushq $0x2
popq %r8
cmpq %r14, %rdx
jge 0x45a40
movq %r8, %r9
cmpl %ebp, %r9d
jg 0x45a38
movq (%rbx,%rdx,8), %r10
movsd (%r10,%r9,8), %xmm9
andpd %xmm1, %xmm9
addsd %xmm9, %xmm8
incq %r9
jmp 0x45a1a
incq %rdx
incq %r8
jmp 0x45a12
ucomisd %xmm2, %xmm8
jne 0x45a4d
jnp 0x45e51
mulsd %xmm3, %xmm8
cmpl $0x4, %esi
jb 0x45a5e
xorpd %xmm8, %xmm8
jmp 0x45a63
divsd %xmm0, %xmm8
pushq $0x3
popq %r15
xorl %r10d, %r10d
pushq $0x1
popq %r9
pushq $0x2
popq %rdx
movq %rdx, 0x8(%rsp)
cmpq %r14, %r9
jge 0x45dad
movq %r15, 0x30(%rsp)
movq 0x8(%rsp), %rdx
cmpl %ebp, %edx
jg 0x45d8f
movq (%rbx,%r9,8), %r8
movsd (%r8,%rdx,8), %xmm11
movapd %xmm11, %xmm10
andpd %xmm1, %xmm10
movapd %xmm10, %xmm9
mulsd %xmm4, %xmm9
cmpl $0x5, %esi
jb 0x45afc
movsd (%r13,%r9,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x45afc
jp 0x45afc
movsd (%r13,%rdx,8), %xmm12
andpd %xmm1, %xmm12
movapd %xmm9, %xmm13
addsd %xmm12, %xmm13
ucomisd %xmm12, %xmm13
jne 0x45afc
jp 0x45afc
andq $0x0, (%r8,%rdx,8)
jmp 0x45d84
ucomisd %xmm8, %xmm10
jbe 0x45d84
movsd (%r13,%rdx,8), %xmm10
subsd (%r13,%r9,8), %xmm10
movapd %xmm10, %xmm12
andpd %xmm1, %xmm12
addsd %xmm12, %xmm9
ucomisd %xmm12, %xmm9
jne 0x45b39
jp 0x45b39
movapd %xmm11, %xmm12
divsd %xmm10, %xmm12
jmp 0x45b77
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 0x45b77
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 (%rax,%r9,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, (%rax,%r9,8)
movsd (%rax,%rdx,8), %xmm12
addsd %xmm11, %xmm12
movsd %xmm12, (%rax,%rdx,8)
movsd (%r13,%r9,8), %xmm12
subsd %xmm11, %xmm12
movsd %xmm12, (%r13,%r9,8)
addsd (%r13,%rdx,8), %xmm11
movsd %xmm11, (%r13,%rdx,8)
andq $0x0, (%r8,%rdx,8)
divsd %xmm13, %xmm10
movapd %xmm9, %xmm11
xorpd %xmm6, %xmm11
xorl %r11d, %r11d
cmpq %r11, %r10
je 0x45c62
movq 0x8(%rbx,%r11), %r14
movsd (%r14,%r9,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,%r9,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdx,8)
addq $0x8, %r11
jmp 0x45c08
movq 0x8(%rsp), %r11
cmpq %rdx, %r11
jae 0x45cbf
movsd (%r8,%r11,8), %xmm12
movq (%rbx,%r11,8), %r14
movsd (%r14,%rdx,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r8,%r11,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%rdx,8)
incq %r11
jmp 0x45c67
movq %r15, %r11
leal -0x1(%r11), %r14d
cmpl %ebp, %r14d
jge 0x45d1e
movsd (%r8,%r11,8), %xmm12
movq (%rbx,%rdx,8), %r14
movsd (%r14,%r11,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r8,%r11,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r14,%r11,8)
incq %r11
jmp 0x45cc2
pushq $0x1
popq %r8
cmpq %r8, %rcx
je 0x45d7a
movq (%r12,%r8,8), %r11
movsd (%r11,%r9,8), %xmm12
movsd (%r11,%rdx,8), %xmm13
movapd %xmm12, %xmm14
mulsd %xmm10, %xmm14
addsd %xmm13, %xmm14
mulsd %xmm11, %xmm14
addsd %xmm12, %xmm14
movsd %xmm14, (%r11,%r9,8)
movapd %xmm13, %xmm14
mulsd %xmm10, %xmm14
subsd %xmm14, %xmm12
mulsd %xmm9, %xmm12
addsd %xmm13, %xmm12
movsd %xmm12, (%r11,%rdx,8)
incq %r8
jmp 0x45d22
incl %edi
movq 0x10(%rsp), %r8
movl %edi, (%r8)
incq %rdx
incq %r15
jmp 0x45a89
incq %r9
incq 0x8(%rsp)
addq $0x8, %r10
movq 0x30(%rsp), %r15
incq %r15
movq 0x20(%rsp), %r14
jmp 0x45a76
xorl %edx, %edx
movq 0x18(%rsp), %r15
cmpq %rdx, 0x28(%rsp)
je 0x45de2
movsd 0x8(%rax,%rdx,8), %xmm8
addsd 0x8(%r15,%rdx,8), %xmm8
movsd %xmm8, 0x8(%r15,%rdx,8)
movsd %xmm8, 0x8(%r13,%rdx,8)
andq $0x0, 0x8(%rax,%rdx,8)
incq %rdx
jmp 0x45db4
incl %esi
jmp 0x459fd
cmpl $0x1e, %ebp
pushq $0x1e
popq %r15
cmovll %ebp, %r15d
movslq %r15d, %r12
incl %r15d
pushq $0x1
popq %r13
leaq 0x12388(%rip), %r14     # 0x5818d
cmpq %r12, %r13
jg 0x45e37
pushq $0x1
popq %rbp
cmpq %rbp, %r15
je 0x45e2a
movq (%rbx,%r13,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r14, %rdi
movb $0x1, %al
callq 0x20f0
incq %rbp
jmp 0x45e0d
pushq $0xa
popq %rdi
callq 0x2060
incq %r13
jmp 0x45e05
leaq 0x12355(%rip), %rdi     # 0x58193
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44d90
pushq $0x1
popq %rbx
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x45405
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x45405
nop