// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq 0x13321(%rip), %rax     # 0x1f0c0
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl 0x13313(%rip), %ecx     # 0x1f0c8
movb %al, -0x25(%rbp)
jge 0xbdc5
cmpq $0x0, -0x20(%rbp)
setne %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0xbdd1
jmp 0xc006
movl $0x0, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xbdea
jmp 0xbfea
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, -0x4(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movl -0x4(%rbp), %eax
sarl $0x4, %eax
cmpl $0xf, %eax
jne 0xbed6
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0xf0, %eax
je 0xbe41
jmp 0xbe26
movl -0x2c(%rbp), %eax
subl $0xf7, %eax
je 0xbe41
jmp 0xbe32
movl -0x2c(%rbp), %eax
subl $0xff, %eax
je 0xbe64
jmp 0xbec2
movq -0x20(%rbp), %rdi
callq 0xcaf0
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
jmp 0xbec2
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, -0x8(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
cmpl $0x2f, -0x8(%rbp)
jne 0xbead
movl $0x1, -0x14(%rbp)
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x14(%rbp)
jne 0xbed1
movq -0x20(%rbp), %rdi
callq 0xcaf0
jmp 0xbdd8
movl -0x4(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xbef3
movl -0x4(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x16(%rax)
jmp 0xbf0e
movq -0x20(%rbp), %rax
movswl 0x16(%rax), %eax
movl %eax, -0x4(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movl -0x4(%rbp), %eax
andl $0xf, %eax
movl %eax, -0xc(%rbp)
movl -0x4(%rbp), %eax
sarl $0x4, %eax
movl %eax, -0x8(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x3b15(%rip), %rax      # 0xfa40
movl (%rax,%rcx,4), %eax
movl %eax, -0x10(%rbp)
cmpl $0xb, -0x8(%rbp)
jne 0xbf7b
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
cmpl $0x7e, %eax
jne 0xbf50
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movzbl (%rax), %eax
cmpl $0x70, %eax
jne 0xbf79
movq 0x13141(%rip), %rax     # 0x1f0a8
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movzbl 0x1(%rcx), %edi
callq *%rax
jmp 0xbf7b
cmpl $0x9, -0xc(%rbp)
jne 0xbfa7
cmpl $0x9, -0x8(%rbp)
jne 0xbfa5
movq 0x1311a(%rip), %rax     # 0x1f0a8
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movzbl (%rcx), %edi
addl $0x80, %edi
callq *%rax
jmp 0xbfc7
cmpl $0xc, -0x8(%rbp)
jne 0xbfc5
movq 0x130f4(%rip), %rax     # 0x1f0a8
movq 0x40(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movzbl (%rcx), %edi
callq *%rax
jmp 0xbfc7
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0xcaf0
jmp 0xbdd8
movq -0x20(%rbp), %rax
addq $0x178, %rax            # imm = 0x178
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbdaa
callq 0xb260
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)