// File: /workspace/github_cpp_makefile_star2_O3/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 0x256b4
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1aa22
movq %r15, %rdi
callq 0x1c1fa
movl %eax, %ebp
xorl %r15d, %r15d
testb %al, %al
jne 0x2563e
movl 0x104(%rsp), %r15d
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x25663
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x25688
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 0x25612
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jmp 0x256c1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1662c(%rip), %rsi     # 0x3bd00
leaq 0x16626(%rip), %rdx     # 0x3bd01
leaq 0x98(%rsp), %rdi
callq 0xb5f8
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15fff(%rip), %rdx     # 0x3b6fa
leaq 0x78(%rsp), %rdi
movq %rdx, %rsi
callq 0xb5f8
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a870
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x25747
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x25764
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x16596(%rip), %rsi     # 0x3bd0a
leaq 0x16590(%rip), %rdx     # 0x3bd0b
leaq 0x58(%rsp), %rdi
callq 0xb5f8
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15f65(%rip), %rdx     # 0x3b6fa
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0xb5f8
leaq 0x110(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a870
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x257db
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x257f2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5360
xorpd %xmm0, %xmm0
testl %r12d, %r12d
je 0x25811
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 0x15e82(%rip), %rdx     # 0x3b6d5
leaq 0x15e74(%rip), %rcx     # 0x3b6ce
cmovbq %rdx, %rcx
leaq 0x4(,%rax,2), %r8
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5510
leaq 0x15e5f(%rip), %rsi     # 0x3b6da
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x188b0
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2589f
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x258c0
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x128(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x258e1
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25902
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25923
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 0x25957
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x25957
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x259e8
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x259e8
jmp 0x259e5
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x25998
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x25998
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x259f5
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5360
jmp 0x259f5
movq %rax, %rbx
jmp 0x259f5
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x259d6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5360
leaq 0x110(%rsp), %rdi
callq 0xb0e0
jmp 0x259e8
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xb0e0
movq %rbx, %rdi
callq 0x55e0
nop