// File: /workspace/github_cpp_makefile_star2_O1/joao18araujo[P]pierluigi/src/song_reader.cpp
// Function: SongReader::song_clef_to_string[abi:cxx11](Song&)
string SongReader::song_clef_to_string(Song & song) {
  int total_midi = 0, total_notes = 0;
  for(auto note : song.notes) {
    if(not note.rest()) {
      total_midi += note.midi_number;
      total_notes++;
    }
  }

  Note treble("b", "", 4);
  Note bass("d", "", 3);

  double mid = total_notes ? (1.0 * total_midi) / total_notes : 0;
  string clef;
  if(treble.midi_number - mid <= mid - bass.midi_number)
    clef = "treble";
  else
    clef = "bass";

  return "\\clef " + clef;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %rbx
movq (%rsi), %r14
movq 0x8(%rsi), %r13
cmpq %r13, %r14
je 0x25696
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a9c6
movq %r15, %rdi
callq 0x1c186
movl %eax, %ebp
xorl %r15d, %r15d
testb %al, %al
jne 0x25620
movl 0x104(%rsp), %r15d
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x25645
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x2566a
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5360
xorb $0x1, %bpl
movzbl %bpl, %eax
addl %eax, %r12d
addl %r15d, %ebx
addq $0x58, %r14
cmpq %r13, %r14
jne 0x255f4
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jmp 0x256a3
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1664a(%rip), %rsi     # 0x3bd00
leaq 0x16644(%rip), %rdx     # 0x3bd01
leaq 0x98(%rsp), %rdi
callq 0xb62c
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1601d(%rip), %rdx     # 0x3b6fa
leaq 0x78(%rsp), %rdi
movq %rdx, %rsi
callq 0xb62c
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a814
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x25729
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x25746
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x165b4(%rip), %rsi     # 0x3bd0a
leaq 0x165ae(%rip), %rdx     # 0x3bd0b
leaq 0x58(%rsp), %rdi
callq 0xb62c
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15f83(%rip), %rdx     # 0x3b6fa
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0xb62c
leaq 0x110(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a814
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x257bd
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x257d4
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5360
xorpd %xmm0, %xmm0
testl %r12d, %r12d
je 0x257f3
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
xorps %xmm1, %xmm1
cvtsi2sdl 0x104(%rsp), %xmm1
subsd %xmm0, %xmm1
cvtsi2sdl 0x15c(%rsp), %xmm2
subsd %xmm2, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setae %al
leaq 0x15ea0(%rip), %rdx     # 0x3b6d5
leaq 0x15e92(%rip), %rcx     # 0x3b6ce
cmovbq %rdx, %rcx
leaq 0x4(,%rax,2), %r8
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5510
leaq 0x15e7d(%rip), %rsi     # 0x3b6da
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x18822
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x25881
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x258a2
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x258c3
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x258e4
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25905
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5360
movq %rbx, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x25939
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x25939
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x259ca
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x259ca
jmp 0x259c7
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x2597a
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x2597a
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x259d7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x259d7
movq %rax, %rbx
jmp 0x259d7
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x259b8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x110(%rsp), %rdi
callq 0xb116
jmp 0x259ca
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xb116
movq %rbx, %rdi
callq 0x55e0
nop