// File: tomfunkhouser[P]gaps/pkgs/RNBasics/RNSvd.cpp
// Function: gaps::householder_zero_row(double*, double*, int, int, int, int, double*)
void householder_zero_row(RNScalar *a,RNScalar *v,int i,int j,int m,int n,RNScalar *hv)
{
    RNScalar scale, sigma,snorm, f, h, s, dot;
    int k,l;

    for (scale=0, k=j; k<n; k++) scale += ((RNScalar) fabs(REF2D(a,m,n,i,k)));
    if (!scale) return;

    for (k=j; k<n; k++) hv[k] = REF2D(a,m,n,i,k) / scale;
    for (sigma=0, k=j; k<n; k++) sigma += hv[k]*hv[k];

    f = hv[j];
    snorm = ((RNScalar) ((f > 0) ? -sqrt(sigma) : sqrt(sigma)));
    h = f*snorm - sigma;
    hv[j] = f - snorm;

    REF2D(a,m,n,i,j) = scale * snorm;
    for (k=j+1; k<n; k++) REF2D(a,m,n,i,k) = 0;

    for (k=i+1; k<m; k++) {
	for (dot=0, l=j; l<n; l++) dot += REF2D(a,m,n,k,l)*hv[l];
	s = dot/h;
	for (l=j; l<n; l++) REF2D(a,m,n,k,l) += s*hv[l];
    }

    for (k=0; k<n; k++) {
	for (dot=0, l=j; l<n; l++) dot += REF2D(v,n,n,l,k)*hv[l];
	s = dot/h;
	for (l=j; l<n; l++) REF2D(v,n,n,l,k) += s*hv[l];
    }
}

// Assembly:
subq $0x68, %rsp
movq 0x70(%rsp), %rax
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movl %edx, 0x54(%rsp)
movl %ecx, 0x50(%rsp)
movl %r8d, 0x4c(%rsp)
movl %r9d, 0x48(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd265e
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x54(%rsp), %ecx
addl 0xc(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x60c2f(%rip), %xmm1    # 0x133270
pand %xmm1, %xmm0
addsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd2616
movsd 0x40(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xd2674
jp 0xd2674
jmp 0xd2a32
movl 0x50(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd26c2
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x54(%rsp), %ecx
addl 0xc(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
divsd 0x40(%rsp), %xmm0
movq 0x70(%rsp), %rax
movslq 0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd267c
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd271c
movq 0x70(%rsp), %rax
movslq 0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x70(%rsp), %rax
movslq 0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x38(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd26d3
movq 0x70(%rsp), %rax
movslq 0x50(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd2769
movsd 0x38(%rsp), %xmm0
callq 0xf390
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, (%rsp)
jmp 0xd2779
movsd 0x38(%rsp), %xmm0
callq 0xf390
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm2
movsd 0x38(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
subsd 0x30(%rsp), %xmm0
movq 0x70(%rsp), %rax
movslq 0x50(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x40(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x54(%rsp), %ecx
addl 0x50(%rsp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd283b
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x54(%rsp), %ecx
addl 0xc(%rsp), %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd2807
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0xd2938
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd28b9
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0xc(%rsp), %ecx
addl 0x8(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x70(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x10(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xd2865
movsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd2926
movsd 0x18(%rsp), %xmm0
movq 0x70(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x60(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0xc(%rsp), %ecx
addl 0x8(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xd28d3
jmp 0xd2928
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd2846
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd2a32
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd29b3
movq 0x58(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x8(%rsp), %ecx
addl 0xc(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x70(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x10(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xd295f
movsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0xd2a20
movsd 0x18(%rsp), %xmm0
movq 0x70(%rsp), %rax
movslq 0x8(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x58(%rsp), %rax
movl 0x48(%rsp), %ecx
imull 0x8(%rsp), %ecx
addl 0xc(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xd29cd
jmp 0xd2a22
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xd2940
addq $0x68, %rsp
retq
nopw (%rax,%rax)