// File: 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
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x300(%rbp)
movq %rdi, %rax
movq %rax, -0x308(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movl $0x40, %edx
callq 0x52f0
movq -0x300(%rbp), %rdi
movb $0x0, -0x61(%rbp)
callq 0x7200
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movb $0x0, -0x79(%rbp)
movb $0x0, -0x7a(%rbp)
jmp 0x34d08
movq -0x60(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x6ef0
jmp 0x34d1e
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x6ef0
jmp 0x34d34
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x6ef0
jmp 0x34d4a
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x6ef0
jmp 0x34d60
leaq -0x40(%rbp), %rdi
leaq -0xf1(%rbp), %rsi
callq 0x33d90
movb %al, -0x309(%rbp)
jmp 0x34d78
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x34d84
jmp 0x34db0
leaq -0x90(%rbp), %rdi
callq 0x33e90
movq %rax, -0xd8(%rbp)
jmp 0x34db0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x355d5
leaq -0x38(%rbp), %rdi
leaq -0xf2(%rbp), %rsi
callq 0x33d90
movb %al, -0x30a(%rbp)
jmp 0x34dc8
movb -0x30a(%rbp), %al
testb $0x1, %al
jne 0x34dd4
jmp 0x34de7
leaq -0xb0(%rbp), %rdi
callq 0x33e90
movq %rax, -0xe0(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xf3(%rbp), %rsi
callq 0x33d90
movb %al, -0x30b(%rbp)
jmp 0x34dff
movb -0x30b(%rbp), %al
testb $0x1, %al
jne 0x34e0b
jmp 0x34e1e
leaq -0xc0(%rbp), %rdi
callq 0x33e90
movq %rax, -0xe8(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0xf4(%rbp), %rsi
callq 0x33d90
movb %al, -0x30c(%rbp)
jmp 0x34e36
movb -0x30c(%rbp), %al
testb $0x1, %al
jne 0x34e42
jmp 0x34e55
leaq -0xd0(%rbp), %rdi
callq 0x33e90
movq %rax, -0xf0(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xf5(%rbp), %rsi
callq 0x33d90
movb %al, -0x30d(%rbp)
jmp 0x34e6d
movb -0x30d(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x30e(%rbp)
jne 0x34e85
jmp 0x34f05
leaq -0x38(%rbp), %rdi
leaq -0xf6(%rbp), %rsi
callq 0x33d90
movb %al, -0x30f(%rbp)
jmp 0x34e9d
movb -0x30f(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x30e(%rbp)
jne 0x34eb2
jmp 0x34f05
leaq -0x30(%rbp), %rdi
leaq -0xf7(%rbp), %rsi
callq 0x33d90
movb %al, -0x310(%rbp)
jmp 0x34eca
movb -0x310(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x30e(%rbp)
jne 0x34edf
jmp 0x34f05
leaq -0x28(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x33d90
movb %al, -0x311(%rbp)
jmp 0x34ef7
movb -0x311(%rbp), %al
movb %al, -0x30e(%rbp)
jmp 0x34f05
movb -0x30e(%rbp), %al
testb $0x1, %al
jne 0x34f14
jmp 0x350ae
movq -0xd8(%rbp), %rax
cmpq -0xe0(%rbp), %rax
jne 0x350ac
movq -0xe0(%rbp), %rax
cmpq -0xe8(%rbp), %rax
jne 0x350ac
movq -0xe8(%rbp), %rax
cmpq -0xf0(%rbp), %rax
jne 0x350ac
movq -0x300(%rbp), %rsi
leaq -0x118(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x35660
jmp 0x34f6c
movq -0x300(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x7360
jmp 0x34f81
leaq -0x118(%rbp), %rdi
callq 0x73a0
leaq -0x60(%rbp), %rdi
leaq -0x119(%rbp), %rsi
callq 0x33cf0
movb %al, -0x312(%rbp)
jmp 0x34fa5
movb -0x312(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x313(%rbp)
jne 0x34fbd
jmp 0x3503d
leaq -0x58(%rbp), %rdi
leaq -0x11a(%rbp), %rsi
callq 0x33cf0
movb %al, -0x314(%rbp)
jmp 0x34fd5
movb -0x314(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x313(%rbp)
jne 0x34fea
jmp 0x3503d
leaq -0x50(%rbp), %rdi
leaq -0x11b(%rbp), %rsi
callq 0x33cf0
movb %al, -0x315(%rbp)
jmp 0x35002
movb -0x315(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x313(%rbp)
jne 0x35017
jmp 0x3503d
leaq -0x48(%rbp), %rdi
leaq -0x11c(%rbp), %rsi
callq 0x33cf0
movb %al, -0x316(%rbp)
jmp 0x3502f
movb -0x316(%rbp), %al
movb %al, -0x313(%rbp)
jmp 0x3503d
movb -0x313(%rbp), %al
testb $0x1, %al
jne 0x35049
jmp 0x35079
movq -0x300(%rbp), %rax
movb $0x1, 0x18(%rax)
jmp 0x35079
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x73a0
jmp 0x355d5
movq -0xd8(%rbp), %rdx
leaq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x35720
jmp 0x35092
leaq -0x60(%rbp), %rdi
leaq -0x160(%rbp), %rsi
movl $0x40, %edx
callq 0x52f0
jmp 0x34d06
jmp 0x350ae
leaq -0x60(%rbp), %rdi
addq $0x20, %rdi
leaq -0x161(%rbp), %rsi
callq 0x33e30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x317(%rbp)
jne 0x350d3
jmp 0x35137
leaq -0x60(%rbp), %rdi
addq $0x28, %rdi
leaq -0x162(%rbp), %rsi
callq 0x33e30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x317(%rbp)
jne 0x350f8
jmp 0x35137
leaq -0x60(%rbp), %rdi
addq $0x30, %rdi
leaq -0x163(%rbp), %rsi
callq 0x33e30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x317(%rbp)
jne 0x3511d
jmp 0x35137
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
leaq -0x164(%rbp), %rsi
callq 0x33e30
movb %al, -0x317(%rbp)
movb -0x317(%rbp), %al
testb $0x1, %al
jne 0x35143
jmp 0x35148
jmp 0x355af
testb $0x1, -0x79(%rbp)
je 0x3528b
testb $0x1, -0x7a(%rbp)
je 0x3528b
leaq -0x28(%rbp), %rdi
leaq -0x165(%rbp), %rsi
callq 0x33d90
movb %al, -0x318(%rbp)
jmp 0x35174
movb -0x318(%rbp), %al
testb $0x1, %al
jne 0x35183
jmp 0x35286
leaq -0x188(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x6f50
jmp 0x35198
movq $0x0, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x340b0
movq %rax, %rcx
movq -0x320(%rbp), %rax
cmpq %rcx, %rax
jae 0x35267
movq -0x190(%rbp), %rsi
leaq -0x188(%rbp), %rdi
callq 0x357b0
movq -0x300(%rbp), %rsi
movq %rax, %rdx
leaq -0x1b0(%rbp), %rdi
callq 0x35660
jmp 0x351fb
movq -0x300(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x7360
jmp 0x35210
leaq -0x1b0(%rbp), %rdi
callq 0x73a0
movq -0x190(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x190(%rbp)
jmp 0x351a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x35275
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x73a0
jmp 0x35275
leaq -0x188(%rbp), %rdi
callq 0x73a0
jmp 0x35286
leaq -0x188(%rbp), %rdi
callq 0x73a0
jmp 0x355d5
jmp 0x355af
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7660
movq %rdx, -0x330(%rbp)
movq %rax, -0x328(%rbp)
jmp 0x352ae
movq -0x330(%rbp), %rax
movq -0x328(%rbp), %rcx
movq %rcx, -0x1c0(%rbp)
movq %rax, -0x1b8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7660
movq %rdx, -0x340(%rbp)
movq %rax, -0x338(%rbp)
jmp 0x352ed
movq -0x340(%rbp), %rax
movq -0x338(%rbp), %rcx
movq %rcx, -0x1d0(%rbp)
movq %rax, -0x1c8(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1d1(%rbp), %rsi
callq 0x33f60
movb %al, -0x341(%rbp)
jmp 0x35324
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0x35330
jmp 0x35352
movq $-0x1, -0x1e0(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x33f90
jmp 0x35350
jmp 0x35352
leaq -0x1d0(%rbp), %rdi
leaq -0x1e1(%rbp), %rsi
callq 0x33f60
movb %al, -0x342(%rbp)
jmp 0x3536d
movb -0x342(%rbp), %al
testb $0x1, %al
jne 0x35379
jmp 0x3539b
movq $-0x1, -0x1f0(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x33f90
jmp 0x35399
jmp 0x3539b
leaq -0x60(%rbp), %rdi
addq $0x28, %rdi
leaq -0x1f1(%rbp), %rsi
callq 0x33e30
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x343(%rbp)
jne 0x353d8
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
leaq -0x1f2(%rbp), %rsi
callq 0x33e30
movb %al, -0x343(%rbp)
movb -0x343(%rbp), %al
testb $0x1, %al
jne 0x353e4
jmp 0x353e9
jmp 0x35506
leaq -0x60(%rbp), %rdi
addq $0x20, %rdi
leaq -0x1f3(%rbp), %rsi
callq 0x33e30
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x344(%rbp)
jne 0x35426
leaq -0x60(%rbp), %rdi
addq $0x30, %rdi
leaq -0x1f4(%rbp), %rsi
callq 0x33e30
movb %al, -0x344(%rbp)
movb -0x344(%rbp), %al
testb $0x1, %al
jne 0x35432
jmp 0x35434
jmp 0x35460
leaq -0x1c0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x34b10
movb %al, -0x345(%rbp)
jmp 0x3544f
movb -0x345(%rbp), %al
testb $0x1, %al
jne 0x3545e
jmp 0x35504
jmp 0x35460
movq -0x70(%rbp), %rax
movq %rax, -0x350(%rbp)
movq -0x18(%rbp), %rdi
callq 0x340b0
movq %rax, %rcx
movq -0x350(%rbp), %rax
cmpq %rcx, %rax
jae 0x354c8
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x35860
movq (%rax), %rdx
leaq -0x238(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x357d0
jmp 0x354a5
leaq -0x60(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movl $0x40, %edx
callq 0x52f0
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x354ff
testb $0x1, -0x79(%rbp)
jne 0x354fb
leaq -0x278(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x35880
jmp 0x354e0
leaq -0x60(%rbp), %rdi
leaq -0x278(%rbp), %rsi
movl $0x40, %edx
callq 0x52f0
movb $0x1, -0x79(%rbp)
jmp 0x354fd
jmp 0x35506
jmp 0x354ff
jmp 0x355aa
jmp 0x35506
movq -0x78(%rbp), %rax
movq %rax, -0x358(%rbp)
movq -0x20(%rbp), %rdi
callq 0x340b0
movq %rax, %rcx
movq -0x358(%rbp), %rax
cmpq %rcx, %rax
jae 0x3556e
movq -0x20(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x35860
movq (%rax), %rdx
leaq -0x2b8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x358e0
jmp 0x3554b
leaq -0x60(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
movl $0x40, %edx
callq 0x52f0
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x355a8
testb $0x1, -0x7a(%rbp)
jne 0x355a1
leaq -0x2f8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x35970
jmp 0x35586
leaq -0x60(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
movl $0x40, %edx
callq 0x52f0
movb $0x1, -0x7a(%rbp)
jmp 0x355a6
jmp 0x35460
jmp 0x355a8
jmp 0x355aa
jmp 0x34d06
movb $0x1, -0x61(%rbp)
testb $0x1, -0x61(%rbp)
jne 0x355c5
movq -0x300(%rbp), %rdi
callq 0x73a0
movq -0x308(%rbp), %rax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq -0x300(%rbp), %rdi
callq 0x73a0
movq -0x98(%rbp), %rdi
callq 0x55b0
nopl (%rax)