// File: /workspace/github_cpp_makefile_star2_O1/ef-gy[P]libefgy/src/test-case/transformation.cpp
// Function: testIdentity(std::ostream&)
bool testIdentity(std::ostream &log) {
  identity<double, 3> id;

  linear<double, 3> phi;

  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      phi.matrix[i][k] = i * k;
    }
  }

  linear<double, 3> leftProduct = id * phi;
  linear<double, 3> rightProduct = phi * id;

  bool leftProductOK = true;
  bool rightProductOK = true;

  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      leftProductOK &= (leftProduct.matrix[i][k] == i * k);
      rightProductOK &= (rightProduct.matrix[i][k] == i * k);
    }
  }

  if (!leftProductOK) {
    log << "Incorrect product of identity transformation with non-trivial "
           "transformation (id * phi).\n";
    log << "\n Expected: \n";
    log << phi.matrix;
    log << "\n Actual: \n";
    log << leftProduct.matrix;

    return false;
  }
  if (!rightProductOK) {
    log << "Incorrect product of non-trivial transformation with identity "
           "transformation (phi * id).\n";
    log << "\n Expected: \n";
    log << phi.matrix;
    log << "\n Actual: \n";
    log << rightProduct.matrix;

    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
leaq 0xe0(%rsp), %rax
xorl %ecx, %ecx
movsd 0xf4b4(%rip), %xmm0     # 0x14008
xorl %edx, %edx
movapd %xmm0, %xmm1
cmpq %rdx, %rcx
je 0x4b63
xorpd %xmm1, %xmm1
movsd %xmm1, (%rax,%rdx,8)
incq %rdx
cmpq $0x3, %rdx
jne 0x4b56
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4b54
leaq 0x8(%rsp), %rax
xorl %ecx, %ecx
movsd 0xf47b(%rip), %xmm0     # 0x14008
xorl %edx, %edx
movapd %xmm0, %xmm1
cmpq %rdx, %rcx
je 0x4b9c
xorpd %xmm1, %xmm1
movsd %xmm1, (%rax,%rdx,8)
incq %rdx
cmpq $0x3, %rdx
jne 0x4b8f
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4b8d
leaq 0x8(%rsp), %rax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
addl %ecx, %edx
cmpq $0x3, %rsi
jne 0x4bc2
incq %rcx
addq $0x18, %rax
cmpq $0x3, %rcx
jne 0x4bbe
leaq 0x98(%rsp), %r14
leaq 0xe0(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x135b8
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x135b8
movb $0x1, %bpl
xorl %eax, %eax
xorl %edx, %edx
movb $0x1, %cl
xorl %esi, %esi
xorl %edi, %edi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
ucomisd (%r14,%rdi,8), %xmm0
setnp %r8b
sete %r9b
andb %r8b, %r9b
andb %r9b, %cl
ucomisd (%r15,%rdi,8), %xmm0
setnp %r8b
sete %r9b
andb %r8b, %r9b
andb %r9b, %bpl
incq %rdi
addl %eax, %esi
cmpq $0x3, %rdi
jne 0x4c29
incq %rdx
incl %eax
addq $0x18, %r14
addq $0x18, %r15
cmpq $0x3, %rdx
jne 0x4c25
andb %cl, %bpl
jne 0x4ced
testb %cl, %cl
leaq 0x50(%rsp), %rax
leaq 0x98(%rsp), %r14
cmovneq %rax, %r14
leaq 0xf4f9(%rip), %rax      # 0x1418e
leaq 0xf47e(%rip), %rsi      # 0x1411a
cmovneq %rax, %rsi
movl $0x59, %edx
movq %rbx, %rdi
callq 0x42a0
leaq 0xf4c0(%rip), %rsi      # 0x14174
movl $0xd, %edx
movq %rbx, %rdi
callq 0x42a0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5274
leaq 0xf4ad(%rip), %rsi      # 0x14182
movl $0xb, %edx
movq %rbx, %rdi
callq 0x42a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5274
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq