// File: IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: forwardsubst(Matrix const&, Vector const&)
Vector forwardsubst(const Matrix& A, const Vector& b)
{
	int n = length(b);
	Vector x(n);
	for (int i=1;i<=n;i++)
	{
		if (A(i,i)==0)
		{
			throw Exception("Singular Matrix",
									  "no solution to equation as coefficient matrix is singular");
		}
		x(i) = b(i);
		for (int j = 1; j<=(i-1); j++)
		{
			x(i) = x(i) - A(i,j)*x(j);
		}
		x(i) = x(i)/A(i,i);
	}
	return x;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0xa8(%rsp)
movq %rdi, %rax
movq %rax, 0xa0(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq %rdx, 0x120(%rsp)
movq 0x120(%rsp), %rdi
callq 0x4090
movq 0xa8(%rsp), %rdi
movl %eax, 0x11c(%rsp)
movb $0x0, 0x11b(%rsp)
movl 0x11c(%rsp), %esi
callq 0x2d70
movl $0x1, 0x114(%rsp)
movl 0x114(%rsp), %eax
cmpl 0x11c(%rsp), %eax
jg 0x8d73
movq 0x128(%rsp), %rdi
movl 0x114(%rsp), %edx
movl %edx, %esi
callq 0x7250
movq %rax, 0x98(%rsp)
jmp 0x89f1
movq 0x98(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8b82
jp 0x8b82
movb $0x1, 0xb6(%rsp)
movl $0x40, %edi
callq 0x2070
movq %rax, 0x88(%rsp)
leaq 0xdf(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x21c0
movq 0x90(%rsp), %rdx
leaq 0x9ade(%rip), %rsi      # 0x1252c
leaq 0xe0(%rsp), %rdi
callq 0x2110
jmp 0x8a5d
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x21c0
movq 0x80(%rsp), %rdx
leaq 0x9abb(%rip), %rsi      # 0x1253c
leaq 0xb8(%rsp), %rdi
callq 0x2110
jmp 0x8a90
movq 0x88(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x4d60
jmp 0x8aaf
movq 0x88(%rsp), %rdi
movb $0x0, 0xb6(%rsp)
leaq 0xd2da(%rip), %rsi      # 0x15da0
leaq -0x3d9d(%rip), %rdx     # 0x4d30
callq 0x2180
jmp 0x8dbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x8da2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x8b57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x8b3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x2080
leaq 0xb7(%rsp), %rdi
callq 0x20f0
leaq 0xe0(%rsp), %rdi
callq 0x2080
leaq 0xdf(%rsp), %rdi
callq 0x20f0
testb $0x1, 0xb6(%rsp)
jne 0x8b70
jmp 0x8b7d
movq 0x88(%rsp), %rdi
callq 0x20a0
jmp 0x8da2
movq 0x120(%rsp), %rdi
movl 0x114(%rsp), %esi
callq 0x3c10
movq %rax, 0x78(%rsp)
jmp 0x8b9d
movq 0xa8(%rsp), %rdi
movq 0x78(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x114(%rsp), %esi
callq 0x3ee0
movq %rax, 0x70(%rsp)
jmp 0x8bc7
movq 0x70(%rsp), %rax
movsd 0x68(%rsp), %xmm0
movsd %xmm0, (%rax)
movl $0x1, 0xb0(%rsp)
movl 0xb0(%rsp), %eax
movl 0x114(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x8cd3
movq 0xa8(%rsp), %rdi
movl 0x114(%rsp), %esi
callq 0x3ee0
movq %rax, 0x60(%rsp)
jmp 0x8c15
movq 0x60(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x128(%rsp), %rdi
movl 0x114(%rsp), %esi
movl 0xb0(%rsp), %edx
callq 0x7250
movq %rax, 0x58(%rsp)
jmp 0x8c46
movq 0xa8(%rsp), %rdi
movq 0x58(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movl 0xb0(%rsp), %esi
callq 0x3ee0
movq %rax, 0x48(%rsp)
jmp 0x8c70
movq 0xa8(%rsp), %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movq 0x48(%rsp), %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movl 0x114(%rsp), %esi
callq 0x3ee0
movq %rax, 0x38(%rsp)
jmp 0x8cae
movq 0x38(%rsp), %rax
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0x8be1
movq 0xa8(%rsp), %rdi
movl 0x114(%rsp), %esi
callq 0x3ee0
movq %rax, 0x28(%rsp)
jmp 0x8cee
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x128(%rsp), %rdi
movl 0x114(%rsp), %edx
movl %edx, %esi
callq 0x7250
movq %rax, 0x20(%rsp)
jmp 0x8d1a
movq 0xa8(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
movq 0x20(%rsp), %rax
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x114(%rsp), %esi
callq 0x3ee0
movq %rax, 0x10(%rsp)
jmp 0x8d4e
movq 0x10(%rsp), %rax
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x114(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x114(%rsp)
jmp 0x89bd
movb $0x1, 0x11b(%rsp)
testb $0x1, 0x11b(%rsp)
jne 0x8d92
movq 0xa8(%rsp), %rdi
callq 0x2ea0
movq 0xa0(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xa8(%rsp), %rdi
callq 0x2ea0
movq 0x108(%rsp), %rdi
callq 0x21b0
nopl (%rax)