// File: /workspace/github_cpp_makefile_star2_O2/ef-gy[P]libefgy/include/ef.gy/continued-fractions.h
// Function: efgy::math::numeric::continuedFractional<long long>::binaryOperator::operator()(efgy::math::numeric::continuedFractional<long long> const&, efgy::math::numeric::continuedFractional<long long> const&) const
continuedFractional operator()(const continuedFractional &x,
                                   const continuedFractional &y) const {
      binaryOperator op = *this;
      continuedFractional rv;
      N px = N(0), py = N(0);
      bool xInf = false, yInf = false;
      while (1) {
        fractional<N> ae = fractional<N>(op.a, op.e),
                      bf = fractional<N>(op.b, op.f),
                      cg = fractional<N>(op.c, op.g),
                      dh = fractional<N>(op.d, op.h);

        N rae, rbf, rcg, rdh;

        if (op.e != zero()) {
          rae = N(ae);
        }
        if (op.f != zero()) {
          rbf = N(bf);
        }
        if (op.g != zero()) {
          rcg = N(cg);
        }
        if (op.h != zero()) {
          rdh = N(dh);
        }

        if ((op.e != zero()) && (op.f != zero()) && (op.g != zero()) &&
            (op.h != zero())) {
          if ((rae == rbf) && (rbf == rcg) && (rcg == rdh)) {
            rv = (rv, rae);
            if ((op.a < zero()) && (op.b < zero()) && (op.c < zero()) &&
                (op.d < zero())) {
              rv.negative = true;
            }
            op = op.output(rae);
            continue;
          }
        }

        if ((op.e == zero()) && (op.f == zero()) && (op.g == zero()) &&
            (op.h == zero())) {
          break;
        }

        if (xInf && yInf) {
          if (op.h != zero()) {
            continuedFractional<N> cfdh = dh;
            for (N i = N(0); i < cfdh.coefficient.size(); i++) {
              rv = (rv, cfdh.coefficient[i]);
            }
          }
          break;
        }

        fractional<N> bfae = bf - ae;
        fractional<N> cgae = cg - ae;

        if (bfae < zero()) {
          bfae *= N(-1);
        }
        if (cgae < zero()) {
          cgae *= N(-1);
        }

        if ((op.f == zero()) || (op.h == zero())) {
          goto processY;
        }
        if ((op.e == zero()) || (op.g == zero())) {
          goto processX;
        }

        if (bfae > cgae) {
        processX:
          if (px < x.coefficient.size()) {
            op = op.insertX(x.coefficient[px]);
            px++;
          } else if (!xInf) {
            op = op.insertXinf();
            xInf = true;
          } else {
            goto processY;
          }
        } else {
        processY:
          if (py < y.coefficient.size()) {
            op = op.insertY(y.coefficient[py]);
            py++;
          } else if (!yInf) {
            op = op.insertYinf();
            yInf = true;
          } else {
            goto processX;
          }
        }
      }
      return rv;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, 0xd8(%rsp)
movq %rdx, 0xd0(%rsp)
movq (%rsi), %r9
movq 0x8(%rsi), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsi), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsi), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsi), %r15
movq 0x28(%rsi), %rbp
movq 0x30(%rsi), %r13
movq 0x38(%rsi), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x9(%rdi)
movq %rdi, 0x8(%rsp)
movups %xmm0, (%rdi)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movq %r9, %rbx
movq %r9, 0xc0(%rsp)
movq %r15, 0xc8(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x11e80
movq 0x20(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %rbp, 0xb8(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x11e80
movq 0x28(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %r13, 0xa8(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x11e80
movq 0x18(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x11e80
testq %r15, %r15
je 0x12370
movq 0xc0(%rsp), %rax
cqto
idivq 0xc8(%rsp)
movq %rax, %rcx
movq %rax, 0x88(%rsp)
testq %rbp, %rbp
je 0x1238c
movq 0xb0(%rsp), %rax
cqto
idivq 0xb8(%rsp)
movq %rax, 0x60(%rsp)
testq %r13, %r13
je 0x123a8
movq 0xa0(%rsp), %rax
cqto
idivq 0xa8(%rsp)
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x123ca
movq 0x90(%rsp), %rax
cqto
idivq 0x98(%rsp)
movq %rax, 0xe0(%rsp)
testq %r15, %r15
je 0x124db
testq %rbp, %rbp
je 0x124ec
testq %r13, %r13
je 0x124ec
cmpq $0x0, 0x10(%rsp)
je 0x124ec
cmpq 0x60(%rsp), %rcx
jne 0x124ec
movq 0x58(%rsp), %rax
cmpq %rax, 0x60(%rsp)
jne 0x124ec
movq 0xe0(%rsp), %rax
cmpq %rax, 0x58(%rsp)
jne 0x124ec
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
leaq 0x88(%rsp), %rdx
callq 0x1280c
movq %r12, %rdi
movq %r14, %rsi
callq 0x534e
movq %r14, %rdi
callq 0xf4b8
testq %rbx, %rbx
jns 0x12475
cmpq $0x0, 0x20(%rsp)
jns 0x12475
cmpq $0x0, 0x28(%rsp)
jns 0x12475
cmpq $0x0, 0x18(%rsp)
jns 0x12475
movq 0x8(%rsp), %rax
movb $0x1, 0x18(%rax)
movq 0x88(%rsp), %rax
movq %rax, %rcx
imulq %r15, %rcx
subq %rcx, %rbx
movq %rax, %rcx
imulq %rbp, %rcx
movq 0x20(%rsp), %rsi
subq %rcx, %rsi
movq %rax, %rcx
imulq %r13, %rcx
movq 0x28(%rsp), %rdi
subq %rcx, %rdi
movq 0x10(%rsp), %r8
imulq %r8, %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
movq %r15, %r9
movq %rbp, 0x20(%rsp)
movq %r13, 0x28(%rsp)
movq %r8, 0x18(%rsp)
movq %rbx, %r15
movq %rsi, %rbp
movq %rdi, %r13
movq %rcx, 0x10(%rsp)
jmp 0x122c3
movq %rbp, %rax
orq %r13, %rax
orq 0x10(%rsp), %rax
je 0x127a1
testb $0x1, 0x40(%rsp)
je 0x124fe
testb $0x1, 0x38(%rsp)
jne 0x1272a
leaq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %r12
movq %r12, %rsi
callq 0x552e
movq %rax, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x552e
movq %rax, 0xe8(%rsp)
movq %rdx, 0xf0(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x121f1
testb %al, %al
je 0x12568
orq $-0x1, 0x30(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x11f2a
leaq 0x30(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x121f1
testb %al, %al
je 0x12596
orq $-0x1, 0x30(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x11f2a
testq %rbp, %rbp
je 0x125cf
cmpq $0x0, 0x10(%rsp)
je 0x125cf
testq %r15, %r15
je 0x12651
testq %r13, %r13
je 0x12651
leaq 0x68(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x12210
testb %al, %al
jne 0x12651
movq 0xd8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq 0x48(%rsp), %rdx
cmpq %rcx, %rdx
jae 0x12646
movq (%rax,%rdx,8), %rax
movq %rdx, %rdi
movq %rax, %rcx
movq 0x28(%rsp), %r9
imulq %r9, %rcx
addq %rcx, %rbx
movq %rax, %rcx
movq 0x18(%rsp), %rsi
imulq %rsi, %rcx
addq 0x20(%rsp), %rcx
movq %rax, %rdx
imulq %r13, %rdx
addq %rdx, %r15
movq 0x10(%rsp), %rdx
imulq %rdx, %rax
addq %rbp, %rax
incq %rdi
movq %rdi, 0x48(%rsp)
movq %rsi, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
jmp 0x126c6
testb $0x1, 0x38(%rsp)
je 0x126f6
movq 0xd0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq 0x50(%rsp), %rdx
cmpq %rcx, %rdx
jae 0x126cd
movq (%rax,%rdx,8), %rax
movq %rdx, %rdi
movq %rax, %rcx
movq 0x20(%rsp), %r9
imulq %r9, %rcx
addq %rbx, %rcx
movq %rax, %rdx
movq 0x18(%rsp), %rbx
imulq %rbx, %rdx
addq 0x28(%rsp), %rdx
movq %rax, %rsi
imulq %rbp, %rsi
addq %r15, %rsi
movq 0x10(%rsp), %r15
imulq %r15, %rax
addq %r13, %rax
incq %rdi
movq %rdi, 0x50(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rbp, %r13
movq %rsi, %rbp
movq %rax, 0x10(%rsp)
jmp 0x12717
testb $0x1, 0x40(%rsp)
jne 0x125cf
movq %rbx, %r9
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r15, %r13
movq %rbp, 0x10(%rsp)
movb $0x1, %al
movq %rax, 0x40(%rsp)
jmp 0x12717
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %r9
movq %r9, %rbx
movq 0x10(%rsp), %rbp
movq %r13, %r15
movb $0x1, %al
movq %rax, 0x38(%rsp)
movq %r15, %rax
movq %rbx, 0x28(%rsp)
movq %r13, %r15
movq %rax, %r13
jmp 0x122c3
cmpq $0x0, 0x10(%rsp)
je 0x127a1
leaq 0x68(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5178
xorl %r14d, %r14d
leaq 0xe8(%rsp), %rbx
xorl %r15d, %r15d
movq 0x8(%rsp), %r12
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rax
subq %rdx, %rax
sarq $0x3, %rax
cmpq %rax, %r15
jae 0x12797
addq %r14, %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1280c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x534e
movq %rbx, %rdi
callq 0xf4b8
incq %r15
addq $0x8, %r14
jmp 0x12757
leaq 0x68(%rsp), %rdi
callq 0xf4b8
movq 0x8(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x127f7
jmp 0x127d6
movq %rax, %rbx
movq %r12, %rdi
jmp 0x127ff
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0xf4b8
jmp 0x127d9
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xf4b8
jmp 0x127fa
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
jmp 0x127f7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0xf4b8
movq %rbx, %rdi
callq 0x4410