// File: /workspace/github_cpp_makefile_star2_O1/ef-gy[P]libefgy/src/test-case/matrix.cpp
// Function: testAddition(std::ostream&)
bool testAddition(std::ostream &log) {
  matrix<int, 3, 4> m;
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 4; k++) {
      m[i][k] = i * k;
    }
  }

  matrix<int, 3, 4> n;

  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 4; k++) {
      n[i][k] = 0;
    }
  }

  // results of left and right addition of
  // neutral element to m
  matrix<int, 3, 4> leftNeutral = n + m;
  matrix<int, 3, 4> rightNeutral = m + n;

  // test addition of neutral element;
  bool allCorrectLeft = true;
  bool allCorrectRight = true;
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 4; k++) {
      allCorrectLeft &= (leftNeutral[i][k] == (i * k));
      allCorrectRight &= (rightNeutral[i][k] == (i * k));
    }
  }
  if (!allCorrectLeft) {
    log << "n + m, where n is the neutral element: ";
    for (int i = 0; i < 3; i++) {
      for (int k = 0; k < 4; k++) {
        log << leftNeutral[i][k];
      }
      log << "\n";
    }
    log << "\n";
    log << "m (original matrix):";
    for (int i = 0; i < 3; i++) {
      for (int k = 0; k < 4; k++) {
        log << m[i][k];
      }
      log << "\n";
    }

    log << "Unexpected result of left addition of neutral element to matrix.";
    return false;
  }
  if (!allCorrectRight) {
    log << "m + n, where n is the neutral element: ";
    for (int i = 0; i < 3; i++) {
      for (int k = 0; k < 4; k++) {
        log << rightNeutral[i][k];
      }
      log << "\n";
    }

    log << "\n";
    log << "m (original matrix):";
    for (int i = 0; i < 3; i++) {
      for (int k = 0; k < 4; k++) {
        log << m[i][k];
      }
      log << "\n";
    }
    log << "Unexpected result of right addition of neutral element to matrix.";
    return false;
  }

  // another test for addition of two non-neutral elements
  matrix<int, 3, 4> m2;

  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 4; k++) {
      m2[i][k] = i + k;
    }
  }

  matrix<int, 3, 4> sum = m + m2;

  bool allCorrectSum = true;
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      allCorrectSum &= (sum[i][k] == (i * k) + (i + k));
    }
  }

  if (!allCorrectSum) {
    log << "Unexpected result adding two matrices.";
    return false;
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
movq %rsp, %rax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
movl %edx, (%rax,%rsi,4)
incq %rsi
addl %ecx, %edx
cmpq $0x4, %rsi
jne 0x4e3c
incq %rcx
addq $0x10, %rax
cmpq $0x3, %rcx
jne 0x4e38
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rax
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x60(%rsp), %rcx
movq %rsp, %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rdx,%rdi,4), %r8d
addl (%rax,%rdi,4), %r8d
movl %r8d, (%rcx,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x4e79
incq %rsi
addq $0x10, %rcx
addq $0x10, %rdx
addq $0x10, %rax
cmpq $0x3, %rsi
jne 0x4e77
leaq 0x30(%rsp), %rax
leaq 0x90(%rsp), %rcx
movq %rsp, %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
addl (%rdx,%rdi,4), %r8d
movl %r8d, (%rax,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x4eb7
incq %rsi
addq $0x10, %rax
addq $0x10, %rcx
addq $0x10, %rdx
cmpq $0x3, %rsi
jne 0x4eb5
movb $0x1, %al
leaq 0x60(%rsp), %rcx
leaq 0x30(%rsp), %rdx
xorl %esi, %esi
movb $0x1, %dil
xorl %r8d, %r8d
xorl %r9d, %r9d
movl (%rcx,%r9,4), %r10d
cmpq %r10, %r8
sete %r10b
andb %r10b, %dil
movl (%rdx,%r9,4), %r10d
cmpq %r10, %r8
sete %r10b
andb %r10b, %al
incq %r9
addq %rsi, %r8
cmpq $0x4, %r9
jne 0x4ef8
incq %rsi
addq $0x10, %rcx
addq $0x10, %rdx
cmpq $0x3, %rsi
jne 0x4ef2
testb %dil, %dil
je 0x500e
testb %al, %al
je 0x50dd
leaq 0xf8(%rsp), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leal (%rcx,%rdx), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x4f4e
incq %rcx
addq $0x10, %rax
cmpq $0x3, %rcx
jne 0x4f4c
leaq 0xc8(%rsp), %rax
leaq 0xf8(%rsp), %rcx
movq %rsp, %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
addl (%rdx,%rdi,4), %r8d
movl %r8d, (%rax,%rdi,4)
incq %rdi
cmpq $0x4, %rdi
jne 0x4f81
incq %rsi
addq $0x10, %rax
addq $0x10, %rcx
addq $0x10, %rdx
cmpq $0x3, %rsi
jne 0x4f7f
movb $0x1, %bpl
movl $0x1, %eax
leaq 0xc8(%rsp), %rcx
xorl %edx, %edx
movq %rdx, %rsi
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
cmpq %r8, %rsi
sete %r8b
andb %r8b, %bpl
incq %rdi
addq %rax, %rsi
cmpq $0x3, %rdi
jne 0x4fc2
incq %rdx
incq %rax
addq $0x10, %rcx
cmpq $0x3, %rdx
jne 0x4fbd
testb %bpl, %bpl
jne 0x51b1
leaq 0xf280(%rip), %rsi      # 0x1427c
movl $0x26, %edx
movq %rbx, %rdi
callq 0x42d0
jmp 0x51b1
leaq 0xf17f(%rip), %rsi      # 0x14194
movl $0x27, %edx
movq %rbx, %rdi
callq 0x42d0
leaq 0x60(%rsp), %r15
xorl %r12d, %r12d
leaq 0xf27a(%rip), %r14      # 0x142ab
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x5034
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x5031
leaq 0xf23e(%rip), %r14      # 0x142ab
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
leaq 0xf138(%rip), %rsi      # 0x141bc
movl $0x14, %edx
movq %rbx, %rdi
callq 0x42d0
movq %rsp, %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x509a
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x5097
leaq 0xf0fe(%rip), %rsi      # 0x141d1
movl $0x40, %edx
jmp 0x51a7
leaq 0xf12e(%rip), %rsi      # 0x14212
movl $0x27, %edx
movq %rbx, %rdi
callq 0x42d0
leaq 0x30(%rsp), %r15
xorl %r12d, %r12d
leaq 0xf1ab(%rip), %r14      # 0x142ab
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x5103
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x5100
leaq 0xf16f(%rip), %r14      # 0x142ab
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
leaq 0xf069(%rip), %rsi      # 0x141bc
movl $0x14, %edx
movq %rbx, %rdi
callq 0x42d0
movq %rsp, %r15
xorl %r12d, %r12d
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x5169
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x5166
leaq 0xf098(%rip), %rsi      # 0x1423a
movl $0x41, %edx
movq %rbx, %rdi
callq 0x42d0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq