// File: /workspace/github_c_makefile_star2_O1/jonof[P]jfaudiolib/src/midi.c
// Function: MIDI_ProcessNextTick
static int _MIDI_ProcessNextTick
   (
   void
   )

   {
   int   event;
   int   channel;
   int   command;
   track *Track;
   int   tracknum;
   int   status;
   int   c1 = 0;
   int   c2 = 0;
   int   TimeSet = FALSE;

   Track = _MIDI_TrackPtr;
   tracknum = 0;
   while( ( tracknum < _MIDI_NumTracks ) && ( Track != NULL ) )
      {
      while ( ( Track->active ) && ( Track->delay == 0 ) )
         {
         GET_NEXT_EVENT( Track, event );

         if ( GET_MIDI_COMMAND( event ) == MIDI_SPECIAL )
            {
            switch( event )
               {
               case MIDI_SYSEX :
               case MIDI_SYSEX_CONTINUE :
                  _MIDI_SysEx( Track );
                  break;

               case MIDI_META_EVENT :
                  _MIDI_MetaEvent( Track );
                  break;
               }

            if ( Track->active )
               {
               Track->delay = _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 );

         if ( _MIDI_CommandLengths[ command ] > 0 )
            {
            GET_NEXT_EVENT( Track, c1 );
            if ( _MIDI_CommandLengths[ command ] > 1 )
               {
               GET_NEXT_EVENT( Track, c2 );
               }
            }

         if ( _MIDI_RerouteFunctions[ channel ] != NULL )
            {
            status = _MIDI_RerouteFunctions[ channel ]( event, c1, c2 );

            if ( status == MIDI_DONT_PLAY )
               {
               Track->delay = _MIDI_ReadDelta( Track );
               continue;
               }
            }

         switch ( command )
            {
            case MIDI_NOTE_OFF :
               break;

            case MIDI_NOTE_ON :
               break;

            case MIDI_POLY_AFTER_TCH :
               if ( _MIDI_Funcs->PolyAftertouch )
                  {
                  _MIDI_Funcs->PolyAftertouch( channel, c1, c2 );
                  }
               break;

            case MIDI_CONTROL_CHANGE :
               TimeSet = _MIDI_InterpretControllerInfo( Track, TimeSet,
                  channel, c1, c2 );
               break;

            case MIDI_PROGRAM_CHANGE :
               if ( ( _MIDI_Funcs->ProgramChange ) &&
                  ( !Track->EMIDI_ProgramChange ) )
                  {
                  _MIDI_Funcs->ProgramChange( channel, c1 );
                  }
               break;

            case MIDI_AFTER_TOUCH :
               if ( _MIDI_Funcs->ChannelAftertouch )
                  {
                  _MIDI_Funcs->ChannelAftertouch( channel, c1 );
                  }
               break;

            case MIDI_PITCH_BEND :
               if ( _MIDI_Funcs->PitchBend )
                  {
                  _MIDI_Funcs->PitchBend( channel, c1, c2 );
                  }
               break;

            default :
               break;
            }

         Track->delay = _MIDI_ReadDelta( Track );
         }

      Track->delay--;
      Track++;
      tracknum++;

      if ( _MIDI_ActiveTracks == 0 )
         {
         break;
         }
      }

   _MIDI_AdvanceTick();

   return( TimeSet );
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %r13d, %r13d
movq 0x116d5(%rip), %rbx     # 0x19680
xorl %r14d, %r14d
xorl %r15d, %r15d
movl $0x0, 0x4(%rsp)
cmpl 0x116c8(%rip), %r13d    # 0x19688
jge 0x8201
testq %rbx, %rbx
je 0x8201
cmpw $0x0, 0x14(%rbx)
je 0x81e7
cmpl $0x0, 0x10(%rbx)
jne 0x81e7
movq 0x8(%rbx), %rax
movzbl (%rax), %edi
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl %edi, %ecx
notl %ecx
testb $-0x10, %cl
jne 0x8068
cmpl $0xf0, %edi
je 0x8014
cmpl $0xff, %edi
je 0x801e
cmpl $0xf7, %edi
jne 0x8026
movq %rbx, %rdi
callq 0x843a
jmp 0x8026
movq %rbx, %rdi
callq 0x851b
cmpw $0x0, 0x14(%rbx)
je 0x7fcf
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
testb %al, %al
jns 0x8060
andl $0x7f, %eax
addq $0x2, %rcx
movzbl -0x1(%rcx), %edx
movq %rcx, 0x8(%rbx)
shll $0x7, %eax
movl %edx, %esi
andl $0x7f, %esi
orl %esi, %eax
incq %rcx
testb %dl, %dl
js 0x8047
movl %eax, 0x10(%rbx)
jmp 0x7fcf
testb %dil, %dil
js 0x8077
movswl 0x16(%rbx), %edi
movq %rax, 0x8(%rbx)
jmp 0x807b
movw %di, 0x16(%rbx)
movl %edi, %ebp
sarl $0x4, %ebp
movslq %ebp, %rcx
leaq -0x8(%rcx), %rax
cmpq $0x6, %rax
ja 0x80b5
movq 0x8(%rbx), %rax
movzbl (%rax), %r14d
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rbx)
movl $0x4f00, %edx           # imm = 0x4F00
btq %rcx, %rdx
jae 0x80b5
movzbl 0x1(%rax), %r15d
addq $0x2, %rax
movq %rax, 0x8(%rbx)
movl %edi, %r12d
andl $0xf, %r12d
movl %r12d, %eax
leaq 0x114da(%rip), %rcx     # 0x195a0
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x8117
movl %r14d, %esi
movl %r15d, %edx
callq *%rax
testl %eax, %eax
jne 0x8117
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
testb %al, %al
jns 0x8060
andl $0x7f, %eax
addq $0x2, %rcx
movzbl -0x1(%rcx), %edx
movq %rcx, 0x8(%rbx)
shll $0x7, %eax
movl %edx, %esi
andl $0x7f, %esi
orl %esi, %eax
incq %rcx
testb %dl, %dl
js 0x80f9
jmp 0x8060
addl $-0xa, %ebp
cmpl $0x4, %ebp
ja 0x81ab
leaq 0x2c3a(%rip), %rcx      # 0xad64
movslq (%rcx,%rbp,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x1152e(%rip), %rax     # 0x19668
movq 0x10(%rax), %rax
jmp 0x814b
movq 0x11521(%rip), %rax     # 0x19668
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x81ab
movl %r12d, %edi
movl %r14d, %esi
movl %r15d, %edx
callq *%rax
jmp 0x81ab
movq 0x11504(%rip), %rax     # 0x19668
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x81ab
cmpb $0x0, 0x171(%rbx)
jne 0x81ab
jmp 0x8188
movq 0x114e9(%rip), %rax     # 0x19668
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x81ab
movl %r12d, %edi
movl %r14d, %esi
callq *%rax
jmp 0x81ab
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl %r12d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
callq 0x865a
movl %eax, 0x4(%rsp)
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
testb %al, %al
jns 0x8060
andl $0x7f, %eax
addq $0x2, %rcx
movzbl -0x1(%rcx), %edx
movq %rcx, 0x8(%rbx)
shll $0x7, %eax
movl %edx, %esi
andl $0x7f, %esi
orl %esi, %eax
incq %rcx
testb %dl, %dl
js 0x81c9
jmp 0x8060
decl 0x10(%rbx)
addq $0x178, %rbx            # imm = 0x178
incl %r13d
cmpl $0x0, 0x114ad(%rip)     # 0x196a8
jne 0x7fb9
callq 0x89a0
movl 0x4(%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq