// File: WeihuaZhu[P]hpc_prog2/seq_tests.cpp
// Function: SequentialTest_Jacobi1_Test::TestBody()
TEST(SequentialTest, Jacobi1) {
    // 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 b[4] =  {6., 25., -11., 15.};
    double x[4];
    double expected_x[4] = {1.0,  2.0, -1.0, 1.0};
    int n = 4;

    // testing sequential matrix multiplication
    jacobi(n, A, b, x);

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

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x3aec2(%rip), %rsi     # 0x4b100
movl $0x80, %edx
callq 0xe840
movq 0x3af81(%rip), %rax     # 0x4b1d0
movq %rax, 0xb0(%rsp)
movq 0x3af7a(%rip), %rax     # 0x4b1d8
movq %rax, 0xb8(%rsp)
movq 0x3af73(%rip), %rax     # 0x4b1e0
movq %rax, 0xc0(%rsp)
movq 0x3af6c(%rip), %rax     # 0x4b1e8
movq %rax, 0xc8(%rsp)
movq 0x3af85(%rip), %rax     # 0x4b210
movq %rax, 0x70(%rsp)
movq 0x3af81(%rip), %rax     # 0x4b218
movq %rax, 0x78(%rsp)
movq 0x3af7d(%rip), %rax     # 0x4b220
movq %rax, 0x80(%rsp)
movq 0x3af76(%rip), %rax     # 0x4b228
movq %rax, 0x88(%rsp)
movl $0x4, 0x6c(%rsp)
movl 0x6c(%rsp), %edi
leaq 0xd0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movl $0x64, %r8d
movsd 0x3ad1c(%rip), %xmm0    # 0x4b008
callq 0x4a960
movl $0x0, 0x68(%rsp)
movl 0x68(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jge 0x1047f
movslq 0x68(%rsp), %rax
movsd 0x70(%rsp,%rax,8), %xmm0
movsd 0x90(%rsp,%rax,8), %xmm1
leaq 0x3ad50(%rip), %rsi     # 0x4b072
leaq 0x3ad52(%rip), %rdx     # 0x4b07b
leaq 0x3ad0f(%rip), %rcx     # 0x4b03f
leaq 0x58(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movsd 0x3acc6(%rip), %xmm2    # 0x4b008
callq 0x19e20
movq 0x28(%rsp), %rdi
callq 0x104f0
movb %al, 0x37(%rsp)
jmp 0x10357
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x10361
jmp 0x10379
jmp 0x10459
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x10473
leaq 0x40(%rsp), %rdi
callq 0x192e0
jmp 0x10385
leaq 0x3acb9(%rip), %rsi     # 0x4b045
leaq 0x40(%rsp), %rdi
callq 0x10500
movq %rax, 0x20(%rsp)
jmp 0x1039d
movq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x10540
movq %rax, 0x18(%rsp)
jmp 0x103b3
movq 0x18(%rsp), %rdi
leaq 0x3ac92(%rip), %rsi     # 0x4b051
callq 0x10580
movq %rax, 0x10(%rsp)
jmp 0x103cb
leaq 0x58(%rsp), %rdi
callq 0x105c0
movq %rax, 0x8(%rsp)
jmp 0x103dc
movq 0x8(%rsp), %r8
leaq 0x3ac74(%rip), %rdx     # 0x4b05c
leaq 0x38(%rsp), %rdi
movl $0x1, %esi
movl $0x4d, %ecx
callq 0x16410
jmp 0x103fe
movq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x164e0
jmp 0x1040f
leaq 0x38(%rsp), %rdi
callq 0x164a0
leaq 0x40(%rsp), %rdi
callq 0x105d0
jmp 0x10459
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x1044d
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 0x10473
leaq 0x58(%rsp), %rdi
callq 0x105e0
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x102f9
leaq 0x58(%rsp), %rdi
callq 0x105e0
jmp 0x10487
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x50(%rsp), %rdi
callq 0xf410
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)