// File: joao18araujo[P]pierluigi/src/song_reader.cpp
// Function: SongReader::note_to_string[abi:cxx11](Note)
string SongReader::note_to_string(Note note){
  int octave_diff = note.octave - BELOW_MIDDLE_C_OCTAVE;
  string s = note.full_note();

  s = regex_replace(s, regex("#"), "is");
  s = regex_replace(s, regex("\u266D"), "es");

  if(not note.rest()){
    if(octave_diff > 0){
      while(octave_diff--)
        s += "\'";
    }else{
      while(octave_diff++)
        s += ",";
    }
  }

  string duration = to_string((note.duration ? QUANT / msb(note.duration) : 0));
  int total_dots = number_of_on_bits(note.duration) - 1;
  while(total_dots-- > 0){
    duration += ".";
  }

  s += duration;

  if(note.linked){
    s = "~ " + s;
  }

  return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rsi, -0x108(%rbp)
movq %rdi, -0x100(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl 0x48(%rsi), %eax
addl $-0x3, %eax
movl %eax, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
callq 0x22ca0
leaq 0x31fa0(%rip), %rsi     # 0x60584
leaq -0x58(%rbp), %rdi
movl $0x10, %edx
callq 0x2fab0
jmp 0x2e5f4
movq -0x100(%rbp), %rsi
leaq 0x3289f(%rip), %rcx     # 0x60ea1
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
xorl %r8d, %r8d
callq 0x2fb80
jmp 0x2e614
movq -0x100(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq %rsi, -0x110(%rbp)
callq 0x6580
movq -0x110(%rbp), %rdi
callq 0x62d0
leaq -0x58(%rbp), %rdi
callq 0x2fb50
leaq 0x31f23(%rip), %rsi     # 0x6056a
leaq -0xa8(%rbp), %rdi
movl $0x10, %edx
callq 0x2fab0
jmp 0x2e65a
movq -0x100(%rbp), %rsi
leaq 0x320f2(%rip), %rcx     # 0x6075a
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
xorl %r8d, %r8d
callq 0x2fb80
jmp 0x2e680
movq -0x100(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movq %rsi, -0x120(%rbp)
callq 0x6580
movq -0x120(%rbp), %rdi
callq 0x62d0
leaq -0xa8(%rbp), %rdi
callq 0x2fb50
movq -0x108(%rbp), %rdi
callq 0x23be0
movb %al, -0x111(%rbp)
jmp 0x2e6c6
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x2e77c
jmp 0x2e6d6
cmpl $0x0, -0x14(%rbp)
jle 0x2e74f
jmp 0x2e6de
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x14(%rbp)
cmpl $0x0, %eax
je 0x2e74d
movq -0x100(%rbp), %rdi
leaq 0x32061(%rip), %rsi     # 0x6075d
callq 0x6450
jmp 0x2e703
jmp 0x2e6de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2e8d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2fb50
jmp 0x2e8d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2fb50
jmp 0x2e8d0
jmp 0x2e77a
jmp 0x2e751
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
cmpl $0x0, %eax
je 0x2e778
movq -0x100(%rbp), %rdi
leaq 0x31a83(%rip), %rsi     # 0x601f2
callq 0x6450
jmp 0x2e776
jmp 0x2e751
jmp 0x2e77a
jmp 0x2e77c
movq -0x108(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2e7b4
movq -0x108(%rbp), %rax
movl (%rax), %edi
callq 0x2e8f0
movl %eax, -0x124(%rbp)
jmp 0x2e79e
movl -0x124(%rbp), %ecx
movl $0x20, %eax
cltd
idivl %ecx
movl %eax, -0x128(%rbp)
jmp 0x2e7be
xorl %eax, %eax
movl %eax, -0x128(%rbp)
jmp 0x2e7be
movl -0x128(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x1ca20
jmp 0x2e7d2
movq -0x108(%rbp), %rax
movl (%rax), %edi
callq 0x2e930
movl %eax, -0x12c(%rbp)
jmp 0x2e7e8
movl -0x12c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xcc(%rbp)
cmpl $0x0, %eax
jle 0x2e841
leaq 0x323b3(%rip), %rsi     # 0x60bc7
leaq -0xc8(%rbp), %rdi
callq 0x6450
jmp 0x2e822
jmp 0x2e7f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x62d0
jmp 0x2e8d0
movq -0x100(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x65f0
jmp 0x2e856
movq -0x108(%rbp), %rax
testb $0x1, 0x55(%rax)
je 0x2e89e
movq -0x100(%rbp), %rdx
leaq 0x31eee(%rip), %rsi     # 0x6075f
leaq -0xf0(%rbp), %rdi
callq 0x20e30
jmp 0x2e87f
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x6580
leaq -0xf0(%rbp), %rdi
callq 0x62d0
movb $0x1, -0x15(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x62d0
testb $0x1, -0x15(%rbp)
jne 0x2e8c0
movq -0x100(%rbp), %rdi
callq 0x62d0
movq -0xf8(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x100(%rbp), %rdi
callq 0x62d0
movq -0x60(%rbp), %rdi
callq 0x6820
nopw %cs:(%rax,%rax)