// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/RNBasics/RNSvd.cpp
// Function: gaps::clr_top_subdiag_elt(double*, int, int, double*, double*, int, int, int)
void clr_top_subdiag_elt(RNScalar * b,int p,int z,RNScalar * u,RNScalar * v,int m,int n,int min)
{
    int i;
    RNScalar x, r, hypot, cos, sin;

    for (i=p; ; i++) {
	/* figure out row rotation to zero out the subdiagonal element */
	x = REF2D(b,m,n,i,i);
	r = REF2D(b,m,n,i+1,i);
	hypot = fhypot(x,r);
	cos = x/hypot;
	sin = r/hypot;
	/* rotate the leading elements of the row */
	REF2D(b,m,n,i,i) = hypot;
	REF2D(b,m,n,i+1,i) = 0;
	/* rotate out the rest of the row */
	rotate_rows(i,i+1,cos,sin,b,i+1,(i+1==z)?1:2,m,n);
	/* accumulate transformation into columns of u */
	rotate_cols(i,i+1,cos,sin,u,0,m,m,min);

	/* end with a row rotation */
	if (i+1==z) break;

	/* figure out column rotation */
	x = REF2D(b,m,n,i,i+1);
	r = REF2D(b,m,n,i,i+2);
	hypot = fhypot(x,r);
	cos = x/hypot;
	sin = r/hypot;
	/* rotate the leading elements of the column */
	REF2D(b,m,n,i,i+1) = hypot;
	REF2D(b,m,n,i,i+2) = 0;
	/* rotate the rest of the column */
	rotate_cols(i+1,i+2,cos,sin,b,i+1,2,m,n);
	/* accumulate transformation into columns of v */
	rotate_rows(i+1,i+2,cos,sin,v,0,n,min,n);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl 0xd0(%rsp), %r10d
movslq 0xd8(%rsp), %r11
movl %r9d, 0xc(%rsp)
movl %r9d, %eax
movq %rax, 0x60(%rsp)
movslq %esi, %r13
movslq %r10d, %r9
movslq %edx, %rax
movq %rax, 0x28(%rsp)
leaq 0x1(%r13), %rax
imulq %r9, %rax
leaq (,%r13,8), %rdx
leaq (%rdx,%rax,8), %rdx
leaq (%rdi,%rdx), %rbx
leaq 0x8(,%r9,8), %rbp
leaq 0x2(%r13), %rsi
imulq %r9, %rsi
leaq (%r8,%rsi,8), %r12
leaq (%r8,%rax,8), %r14
movq %rbp, 0x78(%rsp)
imulq %r13, %rbp
addq %rdi, %rbp
leaq (%rcx,%r13,8), %rax
movq %rax, 0x30(%rsp)
shlq $0x3, %r11
addq %rdi, %rdx
addq $0x8, %rdx
xorpd %xmm6, %xmm6
movapd 0x30a87(%rip), %xmm7    # 0xa2020
leaq (,%r9,8), %r15
movq %rdi, 0x20(%rsp)
movq %r11, 0x18(%rsp)
movq %r9, 0x10(%rsp)
movl %r13d, %eax
imull %r10d, %eax
movslq %eax, %rcx
leaq (%rdi,%r13,8), %r8
movsd (%r8,%rcx,8), %xmm2
leaq 0x1(%r13), %rsi
movl %esi, %eax
imull %r10d, %eax
movslq %eax, %r10
movq %r8, 0x50(%rsp)
movsd (%r8,%r10,8), %xmm8
movapd %xmm8, %xmm1
mulsd %xmm8, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm6, %xmm0
movq %rdx, 0x38(%rsp)
movq %rsi, (%rsp)
jb 0x71607
sqrtsd %xmm0, %xmm0
jmp 0x7165f
movapd %xmm8, 0x40(%rsp)
movq %rcx, 0x70(%rsp)
movq %r10, 0x68(%rsp)
movapd %xmm2, 0x80(%rsp)
callq 0xe340
movapd 0x80(%rsp), %xmm2
movq 0x68(%rsp), %r10
movq 0x70(%rsp), %rcx
movapd 0x40(%rsp), %xmm8
movq (%rsp), %rsi
movapd 0x309d4(%rip), %xmm7    # 0xa2020
xorpd %xmm6, %xmm6
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r11
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %r8
movq %r13, %rax
imulq %r9, %rax
unpcklpd %xmm2, %xmm8            # xmm8 = xmm8[0],xmm2[0]
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
divpd %xmm1, %xmm8
movq 0x50(%rsp), %rdx
movsd %xmm0, (%rdx,%rcx,8)
movq $0x0, (%rdx,%r10,8)
xorl %ecx, %ecx
cmpq %r8, %rsi
sete %cl
negq %rcx
addq %rsi, %rcx
addq $0x2, %rcx
movapd %xmm8, %xmm0
xorpd %xmm7, %xmm0
movapd %xmm8, %xmm1
unpckhpd %xmm8, %xmm1            # xmm1 = xmm1[1],xmm8[1]
movl $0x1, %edx
movsd (%rbp,%rdx,8), %xmm2
movsd (%rbx,%rdx,8), %xmm3
movapd %xmm8, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm1, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%rbp,%rdx,8)
mulsd %xmm1, %xmm3
mulsd %xmm0, %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, (%rbx,%rdx,8)
leaq (%rdx,%r13), %rsi
incq %rsi
incq %rdx
cmpq %rcx, %rsi
jl 0x716b9
cmpl $0x0, 0xc(%rsp)
jle 0x71744
movapd %xmm8, %xmm1
shufpd $0x1, %xmm0, %xmm1      # xmm1 = xmm1[1],xmm0[0]
movq 0x30(%rsp), %rcx
movq 0x60(%rsp), %rdx
movsd (%rcx), %xmm0
movsd 0x8(%rcx), %xmm2
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
mulpd %xmm8, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
addpd %xmm2, %xmm0
movupd %xmm0, (%rcx)
addq %r11, %rcx
decq %rdx
jne 0x7171a
movq (%rsp), %rsi
cmpq %r8, %rsi
je 0x718a6
leaq (%rdi,%rax,8), %rax
movupd (%rax,%rsi,8), %xmm8
movapd %xmm8, %xmm1
mulpd %xmm8, %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm8, %xmm0
mulsd %xmm8, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm6, %xmm0
jb 0x71783
sqrtsd %xmm0, %xmm0
jmp 0x717bf
movapd %xmm8, 0x50(%rsp)
movq %rax, 0x40(%rsp)
callq 0xe340
movq 0x40(%rsp), %rax
movapd 0x50(%rsp), %xmm8
movq (%rsp), %rsi
movapd 0x30874(%rip), %xmm7    # 0xa2020
xorpd %xmm6, %xmm6
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r11
movq 0x20(%rsp), %rdi
movl 0xd0(%rsp), %r10d
movq 0x38(%rsp), %rdx
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
divpd %xmm1, %xmm8
movsd %xmm0, (%rax,%rsi,8)
movq $0x0, 0x10(%rax,%r13,8)
movapd %xmm8, %xmm0
unpckhpd %xmm8, %xmm0            # xmm0 = xmm0[1],xmm8[1]
movapd %xmm0, %xmm1
xorpd %xmm7, %xmm1
movapd %xmm1, %xmm2
unpcklpd %xmm8, %xmm2            # xmm2 = xmm2[0],xmm8[0]
leaq 0x2(%r13), %rax
movq %rdx, %rcx
movsd (%rcx), %xmm3
movsd 0x8(%rcx), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm8, %xmm4
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm2, %xmm3
addpd %xmm4, %xmm3
shufpd $0x1, %xmm3, %xmm3      # xmm3 = xmm3[1,0]
movupd %xmm3, (%rcx)
incq %r13
addq %r15, %rcx
cmpq %rax, %r13
jl 0x71809
testl %r10d, %r10d
jle 0x71884
xorl %eax, %eax
movsd (%r14,%rax,8), %xmm2
movsd (%r12,%rax,8), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm8, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%r14,%rax,8)
mulsd %xmm8, %xmm3
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, (%r12,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x71842
movq 0x78(%rsp), %rax
addq %rax, %rbx
addq %rax, %rbp
addq $0x8, 0x30(%rsp)
addq %rax, %rdx
addq %r15, %r12
addq %r15, %r14
movq %rsi, %r13
jmp 0x715b0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq