// File: /workspace/github_c_makefile_star2_O3/jonof[P]jfaudiolib/src/midi.c
// Function: MIDI_LoadTimbres
void MIDI_LoadTimbres
   (
   void
   )

   {
   int    event;
   int    command;
   int    channel;
   int    length;
   int    Finished;
   track *Track;
   int    tracknum;

   Track = _MIDI_TrackPtr;
   tracknum = 0;
   while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) )
      {
      Finished = FALSE;
      while ( !Finished )
         {
         GET_NEXT_EVENT( Track, event );

         if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL )
            {
            switch( event )
               {
               case MIDI_SYSEX :
               case MIDI_SYSEX_CONTINUE :
                  length = _MIDI_ReadDelta( Track );
                  Track->pos += length;
                  break;

               case MIDI_META_EVENT :
                  GET_NEXT_EVENT( Track, command );
                  GET_NEXT_EVENT( Track, length );

                  if ( command == MIDI_END_OF_TRACK )
                     {
                     Finished = TRUE;
                     }

                  Track->pos += length;
                  break;
               }

            if ( !Finished )
               {
               _MIDI_ReadDelta( Track );
               }

            continue;
            }

         if ( event & MIDI_RUNNING_STATUS )
            {
            Track->RunningStatus = event;
            }
         else
            {
            event = Track->RunningStatus;
            Track->pos--;
            }

         channel = GET_MIDI_CHANNEL( event );
         command = GET_MIDI_COMMAND( event );
         length = _MIDI_CommandLengths[ command ];

         if ( command == MIDI_CONTROL_CHANGE )
            {
            if ( *Track->pos == MIDI_MONO_MODE_ON )
               {
               length++;
               }

            if ( *Track->pos == EMIDI_PROGRAM_CHANGE )
               {
               _MIDI_Funcs->LoadPatch( *( Track->pos + 1 ) );
               }
            }

         if ( channel == MIDI_RHYTHM_CHANNEL )
            {
            if ( command == MIDI_NOTE_ON )
               {
               _MIDI_Funcs->LoadPatch( 128 + *Track->pos );
               }
            }
         else
            {
            if ( command == MIDI_PROGRAM_CHANGE )
               {
               _MIDI_Funcs->LoadPatch( *Track->pos );
               }
            }
         Track->pos += length;
         _MIDI_ReadDelta( Track );
         }
      Track++;
      tracknum++;
      }

   _MIDI_ResetTracks();
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x11c39(%rip), %rbx     # 0x19680
cmpl $0x0, 0x11c3a(%rip)     # 0x19688
setg %al
testq %rbx, %rbx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7c05
xorl %ebp, %ebp
leaq 0x33c5(%rip), %r14      # 0xae30
movq 0x8(%rbx), %rax
movb (%rax), %dl
movzbl %dl, %r15d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl %r15d, %esi
notl %esi
testb $-0x10, %sil
je 0x7b4c
testb %dl, %dl
js 0x7a9e
movswl 0x16(%rbx), %r15d
movq %rax, 0x8(%rbx)
movq %rax, %rcx
jmp 0x7aa5
movzbl %dl, %eax
movw %ax, 0x16(%rbx)
movl %r15d, %r13d
sarl $0x4, %r13d
movslq %r13d, %rax
movl (%r14,%rax,4), %r12d
cmpl $0xb, %eax
jne 0x7ad6
movb (%rcx), %al
xorl %edx, %edx
cmpb $0x7e, %al
sete %dl
addl %edx, %r12d
cmpb $0x70, %al
jne 0x7ad6
movq 0x11b99(%rip), %rax     # 0x19668
movzbl 0x1(%rcx), %edi
callq *0x40(%rax)
andl $0xf, %r15d
cmpl $0x9, %r15d
jne 0x7af9
cmpl $0x9, %r13d
jne 0x7b10
movq 0x11b7b(%rip), %rax     # 0x19668
movq 0x8(%rbx), %rcx
movzbl (%rcx), %edi
subl $-0x80, %edi
jmp 0x7b0d
cmpl $0xc, %r13d
jne 0x7b10
movq 0x11b62(%rip), %rax     # 0x19668
movq 0x8(%rbx), %rcx
movzbl (%rcx), %edi
callq *0x40(%rax)
movq 0x8(%rbx), %rax
movslq %r12d, %rcx
leaq (%rax,%rcx), %rdx
movq %rdx, 0x8(%rbx)
addq %rax, %rcx
incq %rcx
cmpb $0x0, -0x1(%rcx)
movq %rcx, 0x8(%rbx)
js 0x7b37
movq %rcx, %rax
jmp 0x7a6f
leaq 0x1(%rcx), %rax
cmpb $0x0, (%rcx)
movq %rax, 0x8(%rbx)
movq %rax, %rcx
js 0x7b37
jmp 0x7a6f
cmpb $-0x10, %dl
je 0x7b64
movzbl %dl, %edx
cmpl $0xff, %edx
je 0x7ba9
cmpl $0xf7, %edx
jne 0x7bc7
movsbq (%rcx), %rcx
addq $0x2, %rax
movq %rax, 0x8(%rbx)
testq %rcx, %rcx
jns 0x7b9d
andl $0x7f, %ecx
movzbl (%rax), %edx
incq %rax
movq %rax, 0x8(%rbx)
movl %ecx, %esi
shll $0x7, %esi
movl %edx, %ecx
andl $0x7f, %ecx
orl %esi, %ecx
testb %dl, %dl
js 0x7b78
movzbl %dl, %ecx
andl $0x7f, %ecx
orl %ecx, %esi
movslq %esi, %rcx
addq %rcx, %rax
movq %rax, %rcx
movq %rax, 0x8(%rbx)
jmp 0x7bc7
movb (%rcx), %dl
leaq 0x2(%rax), %rcx
movq %rcx, 0x8(%rbx)
movzbl 0x2(%rax), %ecx
addq %rax, %rcx
addq $0x3, %rcx
movq %rcx, 0x8(%rbx)
cmpb $0x2f, %dl
je 0x7bf0
leaq 0x1(%rcx), %rax
cmpb $0x0, (%rcx)
movq %rax, 0x8(%rbx)
jns 0x7a6f
movq %rax, %rcx
leaq 0x1(%rcx), %rax
cmpb $0x0, (%rcx)
movq %rax, 0x8(%rbx)
movq %rax, %rcx
js 0x7bdb
jmp 0x7a6f
addq $0x178, %rbx            # imm = 0x178
incl %ebp
cmpl 0x11a89(%rip), %ebp     # 0x19688
jl 0x7a6b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x72a0