// File: WeihuaZhu[P]hpc_prog2/seq_tests.cpp
// Function: SequentialTest_MatrixVectorMult1_Test::TestBody()
TEST(SequentialTest, MatrixVectorMult1) {
    // simple 4 by 4 input matrix
    double A[4*4] = {10., -1., 2., 0.,
                           -1., 11., -1., 3.,
                           2., -1., 10., -1.,
                           0.0, 3., -1., 8.};
    double x[4] =  {6., 25., -11., 15.};
    double y[4];
    double expected_y[4] = {13.,  325., -138.,  206.};
    int n = 4;

    // testing sequential matrix multiplication
    matrix_vector_mult(n, &A[0], &x[0], &y[0]);

    // checking if all values are correct (up to some error value)
    for (int i = 0; i < n; ++i)
    {
        EXPECT_NEAR(expected_y[i], y[i], 1e-10) << " element y[" << i << "] is wrong";
    }
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x3b0b2(%rip), %rsi     # 0x4b080
movl $0x80, %edx
callq 0xe840
movq 0x3b1f1(%rip), %rax     # 0x4b1d0
movq %rax, 0xb0(%rsp)
movq 0x3b1ea(%rip), %rax     # 0x4b1d8
movq %rax, 0xb8(%rsp)
movq 0x3b1e3(%rip), %rax     # 0x4b1e0
movq %rax, 0xc0(%rsp)
movq 0x3b1dc(%rip), %rax     # 0x4b1e8
movq %rax, 0xc8(%rsp)
movq 0x3b1d5(%rip), %rax     # 0x4b1f0
movq %rax, 0x70(%rsp)
movq 0x3b1d1(%rip), %rax     # 0x4b1f8
movq %rax, 0x78(%rsp)
movq 0x3b1cd(%rip), %rax     # 0x4b200
movq %rax, 0x80(%rsp)
movq 0x3b1c6(%rip), %rax     # 0x4b208
movq %rax, 0x88(%rsp)
movl $0x4, 0x6c(%rsp)
movl 0x6c(%rsp), %edi
leaq 0xd0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0x4a7e0
movl $0x0, 0x68(%rsp)
movl 0x68(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jge 0x10201
movslq 0x68(%rsp), %rax
movsd 0x70(%rsp,%rax,8), %xmm0
movsd 0x90(%rsp,%rax,8), %xmm1
leaq 0x3af8d(%rip), %rsi     # 0x4b031
leaq 0x3af8f(%rip), %rdx     # 0x4b03a
leaq 0x3af8d(%rip), %rcx     # 0x4b03f
leaq 0x58(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movsd 0x3af44(%rip), %xmm2    # 0x4b008
callq 0x19e20
movq 0x28(%rsp), %rdi
callq 0x104f0
movb %al, 0x37(%rsp)
jmp 0x100d9
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x100e3
jmp 0x100fb
jmp 0x101db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x101f5
leaq 0x40(%rsp), %rdi
callq 0x192e0
jmp 0x10107
leaq 0x3af37(%rip), %rsi     # 0x4b045
leaq 0x40(%rsp), %rdi
callq 0x10500
movq %rax, 0x20(%rsp)
jmp 0x1011f
movq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x10540
movq %rax, 0x18(%rsp)
jmp 0x10135
movq 0x18(%rsp), %rdi
leaq 0x3af10(%rip), %rsi     # 0x4b051
callq 0x10580
movq %rax, 0x10(%rsp)
jmp 0x1014d
leaq 0x58(%rsp), %rdi
callq 0x105c0
movq %rax, 0x8(%rsp)
jmp 0x1015e
movq 0x8(%rsp), %r8
leaq 0x3aef2(%rip), %rdx     # 0x4b05c
leaq 0x38(%rsp), %rdi
movl $0x1, %esi
movl $0x37, %ecx
callq 0x16410
jmp 0x10180
movq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x164e0
jmp 0x10191
leaq 0x38(%rsp), %rdi
callq 0x164a0
leaq 0x40(%rsp), %rdi
callq 0x105d0
jmp 0x101db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x101cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x164a0
leaq 0x40(%rsp), %rdi
callq 0x105d0
jmp 0x101f5
leaq 0x58(%rsp), %rdi
callq 0x105e0
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1007b
leaq 0x58(%rsp), %rdi
callq 0x105e0
jmp 0x10209
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x50(%rsp), %rdi
callq 0xf410
nopw %cs:(%rax,%rax)