// File: /workspace/github_cpp_makefile_star2_O2/schlagenhauf[P]lqr_solve/lqr_solve.cpp
// Function: main
int main() {
  Mtx A;
  Mtx B;
  Mtx Q;
  Mtx R;
  Mtx N;
  Mtx K;
  A.resize(4, 4);
  B.resize(4, 1);
  Q.resize(4, 4);
  R.resize(1, 1);
  N.resize(4, 1);

  A << 0.9904, 0.04772, 0.004251, 0.0007791, -0.3764, 0.9061, 0.167, 0.03211,
      0.002975, -0.004629, 0.9985, 0.04999, 0.1309, -0.1814, -0.06348, 0.9982;
  B << -0.00241, -0.09491, -9.478e-05, -0.0007852;
  Q << 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0;
  R << 100;
  N << 0, 0, 0, 0;

  if (!compGainMatrix(A, B, Q, R, N, &K))
    return 1;

  Eigen::IOFormat fmt(4, 0, ", ", "\n", "[", "]");
  std::cout << "K: " << K.format(fmt) << std::endl;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x3c0, %rsp            # imm = 0x3C0
xorps %xmm0, %xmm0
leaq -0x190(%rbp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movaps %xmm0, -0xd0(%rbp)
andq $0x0, -0xc0(%rbp)
movaps %xmm0, -0xb0(%rbp)
andq $0x0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
andq $0x0, -0x80(%rbp)
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movaps %xmm0, -0x170(%rbp)
andq $0x0, -0x160(%rbp)
pushq $0x4
popq %rdx
movq %rdx, %rsi
callq 0x3234
leaq -0xd0(%rbp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x3234
leaq -0xb0(%rbp), %rdi
pushq $0x4
popq %rdx
movq %rdx, %rsi
callq 0x3234
leaq -0x90(%rbp), %rdi
pushq $0x1
popq %rdx
movq %rdx, %rsi
callq 0x3234
leaq -0x70(%rbp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x3234
movabsq $0x3fefb15b573eab36, %rax # imm = 0x3FEFB15B573EAB36
leaq -0x3d8(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x2c8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x196c0
movabsq $0x3fa86ec17ebaf102, %rax # imm = 0x3FA86EC17EBAF102
leaq -0x110(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x2c8(%rbp), %rdi
callq 0x32b6
movabsq $0x3f71697f1f9acffa, %rcx # imm = 0x3F71697F1F9ACFFA
leaq -0xf0(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3f4987908299a2d4, %rcx # imm = 0x3F4987908299A2D4
leaq -0x150(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $-0x4027e90ff9724745, %rcx # imm = 0xBFD816F0068DB8BB
leaq -0x1d0(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3fecfec56d5cfaad, %rcx # imm = 0x3FECFEC56D5CFAAD
leaq -0x1b0(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3fc5604189374bc7, %rcx # imm = 0x3FC5604189374BC7
leaq -0x50(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3fa070b8cfbfc654, %rcx # imm = 0x3FA070B8CFBFC654
leaq -0x48(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3f685f06f6944674, %rcx # imm = 0x3F685F06F6944674
leaq -0x40(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $-0x408d0a24463065f9, %rcx # imm = 0xBF72F5DBB9CF9A07
leaq -0x38(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3feff3b645a1cac1, %rcx # imm = 0x3FEFF3B645A1CAC1
leaq -0x30(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3fa9984a0e410b63, %rcx # imm = 0x3FA9984A0E410B63
leaq -0x28(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3fc0c154c985f06f, %rcx # imm = 0x3FC0C154C985F06F
leaq -0x130(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $-0x4038c7e28240b780, %rcx # imm = 0xBFC7381D7DBF4880
leaq -0x128(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $-0x404fbfc6540cc78f, %rcx # imm = 0xBFB04039ABF33871
leaq -0x120(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3feff141205bc01a, %rcx # imm = 0x3FEFF141205BC01A
leaq -0x118(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x2c8(%rbp), %rdi
callq 0x1970e
movabsq $-0x409c41dd1a21ea36, %rax # imm = 0xBF63BE22E5DE15CA
leaq -0x3d8(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x2c8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x196c0
movabsq $-0x4047b3fa6defc7a4, %rax # imm = 0xBFB84C059210385C
leaq -0x110(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x2c8(%rbp), %rdi
callq 0x32b6
movabsq $-0x40e7276bffad74c3, %rcx # imm = 0xBF18D89400528B3D
leaq -0xf0(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $-0x40b64543d6ef657e, %rcx # imm = 0xBF49BABC29109A82
leaq -0x150(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x2c8(%rbp), %rdi
callq 0x1970e
leaq -0x3d8(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x2c8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x196c0
leaq -0x110(%rbp), %rsi
andq $0x0, (%rsi)
leaq -0x2c8(%rbp), %rdi
callq 0x32b6
leaq -0xf0(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x150(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x1d0(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x1b0(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x50(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x48(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x40(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x38(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
leaq -0x30(%rbp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x28(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x130(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x128(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x120(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x118(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x2c8(%rbp), %rbx
movq %rbx, %rdi
callq 0x1970e
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, (%rbx)
leaq -0x2e8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x2c8(%rbp), %rdx
callq 0x196c0
leaq -0x2e8(%rbp), %rdi
callq 0x1970e
leaq -0x3d8(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x2c8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x196c0
leaq -0x110(%rbp), %rsi
andq $0x0, (%rsi)
leaq -0x2c8(%rbp), %rdi
callq 0x32b6
leaq -0xf0(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x150(%rbp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x32b6
leaq -0x2c8(%rbp), %rdi
callq 0x1970e
leaq -0x190(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0x90(%rbp), %rcx
leaq -0x70(%rbp), %r8
leaq -0x170(%rbp), %rbx
movsd 0x17294(%rip), %xmm0    # 0x1a040
movq %rbx, %r9
callq 0x230c
testb %al, %al
je 0x2f28
leaq 0x17513(%rip), %rsi     # 0x1a2d6
leaq -0x2c8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x2030
leaq 0x174ff(%rip), %rsi     # 0x1a2d9
leaq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x2030
leaq 0x174ea(%rip), %rsi     # 0x1a2db
leaq -0xf0(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x2030
leaq 0x1942e(%rip), %rsi     # 0x1c236
leaq -0x150(%rbp), %r14
leaq -0x38(%rbp), %rdx
movq %r14, %rdi
callq 0x2030
leaq 0x174b8(%rip), %rsi     # 0x1a2da
leaq -0x1d0(%rbp), %r15
leaq -0x30(%rbp), %rdx
movq %r15, %rdi
callq 0x2030
leaq 0x1749e(%rip), %rsi     # 0x1a2da
leaq -0x1b0(%rbp), %r12
leaq -0x28(%rbp), %rdx
movq %r12, %rdi
callq 0x2030
leaq -0x3d8(%rbp), %rdi
pushq $0x4
popq %rsi
leaq -0x2c8(%rbp), %rcx
leaq -0x110(%rbp), %r8
leaq -0xf0(%rbp), %r9
xorl %edx, %edx
pushq $0x20
pushq %r12
pushq %r15
pushq %r14
callq 0x336c
addq $0x20, %rsp
leaq -0x1b0(%rbp), %rdi
callq 0x2040
leaq -0x1d0(%rbp), %rdi
callq 0x2040
leaq -0x150(%rbp), %rdi
callq 0x2040
leaq -0xf0(%rbp), %rdi
callq 0x2040
leaq -0x110(%rbp), %rdi
callq 0x2040
leaq -0x2c8(%rbp), %rdi
callq 0x2040
movq 0x4e100(%rip), %rdi     # 0x50fd0
leaq 0x17406(%rip), %rsi     # 0x1a2dd
callq 0x2130
movq %rax, %r15
leaq -0x2c0(%rbp), %r14
movq %rbx, -0x8(%r14)
leaq -0x3d8(%rbp), %rsi
movq %r14, %rdi
callq 0x19752
leaq -0x2c8(%rbp), %rsi
movq %r15, %rdi
callq 0x34d1
movq %rax, %rdi
callq 0x2060
movq %r14, %rdi
callq 0x34e6
leaq -0x3d8(%rbp), %rdi
callq 0x34e6
xorl %ebx, %ebx
jmp 0x2f2b
pushq $0x1
popq %rbx
movq -0x170(%rbp), %rdi
callq 0x2140
movq -0x70(%rbp), %rdi
callq 0x2140
movq -0x90(%rbp), %rdi
callq 0x2140
movq -0xb0(%rbp), %rdi
callq 0x2140
movq -0xd0(%rbp), %rdi
callq 0x2140
movq -0x190(%rbp), %rdi
callq 0x2140
movl %ebx, %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f84
movq %rax, %rbx
jmp 0x2fff
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x2040
jmp 0x2f9d
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x2040
jmp 0x2fae
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x2040
jmp 0x2fbf
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x2040
jmp 0x2fd0
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x2040
leaq -0x2c8(%rbp), %rdi
callq 0x2040
jmp 0x3071
movq %rax, %rbx
jmp 0x2fdc
jmp 0x306e
movq %rax, %rbx
movq %r14, %rdi
callq 0x34e6
leaq -0x3d8(%rbp), %rdi
callq 0x34e6
jmp 0x3071
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x306e
jmp 0x306e
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x306e
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x306e
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
jmp 0x305b
movq %rax, %rbx
leaq -0x2c8(%rbp), %rdi
callq 0x1970e
jmp 0x3071
jmp 0x306e
movq %rax, %rbx
movq -0x170(%rbp), %rdi
callq 0x2140
movq -0x70(%rbp), %rdi
callq 0x2140
movq -0x90(%rbp), %rdi
callq 0x2140
movq -0xb0(%rbp), %rdi
callq 0x2140
movq -0xd0(%rbp), %rdi
callq 0x2140
movq -0x190(%rbp), %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x21b0