// File: /workspace/github_c_makefile_star2_O3/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 0x11676(%rip), %rbx     # 0x19680
xorl %r14d, %r14d
xorl %r15d, %r15d
movl $0x0, 0x4(%rsp)
cmpl 0x11669(%rip), %r13d    # 0x19688
jge 0x826f
testq %rbx, %rbx
je 0x826f
cmpw $0x0, 0x14(%rbx)
je 0x8255
movl 0x10(%rbx), %eax
testl %eax, %eax
jne 0x8255
movq 0x8(%rbx), %rcx
movzbl (%rcx), %edi
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rbx)
movl %edi, %edx
notl %edx
testb $-0x10, %dl
jne 0x80d8
cmpl $0xf0, %edi
je 0x8074
cmpl $0xff, %edi
je 0x807e
cmpl $0xf7, %edi
jne 0x8086
movq %rbx, %rdi
callq 0x84a8
jmp 0x8086
movq %rbx, %rdi
callq 0x8591
movzwl 0x14(%rbx), %ecx
testw %cx, %cx
je 0x8255
movq 0x8(%rbx), %rdx
movzbl (%rdx), %eax
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rbx)
testb %al, %al
jns 0x80c7
andl $0x7f, %eax
addq $0x2, %rdx
movzbl -0x1(%rdx), %esi
movq %rdx, 0x8(%rbx)
shll $0x7, %eax
movl %esi, %edi
andl $0x7f, %edi
orl %edi, %eax
incq %rdx
testb %sil, %sil
js 0x80ad
movl %eax, 0x10(%rbx)
testw %cx, %cx
jne 0x803c
jmp 0x8255
testb %dil, %dil
js 0x80ea
movswl 0x16(%rbx), %edi
movq %rcx, 0x8(%rbx)
movq %rcx, %rax
jmp 0x80ee
movw %di, 0x16(%rbx)
movl %edi, %ebp
sarl $0x4, %ebp
movslq %ebp, %rcx
leaq -0x8(%rcx), %rdx
cmpq $0x6, %rdx
ja 0x8124
movzbl (%rax), %r14d
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rbx)
movl $0x4f00, %edx           # imm = 0x4F00
btq %rcx, %rdx
jae 0x8124
movzbl 0x1(%rax), %r15d
addq $0x2, %rax
movq %rax, 0x8(%rbx)
movl %edi, %r12d
andl $0xf, %r12d
movl %r12d, %eax
leaq 0x1146b(%rip), %rcx     # 0x195a0
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x8185
movl %r14d, %esi
movl %r15d, %edx
callq *%rax
testl %eax, %eax
jne 0x8185
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
testb %al, %al
jns 0x817d
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 0x8164
movl %eax, 0x10(%rbx)
jmp 0x802e
addl $-0xa, %ebp
cmpl $0x4, %ebp
ja 0x8219
leaq 0x2c3c(%rip), %rcx      # 0xadd4
movslq (%rcx,%rbp,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x114c0(%rip), %rax     # 0x19668
movq 0x10(%rax), %rax
jmp 0x81b9
movq 0x114b3(%rip), %rax     # 0x19668
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x8219
movl %r12d, %edi
movl %r14d, %esi
movl %r15d, %edx
callq *%rax
jmp 0x8219
movq 0x11496(%rip), %rax     # 0x19668
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x8219
cmpb $0x0, 0x171(%rbx)
jne 0x8219
jmp 0x81f6
movq 0x1147b(%rip), %rax     # 0x19668
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x8219
movl %r12d, %edi
movl %r14d, %esi
callq *%rax
jmp 0x8219
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl %r12d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
callq 0x86ca
movl %eax, 0x4(%rsp)
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
testb %al, %al
jns 0x817d
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 0x8237
jmp 0x817d
decl 0x10(%rbx)
addq $0x178, %rbx            # imm = 0x178
incl %r13d
cmpl $0x0, 0x1143f(%rip)     # 0x196a8
jne 0x8018
callq 0x8a0e
movl 0x4(%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq