// File: /workspace/github_cpp_makefile_star2_O3/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 0x4e2c
incq %rcx
addq $0x10, %rax
cmpq $0x3, %rcx
jne 0x4e28
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movdqa %xmm0, 0x30(%rsp)
xorl %eax, %eax
movdqu 0x30(%rsp,%rax), %xmm0
movdqu (%rsp,%rax), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, 0x98(%rsp,%rax)
addq $0x10, %rax
cmpq $0x30, %rax
jne 0x4e5f
xorl %eax, %eax
movdqu (%rsp,%rax), %xmm0
movdqu 0x30(%rsp,%rax), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, 0x68(%rsp,%rax)
addq $0x10, %rax
cmpq $0x30, %rax
jne 0x4e83
movb $0x1, %al
leaq 0x98(%rsp), %rcx
leaq 0x68(%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 0x4ebc
incq %rsi
addq $0x10, %rcx
addq $0x10, %rdx
cmpq $0x3, %rsi
jne 0x4eb6
testb %dil, %dil
je 0x4fc0
testb %al, %al
je 0x5092
leaq 0xf8(%rsp), %rax
xorl %ecx, %ecx
movdqa 0xf0f8(%rip), %xmm0     # 0x14010
movd %ecx, %xmm1
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
paddd %xmm0, %xmm1
movdqu %xmm1, (%rax)
incq %rcx
addq $0x10, %rax
cmpq $0x3, %rcx
jne 0x4f18
xorl %eax, %eax
movdqu (%rsp,%rax), %xmm0
movdqu 0xf8(%rsp,%rax), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, 0xc8(%rsp,%rax)
addq $0x10, %rax
cmpq $0x30, %rax
jne 0x4f38
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 0x4f74
incq %rdx
incq %rax
addq $0x10, %rcx
cmpq $0x3, %rdx
jne 0x4f6f
testb %bpl, %bpl
jne 0x5166
leaq 0xf2de(%rip), %rsi      # 0x1428c
movl $0x26, %edx
movq %rbx, %rdi
callq 0x42d0
jmp 0x5166
leaq 0xf1dd(%rip), %rsi      # 0x141a4
movl $0x27, %edx
movq %rbx, %rdi
callq 0x42d0
leaq 0x98(%rsp), %r15
xorl %r12d, %r12d
leaq 0xf2d5(%rip), %r14      # 0x142bb
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x4fe9
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x4fe6
leaq 0xf299(%rip), %r14      # 0x142bb
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
leaq 0xf193(%rip), %rsi      # 0x141cc
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 0x504f
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x504c
leaq 0xf159(%rip), %rsi      # 0x141e1
movl $0x40, %edx
jmp 0x515c
leaq 0xf189(%rip), %rsi      # 0x14222
movl $0x27, %edx
movq %rbx, %rdi
callq 0x42d0
leaq 0x68(%rsp), %r15
xorl %r12d, %r12d
leaq 0xf206(%rip), %r14      # 0x142bb
xorl %r13d, %r13d
movl (%r15,%r13,4), %esi
movq %rbx, %rdi
callq 0x43f0
incq %r13
cmpq $0x4, %r13
jne 0x50b8
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x50b5
leaq 0xf1ca(%rip), %r14      # 0x142bb
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
leaq 0xf0c4(%rip), %rsi      # 0x141cc
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 0x511e
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42d0
incq %r12
addq $0x10, %r15
cmpq $0x3, %r12
jne 0x511b
leaq 0xf0f3(%rip), %rsi      # 0x1424a
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