// File: /workspace/github_c_makefile_star2_O1/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 0x11cb5(%rip), %rbx     # 0x19680
cmpl $0x0, 0x11cb6(%rip)     # 0x19688
setg %al
testq %rbx, %rbx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7bad
xorl %eax, %eax
leaq 0x33d1(%rip), %r15      # 0xadc0
movl %eax, 0x4(%rsp)
movb $0x1, %r13b
movl $0x0, (%rsp)
movq 0x8(%rbx), %rax
movzbl (%rax), %r14d
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl %r14d, %ecx
notl %ecx
testb $-0x10, %cl
je 0x7ae2
testb %r14b, %r14b
js 0x7a2b
movswl 0x16(%rbx), %r14d
movq %rax, 0x8(%rbx)
jmp 0x7a30
movw %r14w, 0x16(%rbx)
movl %r14d, %ebp
sarl $0x4, %ebp
movslq %ebp, %rax
movl (%r15,%rax,4), %r12d
cmpl $0xb, %eax
jne 0x7a66
movq 0x8(%rbx), %rax
movb (%rax), %cl
xorl %edx, %edx
cmpb $0x7e, %cl
sete %dl
addl %edx, %r12d
cmpb $0x70, %cl
jne 0x7a66
movq 0x11c09(%rip), %rcx     # 0x19668
movzbl 0x1(%rax), %edi
callq *0x40(%rcx)
andl $0xf, %r14d
cmpl $0x9, %r14d
jne 0x7a88
cmpl $0x9, %ebp
jne 0x7a9e
movq 0x11bec(%rip), %rax     # 0x19668
movq 0x8(%rbx), %rcx
movzbl (%rcx), %edi
subl $-0x80, %edi
jmp 0x7a9b
cmpl $0xc, %ebp
jne 0x7a9e
movq 0x11bd4(%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)
leaq (%rax,%rcx), %rdx
incq %rdx
cmpb $0x0, -0x1(%rdx)
movq %rdx, 0x8(%rbx)
jns 0x7ad3
addq %rcx, %rax
addq $0x2, %rax
cmpb $0x0, -0x1(%rax)
movq %rax, 0x8(%rbx)
leaq 0x1(%rax), %rax
js 0x7ac5
testb $0x1, %r13b
jne 0x79fd
jmp 0x7b94
cmpl $0xf0, %r14d
movl (%rsp), %edi
je 0x7b00
cmpl $0xff, %r14d
je 0x7b39
cmpl $0xf7, %r14d
jne 0x7b5e
movzbl 0x1(%rax), %ecx
leaq 0x2(%rax), %rdx
movq %rdx, 0x8(%rbx)
testb %cl, %cl
jns 0x7b30
andl $0x7f, %ecx
addq $0x3, %rax
movzbl -0x1(%rax), %edx
movq %rax, 0x8(%rbx)
shll $0x7, %ecx
movl %edx, %esi
andl $0x7f, %esi
orl %esi, %ecx
incq %rax
testb %dl, %dl
js 0x7b17
movslq %ecx, %rax
addq 0x8(%rbx), %rax
jmp 0x7b5a
movb 0x1(%rax), %cl
leaq 0x2(%rax), %rdx
movq %rdx, 0x8(%rbx)
movzbl 0x2(%rax), %edx
cmpb $0x2f, %cl
movl $0x1, %ecx
cmovel %ecx, %edi
addq %rdx, %rax
addq $0x3, %rax
movq %rax, 0x8(%rbx)
testl %edi, %edi
jne 0x7b85
movq 0x8(%rbx), %rax
leaq 0x1(%rax), %rcx
cmpb $0x0, (%rax)
movq %rcx, 0x8(%rbx)
jns 0x7b85
addq $0x2, %rax
cmpb $0x0, -0x1(%rax)
movq %rax, 0x8(%rbx)
leaq 0x1(%rax), %rax
js 0x7b77
movl %edi, (%rsp)
testl %edi, %edi
sete %r13b
je 0x79fd
addq $0x178, %rbx            # imm = 0x178
movl 0x4(%rsp), %eax
incl %eax
cmpl 0x11ae1(%rip), %eax     # 0x19688
jl 0x79ef
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7210