// File: /workspace/github_cpp_makefile_star2_O3/joao18araujo[P]pierluigi/src/second_species_counterpoint.cpp
// Function: SecondSpeciesCounterpoint::analyse_and_add_interval(bool, bool, std::vector<Interval, std::allocator<Interval>>&, Note, Note, Interval, Song*)
void SecondSpeciesCounterpoint::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_or_passing = true;
  if(interval.is_dissonant()){
    is_valid_or_passing = (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);
    is_valid_or_passing = (melodic_interval.ascendant() == previous_melodic_interval.ascendant())
                          && (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_or_passing)
    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, %r13
movl %esi, 0x8(%rsp)
movl %edi, 0xc(%rsp)
movq 0x5f0(%rsp), %rbp
leaq 0x138(%rsp), %rdi
callq 0x1aada
movq 0x8(%rbp), %rsi
addq $-0x58, %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x1aa22
movq %rbx, %rdi
callq 0x15638
testb %al, %al
je 0x23901
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 0x9beedb0(%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), %rbp
leaq 0x50(%r15), %rsi
movq %rbp, %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 0x5f0(%rsp), %rbp
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 0x23807
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23822
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x2d8(%rsp), %rdi
leaq 0x2e8(%rsp), %rax
cmpq %rax, %rdi
je 0x23847
movq 0x2e8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x2b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq %r12, %r14
je 0x2386b
movq 0x2b8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x298(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2388c
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 0x238be
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x598(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x238df
movq 0x598(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x578(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23a3f
movq 0x578(%rsp), %rsi
jmp 0x23a37
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 0x239c5
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x239e0
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x1c8(%rsp), %rdi
cmpq %r12, %rdi
je 0x239fd
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x540(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23a1e
movq 0x540(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x520(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23a3f
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 0x23aa2
movq 0x490(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x470(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23ac3
movq 0x470(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x4e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23ae4
movq 0x4e8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x4c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23b05
movq 0x4c8(%rsp), %rsi
incq %rsi
callq 0x5360
cmpb $0x1, 0x18c(%rsp)
jne 0x23f66
movq %rbx, %rdi
callq 0x155ec
testb %al, %al
je 0x23b34
leaq 0x190(%rsp), %rdi
callq 0x155ec
testb %al, %al
jne 0x23f66
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 0x23b9c
movq 0x3e0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x3c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23bbd
movq 0x3c0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x438(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23bde
movq 0x438(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x418(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23bff
movq 0x418(%rsp), %rsi
incq %rsi
callq 0x5360
movq %rbx, %rdi
callq 0x155ec
testb %al, %al
je 0x23cb5
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x17492(%rip), %rsi     # 0x3b0b2
leaq 0x1748d(%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 0x23c9d
movq %r15, %rbp
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x17458(%rip), %rsi     # 0x3b0b5
leaq 0x17453(%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 0x23c9a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5360
movq %rbp, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x23eef
movq 0x20(%rsp), %rsi
jmp 0x23ee7
leaq 0x190(%rsp), %rdi
callq 0x155ec
movb $0x1, %r14b
testb %al, %al
je 0x23eef
movq %rbp, %rdi
callq 0x242b0
addl $-0x2, %eax
imulq $0x58, %rax, %rsi
addq (%rbp), %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 0x23d4c
movq 0x330(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x310(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23d6d
movq 0x310(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x388(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23d8e
movq 0x388(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x368(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23daf
movq 0x368(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x98(%rsp), %rdi
callq 0x15be4
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x15be4
cmpb %al, %bpl
je 0x23dd5
xorl %r14d, %r14d
jmp 0x23e98
leaq 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x172c9(%rip), %rsi     # 0x3b0b2
leaq 0x172c4(%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 0x23e7b
movq %r15, %rbp
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x17286(%rip), %rsi     # 0x3b0b5
leaq 0x17281(%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 0x23e78
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5360
movq %rbp, %r15
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x23e98
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23eb9
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23ed4
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23eef
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
cmpb $0x0, 0xc(%rsp)
jne 0x23f07
movl 0x98(%rsp), %eax
cmpl $0x5, %eax
jl 0x23f07
cmpl $0x8, %eax
jne 0x23f28
leaq 0x98(%rsp), %rdi
callq 0x15be4
cmpb 0x8(%rsp), %al
jne 0x23f28
cmpb $0x0, 0x54(%r15)
je 0x23f28
testb %r14b, %r14b
jne 0x23f3a
jmp 0x23f45
leaq 0x1f0(%rsp), %rdi
callq 0x1c1fa
testb %al, %r14b
je 0x23f45
movq %r13, %rdi
movq %rbx, %rsi
callq 0xb22e
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23f66
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x1a8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23f87
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x228(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23fa8
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x208(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23fc9
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x170(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x23fea
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2400b
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 0x24044
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x24044
jmp 0x24041
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x240af
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x240af
jmp 0x240ac
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0xb0e0
jmp 0x2407a
movq %rax, %rbx
leaq 0x350(%rsp), %rdi
callq 0xb0e0
jmp 0x240d0
movq %rax, %rbx
jmp 0x240d0
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x240e7
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x240e7
jmp 0x240e4
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x240d0
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x10(%rsp), %rdi
callq 0xb0e0
jmp 0x2418b
jmp 0x24188
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2418b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x2418b
jmp 0x24188
movq %rax, %rbx
leaq 0x3a8(%rsp), %rdi
callq 0xb0e0
jmp 0x2411e
movq %rax, %rbx
leaq 0x400(%rsp), %rdi
callq 0xb0e0
jmp 0x241b1
jmp 0x241ae
movq %rax, %rbx
jmp 0x2420f
movq %rax, %rbx
movq %rbp, %rdi
callq 0xb0e0
jmp 0x2414a
movq %rax, %rbx
leaq 0x248(%rsp), %rdi
callq 0xb4e4
jmp 0x2421c
movq %rax, %rbx
jmp 0x24258
movq %rax, %rbx
jmp 0x2421c
movq %rax, %rbx
jmp 0x24275
movq %rax, %rbx
jmp 0x24241
jmp 0x24284
jmp 0x24284
jmp 0x24188
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x241b1
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x241b1
movq %rax, %rbx
leaq 0x1a8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24287
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x24287
movq %rax, %rbx
leaq 0x458(%rsp), %rdi
callq 0xb0e0
jmp 0x241f0
movq %rax, %rbx
leaq 0x4b0(%rsp), %rdi
jmp 0x2427d
jmp 0x24284
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 0x24241
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x560(%rsp), %rdi
jmp 0x2427d
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb0e0
movq 0x1c8(%rsp), %rdi
cmpq %r12, %rdi
je 0x24275
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x508(%rsp), %rdi
callq 0xb0e0
jmp 0x24287
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0xb0e0
leaq 0x138(%rsp), %rdi
callq 0xb0e0
movq %rbx, %rdi
callq 0x55e0
movq %rax, %rbx
jmp 0x24294
nop