// File: ef-gy[P]libefgy/src/test-case/transformation.cpp
// Function: testAffineConstruction(std::ostream&)
bool testAffineConstruction(std::ostream &log) {
  linear<double, 3> phi;

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

  affine<double, 3> psi(phi);

  bool allCorrect = true;

  // check if matrix entries of linear map are in place
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      allCorrect &= (psi.matrix[i][k] == i * k);
    }
  }

  // check for zeroes in the last row and column
  for (int i = 0; i < 3; i++) {
    allCorrect &= (psi.matrix[i][3] == 0);
    allCorrect &= (psi.matrix[3][i] == 0);
  }

  allCorrect &= (psi.matrix[3][3] == 1);

  if (!allCorrect) {
    log << "An error occurred in constructing an affine transformation";
    log << " from a linear map.\n";

    return false;
  } else {
    return true;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6a00
movl $0x0, -0x5c(%rbp)
cmpl $0x3, -0x5c(%rbp)
jge 0x5fa2
movl $0x0, -0x60(%rbp)
cmpl $0x3, -0x60(%rbp)
jge 0x5f95
movl -0x5c(%rbp), %eax
imull -0x60(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xf8(%rbp)
leaq -0x58(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0x6a40
movq %rax, %rdi
movslq -0x60(%rbp), %rsi
callq 0x6a70
movsd -0xf8(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x5f4c
jmp 0x5f97
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x5f3f
leaq -0xe0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6b80
movb $0x1, -0xe1(%rbp)
movl $0x0, -0xe8(%rbp)
cmpl $0x3, -0xe8(%rbp)
jge 0x606d
movl $0x0, -0xec(%rbp)
cmpl $0x3, -0xec(%rbp)
jge 0x6057
leaq -0xe0(%rbp), %rdi
movslq -0xe8(%rbp), %rsi
callq 0x6cb0
movq %rax, %rdi
movslq -0xec(%rbp), %rsi
callq 0x6ce0
movsd (%rax), %xmm0
movl -0xe8(%rbp), %eax
imull -0xec(%rbp), %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %ecx
movb -0xe1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xe1(%rbp)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x5fda
jmp 0x6059
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x5fc3
movl $0x0, -0xf0(%rbp)
cmpl $0x3, -0xf0(%rbp)
jge 0x613e
leaq -0xe0(%rbp), %rdi
movslq -0xf0(%rbp), %rsi
callq 0x6cb0
movq %rax, %rdi
movl $0x3, %esi
callq 0x6ce0
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %ecx
movb -0xe1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xe1(%rbp)
leaq -0xe0(%rbp), %rdi
movl $0x3, %esi
callq 0x6cb0
movq %rax, %rdi
movslq -0xf0(%rbp), %rsi
callq 0x6ce0
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %ecx
movb -0xe1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xe1(%rbp)
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x6077
leaq -0xe0(%rbp), %rdi
movl $0x3, %esi
callq 0x6cb0
movq %rax, %rdi
movl $0x3, %esi
callq 0x6ce0
movsd (%rax), %xmm0
movsd 0x2dea0(%rip), %xmm1    # 0x34008
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
andb $0x1, %al
movzbl %al, %ecx
movb -0xe1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xe1(%rbp)
testb $0x1, -0xe1(%rbp)
jne 0x61c3
movq -0x10(%rbp), %rdi
leaq 0x2e0f8(%rip), %rsi     # 0x342a0
callq 0x5350
movq -0x10(%rbp), %rdi
leaq 0x2e123(%rip), %rsi     # 0x342db
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x61c7
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)