// File: /workspace/github_cpp_makefile_star2_O3/joao18araujo[P]pierluigi/src/fourth_species_counterpoint.cpp
// Function: FourthSpeciesCounterpoint::analyse_and_add_interval(bool, bool, std::vector<Interval, std::allocator<Interval>>&, Note, Note, Interval, Song*)
void FourthSpeciesCounterpoint::analyse_and_add_interval(bool reverse_movement, bool melodic_ascendant, vector<Interval> & possible_intervals, Note previous_note, Note note, Interval interval, Song * counterpoint){
  Note next_note;
  auto previous_counterpoint_note = counterpoint->notes.back();

  if(interval.is_consonant())
    next_note = Scale::interval_to_note_on_scale(note, interval, song->scale);
  else
    next_note = Interval::interval_to_note(note, interval);

  auto previous_interval = Interval(previous_note, previous_counterpoint_note);

  if(!next_note.valid or (interval.is_dissonant() and previous_interval.is_dissonant())){
    return;
  }

  Interval melodic_interval(previous_counterpoint_note, next_note);

  bool is_valid_passing_or_neighbor = true;
  if(interval.is_dissonant()){
    is_valid_passing_or_neighbor = (melodic_interval == "m2" or melodic_interval == "M2");
  }else if(previous_interval.is_dissonant()){
    auto pre_previous_counterpoint_note = counterpoint->notes[counterpoint->size() - 2];
    Interval previous_melodic_interval(pre_previous_counterpoint_note, previous_counterpoint_note);
    bool passing = melodic_interval.ascendant() == previous_melodic_interval.ascendant();
    bool neighbor = (pre_previous_counterpoint_note == next_note and melodic_interval.ascendant());
    is_valid_passing_or_neighbor = (passing || neighbor) && (melodic_interval == "m2" or melodic_interval == "M2");
  }

  bool can_jump = (reverse_movement or
                  melodic_interval.quantitative <= 4 or
                  melodic_interval.quantitative == 8);

  if(((can_jump and (melodic_ascendant == melodic_interval.ascendant()) and note.valid) or
      previous_counterpoint_note.rest()) and is_valid_passing_or_neighbor)
    possible_intervals.push_back(interval);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movq %r9, %rbx
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbp
movl %esi, 0x8(%rsp)
movl %edi, 0xc(%rsp)
movq 0x5f0(%rsp), %r13
leaq 0x138(%rsp), %rdi
callq 0x1aada
movq 0x8(%r13), %rsi
addq $-0x58, %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x1aa22
movq %rbx, %rdi
callq 0x15638
testb %al, %al
je 0x1445f
leaq 0x560(%rsp), %rdi
movq %r15, %rsi
callq 0x1aa22
movq %r15, %r14
movl (%rbx), %eax
leaq 0xd0(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
callq 0xb50a
movzwl 0x2c(%rbx), %eax
movw %ax, 0xf4(%rsp)
movl 0x28(%rbx), %eax
movl %eax, 0xf0(%rsp)
leaq 0x9bfe252(%rip), %rax   # 0x9c124a8
movq (%rax), %r15
leaq 0x18(%r15), %rsi
xorl %eax, %eax
leaq 0x248(%rsp), %rdi
movq %rax, (%rdi)
movq 0x20(%r15), %rcx
movq %rcx, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movq 0x30(%r15), %rcx
movq %rcx, 0x18(%rdi)
movups 0x38(%r15), %xmm0
movups %xmm0, 0x20(%rdi)
movq %rax, 0x30(%rdi)
leaq 0x190(%rsp), %rdx
movq %rdi, (%rdx)
callq 0xb29e
leaq 0x280(%rsp), %r13
leaq 0x50(%r15), %rsi
movq %r13, %rdi
callq 0x1aa22
leaq 0x2d8(%rsp), %rdi
leaq 0x2e8(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xa8(%r15), %rsi
movq 0xb0(%r15), %rdx
addq %rsi, %rdx
callq 0xb50a
leaq 0x10(%rsp), %rdi
leaq 0x560(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x248(%rsp), %rcx
callq 0x1de5a
movq %r14, %r15
leaq 0x18(%rsp), %rsi
movq -0x8(%rsi), %rax
leaq 0x140(%rsp), %rdi
movq %rax, -0x8(%rdi)
callq 0x51e0
movq %r12, %r14
leaq 0x160(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x51e0
leaq 0x48(%rsp), %rax
movq 0x16(%rax), %rcx
movq %rcx, 0x186(%rsp)
movq -0x10(%rax), %rdi
movq 0x10(%rax), %rcx
movq %rcx, 0x180(%rsp)
cmpq %rax, %rdi
je 0x14360
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1437b
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x2d8(%rsp), %rdi
leaq 0x2e8(%rsp), %rax
cmpq %rax, %rdi
je 0x143a0
movq 0x2e8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x2b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x5f0(%rsp), %r13
je 0x143c9
movq 0x2b8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x298(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x143ea
movq 0x298(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x248(%rsp), %rdi
callq 0xb4e4
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x1441c
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x598(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1443d
movq 0x598(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x578(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1459d
movq 0x578(%rsp), %rsi
jmp 0x14595
movq %r12, %r14
leaq 0x508(%rsp), %rdi
movq %r15, %rsi
callq 0x1aa22
movl (%rbx), %eax
leaq 0x1c8(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0x1d8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
callq 0xb50a
movzwl 0x2c(%rbx), %eax
leaq 0x1c0(%rsp), %rdx
movw %ax, 0x2c(%rdx)
movl 0x28(%rbx), %eax
movl %eax, 0x28(%rdx)
leaq 0x10(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0x15ab2
leaq 0x18(%rsp), %rsi
movq -0x8(%rsi), %rax
leaq 0x140(%rsp), %rdi
movq %rax, -0x8(%rdi)
callq 0x51e0
leaq 0x160(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x51e0
leaq 0x48(%rsp), %rax
movq 0x16(%rax), %rcx
movq %rcx, 0x186(%rsp)
movq -0x10(%rax), %rdi
movq 0x10(%rax), %rcx
movq %rcx, 0x180(%rsp)
cmpq %rax, %rdi
je 0x14523
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1453e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x1c8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1455b
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x540(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1457c
movq 0x540(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x520(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1459d
movq 0x520(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x4b0(%rsp), %rdi
movq %r14, %rsi
callq 0x1aa22
leaq 0x458(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x1aa22
leaq 0x190(%rsp), %rdi
leaq 0x4b0(%rsp), %rsi
leaq 0x458(%rsp), %rdx
callq 0x1528a
leaq 0x490(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14600
movq 0x490(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x470(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14621
movq 0x470(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x4e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14642
movq 0x4e8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x4c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14663
movq 0x4c8(%rsp), %rsi
incq %rsi
callq 0x5360
cmpb $0x1, 0x18c(%rsp)
jne 0x14af7
movq %rbx, %rdi
callq 0x155ec
testb %al, %al
je 0x14692
leaq 0x190(%rsp), %rdi
callq 0x155ec
testb %al, %al
jne 0x14af7
leaq 0x400(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x1aa22
leaq 0x3a8(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x1aa22
leaq 0x98(%rsp), %rdi
leaq 0x400(%rsp), %rsi
leaq 0x3a8(%rsp), %rdx
callq 0x1528a
leaq 0x3e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x146fa
movq 0x3e0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x3c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1471b
movq 0x3c0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x438(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1473c
movq 0x438(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x418(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1475d
movq 0x418(%rsp), %rsi
incq %rsi
callq 0x5360
movq %rbx, %rdi
callq 0x155ec
testb %al, %al
je 0x14813
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x26934(%rip), %rsi     # 0x3b0b2
leaq 0x2692f(%rip), %rdx     # 0x3b0b4
leaq 0x10(%rsp), %rdi
callq 0xb5f8
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x153a8
movb $0x1, %r14b
testb %al, %al
jne 0x147fb
movq %r15, %r13
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x268fa(%rip), %rsi     # 0x3b0b5
leaq 0x268f5(%rip), %rdx     # 0x3b0b7
leaq 0x68(%rsp), %rdi
callq 0xb5f8
leaq 0x98(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x153a8
movl %eax, %r14d
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x147f8
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5360
movq %r13, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x14a80
movq 0x20(%rsp), %rsi
jmp 0x14a78
leaq 0x190(%rsp), %rdi
callq 0x155ec
movb $0x1, %r14b
testb %al, %al
je 0x14a80
movq %r13, %rdi
callq 0x242b0
addl $-0x2, %eax
imulq $0x58, %rax, %rsi
addq (%r13), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1aa22
leaq 0x350(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1aa22
leaq 0x2f8(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x1aa22
leaq 0x68(%rsp), %rdi
leaq 0x350(%rsp), %rsi
leaq 0x2f8(%rsp), %rdx
callq 0x1528a
leaq 0x330(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x148aa
movq 0x330(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x310(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x148cb
movq 0x310(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x388(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x148ec
movq 0x388(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x368(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1490d
movq 0x368(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x98(%rsp), %rdi
callq 0x15be4
movl %eax, %r14d
leaq 0x68(%rsp), %rdi
callq 0x15be4
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x1c07e
testb %al, %al
je 0x1494f
leaq 0x98(%rsp), %rdi
callq 0x15be4
jmp 0x14951
xorl %eax, %eax
testb %al, %al
jne 0x14966
xorb %r13b, %r14b
xorb $0x1, %r14b
jne 0x14966
xorl %r14d, %r14d
jmp 0x14a29
leaq 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x26738(%rip), %rsi     # 0x3b0b2
leaq 0x26733(%rip), %rdx     # 0x3b0b4
leaq 0x118(%rsp), %rdi
callq 0xb5f8
leaq 0x98(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x153a8
movb $0x1, %r14b
testb %al, %al
jne 0x14a0c
movq %r15, %r13
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x266f5(%rip), %rsi     # 0x3b0b5
leaq 0x266f0(%rip), %rdx     # 0x3b0b7
leaq 0xf8(%rsp), %rdi
callq 0xb5f8
leaq 0x98(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x153a8
movl %eax, %r14d
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x14a09
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5360
movq %r13, %r15
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x14a29
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a4a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a65
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14a80
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
cmpb $0x0, 0xc(%rsp)
jne 0x14a98
movl 0x98(%rsp), %eax
cmpl $0x5, %eax
jl 0x14a98
cmpl $0x8, %eax
jne 0x14ab9
leaq 0x98(%rsp), %rdi
callq 0x15be4
cmpb 0x8(%rsp), %al
jne 0x14ab9
cmpb $0x0, 0x54(%r15)
je 0x14ab9
testb %r14b, %r14b
jne 0x14acb
jmp 0x14ad6
leaq 0x1f0(%rsp), %rdi
callq 0x1c1fa
testb %al, %r14b
je 0x14ad6
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xb22e
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14af7
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x1a8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14b18
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x228(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14b39
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x208(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14b5a
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x170(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14b7b
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14b9c
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x5360
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x14bd5
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14bd5
jmp 0x14bd2
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x14c42
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14c42
jmp 0x14c3f
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0xb0e0
jmp 0x14c0b
movq %rax, %rbx
leaq 0x350(%rsp), %rdi
callq 0xb0e0
jmp 0x14c63
movq %rax, %rbx
jmp 0x14c63
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x14c7a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14c7a
jmp 0x14c77
jmp 0x14c3f
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14c63
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x10(%rsp), %rdi
callq 0xb0e0
jmp 0x14d1e
jmp 0x14d1b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x14d1e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14d1e
jmp 0x14d1b
movq %rax, %rbx
leaq 0x3a8(%rsp), %rdi
callq 0xb0e0
jmp 0x14cb1
movq %rax, %rbx
leaq 0x400(%rsp), %rdi
callq 0xb0e0
jmp 0x14d44
jmp 0x14d41
movq %rax, %rbx
jmp 0x14da2
movq %rax, %rbx
movq %r13, %rdi
callq 0xb0e0
jmp 0x14cdd
movq %rax, %rbx
leaq 0x248(%rsp), %rdi
callq 0xb4e4
jmp 0x14daf
movq %rax, %rbx
jmp 0x14deb
movq %rax, %rbx
jmp 0x14daf
movq %rax, %rbx
jmp 0x14e08
movq %rax, %rbx
jmp 0x14dd4
jmp 0x14e17
jmp 0x14e17
jmp 0x14d1b
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14d44
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14d44
movq %rax, %rbx
leaq 0x1a8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14e1a
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x14e1a
movq %rax, %rbx
leaq 0x458(%rsp), %rdi
callq 0xb0e0
jmp 0x14d83
movq %rax, %rbx
leaq 0x4b0(%rsp), %rdi
jmp 0x14e10
jmp 0x14e17
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb0e0
leaq 0x248(%rsp), %rdi
callq 0xb1d2
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x14dd4
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x560(%rsp), %rdi
jmp 0x14e10
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb0e0
movq 0x1c8(%rsp), %rdi
cmpq %r12, %rdi
je 0x14e08
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x508(%rsp), %rdi
callq 0xb0e0
jmp 0x14e1a
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0xb0e0
leaq 0x138(%rsp), %rdi
callq 0xb0e0
movq %rbx, %rdi
callq 0x55e0
movq %rax, %rbx
jmp 0x14e27
nop