// File: /workspace/github_cpp_makefile_star2_O3/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 0xe8(%rsp), %rax
xorl %ecx, %ecx
movdqa 0xf4bc(%rip), %xmm4     # 0x14010
movdqa 0xf4c4(%rip), %xmm0     # 0x14020
movdqa 0xf4cc(%rip), %xmm1     # 0x14030
pshufd $0xf5, %xmm1, %xmm2     # xmm2 = xmm1[1,1,3,3]
movq 0xf50f(%rip), %xmm5     # 0x14080
movdqa 0xf4c7(%rip), %xmm3     # 0x14040
xorl %edx, %edx
leaq -0x8(%rcx), %rsi
xorl %edi, %edi
movdqa %xmm4, %xmm6
movdqa %xmm6, %xmm7
pxor %xmm0, %xmm7
movdqa %xmm1, %xmm8
pcmpgtd %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
pcmpeqd %xmm2, %xmm7
pand %xmm8, %xmm7
movd %xmm7, %r8d
testb $0x1, %r8b
je 0x4bc6
movdqa %xmm5, %xmm8
cmpq %rdi, %rcx
je 0x4bbf
pxor %xmm8, %xmm8
movq %xmm8, -0x8(%rax,%rdi)
pextrw $0x4, %xmm7, %r8d
testb $0x1, %r8b
je 0x4be4
movdqa %xmm5, %xmm7
cmpq %rdi, %rsi
je 0x4bdf
pxor %xmm7, %xmm7
movq %xmm7, (%rax,%rdi)
paddq %xmm3, %xmm6
addq $0x10, %rdi
cmpq $0x20, %rdi
jne 0x4b85
incq %rdx
addq $0x8, %rcx
addq $0x18, %rax
cmpq $0x3, %rdx
jne 0x4b7b
leaq 0x10(%rsp), %rax
xorl %ecx, %ecx
movdqa 0xf3fa(%rip), %xmm4     # 0x14010
movq 0xf462(%rip), %xmm5     # 0x14080
xorl %edx, %edx
leaq -0x8(%rcx), %rsi
xorl %edi, %edi
movdqa %xmm4, %xmm6
movdqa %xmm6, %xmm7
pxor %xmm0, %xmm7
movdqa %xmm1, %xmm8
pcmpgtd %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm7     # xmm7 = xmm7[1,1,3,3]
pcmpeqd %xmm2, %xmm7
pand %xmm8, %xmm7
movd %xmm7, %r8d
testb $0x1, %r8b
je 0x4c6b
movdqa %xmm5, %xmm8
cmpq %rdi, %rcx
je 0x4c64
pxor %xmm8, %xmm8
movq %xmm8, -0x8(%rax,%rdi)
pextrw $0x4, %xmm7, %r8d
testb $0x1, %r8b
je 0x4c89
movdqa %xmm5, %xmm7
cmpq %rdi, %rsi
je 0x4c84
pxor %xmm7, %xmm7
movq %xmm7, (%rax,%rdi)
paddq %xmm3, %xmm6
addq $0x10, %rdi
cmpq $0x20, %rdi
jne 0x4c2a
incq %rdx
addq $0x8, %rcx
addq $0x18, %rax
cmpq $0x3, %rdx
jne 0x4c20
xorl %eax, %eax
leaq 0x10(%rsp), %rcx
movdqa 0xf355(%rip), %xmm4     # 0x14010
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
movdqa %xmm4, %xmm5
movdqa %xmm5, %xmm6
pxor %xmm0, %xmm6
movdqa %xmm1, %xmm7
pcmpgtd %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
pcmpeqd %xmm2, %xmm6
pand %xmm7, %xmm6
movd %xmm6, %r8d
testb $0x1, %r8b
je 0x4cfa
xorps %xmm7, %xmm7
cvtsi2sd %esi, %xmm7
movsd %xmm7, -0x8(%rcx,%rdi,8)
pextrw $0x4, %xmm6, %r8d
testb $0x1, %r8b
je 0x4d17
leal (%rdx,%rsi), %r8d
xorps %xmm6, %xmm6
cvtsi2sd %r8d, %xmm6
movsd %xmm6, (%rcx,%rdi,8)
addq $0x2, %rdi
paddq %xmm3, %xmm5
addl %eax, %esi
cmpq $0x4, %rdi
jne 0x4cc5
incq %rdx
addl $0x2, %eax
addq $0x18, %rcx
cmpq $0x3, %rdx
jne 0x4cbd
leaq 0x98(%rsp), %r14
leaq 0xe0(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5477
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x5477
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 0x4d7a
incq %rdx
incl %eax
addq $0x18, %r14
addq $0x18, %r15
cmpq $0x3, %rdx
jne 0x4d76
andb %cl, %bpl
jne 0x4e3e
testb %cl, %cl
leaq 0x50(%rsp), %rax
leaq 0x98(%rsp), %r14
cmovneq %rax, %r14
leaq 0xf3f0(%rip), %rax      # 0x141d6
leaq 0xf375(%rip), %rsi      # 0x14162
cmovneq %rax, %rsi
movl $0x59, %edx
movq %rbx, %rdi
callq 0x42a0
leaq 0xf3b7(%rip), %rsi      # 0x141bc
movl $0xd, %edx
movq %rbx, %rdi
callq 0x42a0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x54f1
leaq 0xf3a4(%rip), %rsi      # 0x141ca
movl $0xb, %edx
movq %rbx, %rdi
callq 0x42a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x54f1
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq