// File: /workspace/github_cpp_makefile_star2_O2/joao18araujo[P]pierluigi/src/ly_parser.cpp
// Function: LyParser::convert_file_to_simple_format(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void LyParser::convert_file_to_simple_format(string file_path, string output_path) {
  std::fstream file(file_path);

  string line, s;

  if(!file.is_open()){
    std::cerr << "Error: File not found\n";
    exit(-2);
  }

  string s_scale = "", s_time = "", s_notes = "";
  Note note, prev;
  int note_count = 0;
  while(file >> s){
    if(s == "\\key" && s_scale == ""){
      string key, mode;
      file >> key >> mode;
      Scale scale = SongReader::string_to_scale(s + " " + key + " " + mode);
      s_scale = SongReader::scale_to_string(scale);
    }else if(s == "\\time" or s == "\\numericTimeSignature\\time"){
      string time_and_note;
      file >> time_and_note;
      CompassTime compass_time = SongReader::string_to_compass_time("\\time " + time_and_note);
      s_time = SongReader::compass_time_to_string(compass_time);
    }else if(s == "\\relative"){
      if(s_scale == ""){
        std::cerr << "Error: Lilypond with relative pitches\n";
        file.close();
        exit(-5);
      }
    }else{
      note = SongReader::string_to_note(prev, s);
      if(note.valid){
        prev = note;
        note_count++;
        if(note_count > 1){
          if(note_count % 10 == 1) s_notes += "\n";
          else s_notes += " ";
        }
        s_notes += SongReader::note_to_string(note);
      }
    }

    if(s == "}" and s_notes != "") break;
  }

  if(s_scale == ""){
    std::cerr << "Error: Lilypond without scale\n";
    file.close();
    exit(-3);
  }

  if(s_time == ""){
    std::cerr << "Error: Lilypond without time\n";
    file.close();
    exit(-4);
  }

  std::ofstream output(output_path);
  output << s_scale << std::endl;
  output << s_time << std::endl;
  output << s_notes << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7d8, %rsp            # imm = 0x7D8
movq %rsi, 0x10(%rsp)
movq %rdi, %rsi
leaq 0x518(%rsp), %rdi
pushq $0x18
popq %rdx
callq 0x5570
leaq 0x168(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0xc8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
leaq 0x598(%rsp), %rdi
callq 0x50e0
testb %al, %al
je 0x10cf1
leaq 0x18fd1(%rip), %rsi     # 0x2974a
leaq 0x38(%rsp), %rdi
leaq 0x2c0(%rsp), %rdx
callq 0x96e6
leaq 0x18fb8(%rip), %rsi     # 0x2974a
leaq 0x98(%rsp), %rdi
leaq 0x2c0(%rsp), %rdx
callq 0x96e6
leaq 0x18f9c(%rip), %rsi     # 0x2974a
leaq 0x58(%rsp), %rdi
leaq 0x2c0(%rsp), %rdx
callq 0x96e6
leaq 0x178(%rsp), %rdi
callq 0x12712
leaq 0x210(%rsp), %rdi
callq 0x12712
leaq 0x518(%rsp), %r14
leaq 0xb8(%rsp), %r15
leaq 0x78(%rsp), %rbx
leaq 0x2c0(%rsp), %r12
movq $0x0, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x5440
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x10bb1
movq %r15, %rdi
leaq 0x189f5(%rip), %rsi     # 0x2921c
callq 0x989a
testb %al, %al
je 0x1098c
leaq 0x38(%rsp), %rdi
leaq 0x18f0a(%rip), %rsi     # 0x2974a
callq 0x989a
testb %al, %al
je 0x1098c
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
andq $0x0, 0x80(%rsp)
xorl %eax, %eax
movb %al, 0x88(%rsp)
leaq 0x28(%rsp), %rcx
movq %rcx, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb %al, 0x28(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5440
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0x5440
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x1895f(%rip), %rdx     # 0x2920c
callq 0x115ad
leaq 0x118(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x1158e
leaq 0x138(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x1892f(%rip), %rdx     # 0x2920c
callq 0xf94d
leaq 0x1f0(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x18(%rsp), %rdx
callq 0x1158e
movq %r12, %rdi
movq %r13, %rsi
callq 0x1834e
movq %r13, %rdi
callq 0x51b0
leaq 0x138(%rsp), %r13
movq %r13, %rdi
callq 0x51b0
leaq 0x118(%rsp), %rdi
callq 0x51b0
leaq 0xf8(%rsp), %rdi
callq 0x51b0
leaq 0x728(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x98ec
movq %r13, %rdi
movq %rbp, %rsi
callq 0x18596
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x5400
movq %r13, %rdi
callq 0x51b0
movq %rbp, %rdi
callq 0x9946
movq %r12, %rdi
callq 0x9946
leaq 0x18(%rsp), %rdi
callq 0x51b0
movq %rbx, %rdi
jmp 0x10a35
movq %r15, %rdi
leaq 0x188a0(%rip), %rsi     # 0x29236
callq 0x989a
testb %al, %al
jne 0x109b6
movq %r15, %rdi
leaq 0x18878(%rip), %rsi     # 0x29221
callq 0x989a
testb %al, %al
je 0x10a6f
leaq 0x2d0(%rsp), %rax
movq %rax, 0x2c0(%rsp)
andq $0x0, 0x2c8(%rsp)
movb $0x0, 0x2d0(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x5440
leaq 0x1d0(%rsp), %r13
movq %r13, %rdi
leaq 0x18848(%rip), %rsi     # 0x2923c
movq %r12, %rdx
callq 0x115e5
movq %r13, %rdi
callq 0x18626
movq %rax, %rbp
movq %r13, %rdi
callq 0x51b0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x186be
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x51b0
movq %r12, %rdi
callq 0x51b0
movq %r15, %rdi
leaq 0x18830(%rip), %rsi     # 0x29274
callq 0x989a
testb %al, %al
je 0x10800
leaq 0x58(%rsp), %rdi
leaq 0x18ced(%rip), %rsi     # 0x2974a
callq 0x982d
testb %al, %al
je 0x10800
jmp 0x10bb1
movq %r15, %rdi
leaq 0x187ca(%rip), %rsi     # 0x29243
callq 0x989a
testb %al, %al
je 0x10a9c
leaq 0x38(%rsp), %rdi
leaq 0x18cbc(%rip), %rsi     # 0x2974a
callq 0x989a
testb %al, %al
je 0x10a3a
jmp 0x10ccd
leaq 0x268(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x12676
leaq 0xd8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x5480
movq %r12, %rdi
leaq 0x268(%rsp), %rsi
movq %r13, %rdx
callq 0x17d8c
leaq 0x178(%rsp), %rdi
movq %r12, %rsi
callq 0x97e8
movq %r12, %rdi
callq 0x979a
leaq 0xd8(%rsp), %rdi
callq 0x51b0
leaq 0x268(%rsp), %rdi
callq 0x979a
cmpb $0x1, 0x1cc(%rsp)
jne 0x10a3a
leaq 0x210(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x97e8
movq 0x8(%rsp), %rax
leal 0x1(%rax), %ebp
testl %eax, %eax
jle 0x10b60
movl %ebp, %eax
xorl %edx, %edx
pushq $0xa
popq %rcx
divl %ecx
cmpl $0x1, %edx
leaq 0x186c1(%rip), %rsi     # 0x2920c
leaq 0x18cc8(%rip), %rax     # 0x2981a
cmoveq %rax, %rsi
leaq 0x58(%rsp), %rdi
callq 0x5620
leaq 0x4c0(%rsp), %r13
movq %r13, %rdi
leaq 0x178(%rsp), %rsi
callq 0x12676
movq %r12, %rdi
movq %r13, %rsi
callq 0x18102
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x5650
movq %r12, %rdi
callq 0x51b0
leaq 0x4c0(%rsp), %rdi
callq 0x979a
movl %ebp, %eax
movq %rax, 0x8(%rsp)
jmp 0x10a3a
leaq 0x18b92(%rip), %rsi     # 0x2974a
leaq 0x38(%rsp), %rdi
callq 0x989a
testb %al, %al
jne 0x10d08
leaq 0x18b79(%rip), %rsi     # 0x2974a
leaq 0x98(%rsp), %rdi
callq 0x989a
testb %al, %al
jne 0x10d2c
leaq 0x2c0(%rsp), %rdi
pushq $0x10
popq %rdx
movq 0x10(%rsp), %rsi
callq 0x5640
leaq 0x2c0(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5310
movq %rax, %rdi
callq 0x51d0
leaq 0x2c0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x5310
movq %rax, %rdi
callq 0x51d0
leaq 0x2c0(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x5310
movq %rax, %rdi
callq 0x51d0
leaq 0x2c0(%rsp), %rdi
callq 0x54e0
leaq 0x210(%rsp), %rdi
callq 0x979a
leaq 0x178(%rsp), %rdi
callq 0x979a
leaq 0x58(%rsp), %rdi
callq 0x51b0
leaq 0x98(%rsp), %rdi
callq 0x51b0
leaq 0x38(%rsp), %rdi
callq 0x51b0
leaq 0xb8(%rsp), %rdi
callq 0x51b0
leaq 0x158(%rsp), %rdi
callq 0x51b0
leaq 0x518(%rsp), %rdi
callq 0x50c0
addq $0x7d8, %rsp            # imm = 0x7D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29314(%rip), %rdi     # 0x39fe8
leaq 0x18572(%rip), %rsi     # 0x2924d
callq 0x5350
leaq 0x518(%rsp), %rdi
callq 0x5070
pushq $-0x5
jmp 0x10d4e
movq 0x292f0(%rip), %rdi     # 0x39fe8
leaq 0x184da(%rip), %rsi     # 0x291d9
callq 0x5350
pushq $-0x2
jmp 0x10d4e
movq 0x292d9(%rip), %rdi     # 0x39fe8
leaq 0x18560(%rip), %rsi     # 0x29276
callq 0x5350
leaq 0x518(%rsp), %rdi
callq 0x5070
pushq $-0x3
jmp 0x10d4e
movq 0x292b5(%rip), %rdi     # 0x39fe8
leaq 0x1855b(%rip), %rsi     # 0x29295
callq 0x5350
leaq 0x518(%rsp), %rdi
callq 0x5070
pushq $-0x4
popq %rdi
callq 0x53f0
jmp 0x10d9f
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x51b0
jmp 0x10d6b
movq %rax, %rbx
leaq 0x4c0(%rsp), %rdi
jmp 0x10dd6
jmp 0x10ea6
jmp 0x10ea6
movq %rax, %rbx
jmp 0x10eb6
movq %rax, %rbx
jmp 0x10ec3
movq %rax, %rbx
jmp 0x10ecd
movq %rax, %rbx
jmp 0x10eda
movq %rax, %rbx
jmp 0x10ee4
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x979a
jmp 0x10dbc
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x51b0
jmp 0x10dce
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x979a
jmp 0x10ea9
jmp 0x10ea6
jmp 0x10ea6
movq %rax, %rbx
jmp 0x10e3c
movq %rax, %rbx
jmp 0x10e49
jmp 0x10e6a
movq %rax, %rbx
leaq 0x728(%rsp), %rdi
callq 0x9946
jmp 0x10e0b
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x9946
jmp 0x10e6d
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x51b0
jmp 0x10e2f
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x51b0
leaq 0x118(%rsp), %rdi
callq 0x51b0
leaq 0xf8(%rsp), %rdi
callq 0x51b0
jmp 0x10e6d
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x54e0
jmp 0x10ea9
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x51b0
leaq 0x78(%rsp), %rdi
jmp 0x10e9f
jmp 0x10e94
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x51b0
jmp 0x10e97
jmp 0x10e94
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x51b0
jmp 0x10ea9
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x979a
leaq 0x178(%rsp), %rdi
callq 0x979a
leaq 0x58(%rsp), %rdi
callq 0x51b0
leaq 0x98(%rsp), %rdi
callq 0x51b0
leaq 0x38(%rsp), %rdi
callq 0x51b0
leaq 0xb8(%rsp), %rdi
callq 0x51b0
leaq 0x158(%rsp), %rdi
callq 0x51b0
leaq 0x518(%rsp), %rdi
callq 0x50c0
movq %rbx, %rdi
callq 0x55d0
nop