// File: /workspace/github_c_makefile_star2_O1/jonof[P]jfaudiolib/src/midi.c
// Function: MIDI_InterpretControllerInfo
static int _MIDI_InterpretControllerInfo
   (
   track *Track,
   int   TimeSet,
   int   channel,
   int   c1,
   int   c2
   )

   {
   track *trackptr;
   int tracknum;
   int loopcount;

   switch( c1 )
      {
      case MIDI_MONO_MODE_ON :
         Track->pos++;
         break;

      case MIDI_VOLUME :
         if ( !Track->EMIDI_VolumeChange )
            {
            _MIDI_SetChannelVolume( channel, c2 );
            }
         break;

      case EMIDI_INCLUDE_TRACK :
      case EMIDI_EXCLUDE_TRACK :
         break;

      case EMIDI_PROGRAM_CHANGE :
         if ( Track->EMIDI_ProgramChange )
            {
            _MIDI_Funcs->ProgramChange( channel, MIDI_PatchMap[ c2 & 0x7f ] );
            }
         break;

      case EMIDI_VOLUME_CHANGE :
         if ( Track->EMIDI_VolumeChange )
            {
            _MIDI_SetChannelVolume( channel, c2 );
            }
         break;

      case EMIDI_CONTEXT_START :
         break;

      case EMIDI_CONTEXT_END :
         if ( ( Track->currentcontext == _MIDI_Context ) ||
            ( _MIDI_Context < 0 ) ||
            ( Track->context[ _MIDI_Context ].pos == NULL ) )
            {
            break;
            }

         Track->currentcontext = _MIDI_Context;
         Track->context[ 0 ].loopstart = Track->context[ _MIDI_Context ].loopstart;
         Track->context[ 0 ].loopcount = Track->context[ _MIDI_Context ].loopcount;
         Track->pos           = Track->context[ _MIDI_Context ].pos;
         Track->RunningStatus = Track->context[ _MIDI_Context ].RunningStatus;

         if ( TimeSet )
            {
            break;
            }

         _MIDI_Time             = Track->context[ _MIDI_Context ].time;
         _MIDI_FPSecondsPerTick = Track->context[ _MIDI_Context ].FPSecondsPerTick;
         _MIDI_Tick             = Track->context[ _MIDI_Context ].tick;
         _MIDI_Beat             = Track->context[ _MIDI_Context ].beat;
         _MIDI_Measure          = Track->context[ _MIDI_Context ].measure;
         _MIDI_BeatsPerMeasure  = Track->context[ _MIDI_Context ].BeatsPerMeasure;
         _MIDI_TicksPerBeat     = Track->context[ _MIDI_Context ].TicksPerBeat;
         _MIDI_TimeBase         = Track->context[ _MIDI_Context ].TimeBase;
         TimeSet = TRUE;
         break;

      case EMIDI_LOOP_START :
      case EMIDI_SONG_LOOP_START :
         if ( c2 == 0 )
            {
            loopcount = EMIDI_INFINITE;
            }
         else
            {
            loopcount = c2;
            }

         if ( c1 == EMIDI_SONG_LOOP_START )
            {
            trackptr = _MIDI_TrackPtr;
            tracknum = _MIDI_NumTracks;
            }
         else
            {
            trackptr = Track;
            tracknum = 1;
            }

         while( tracknum > 0 )
            {
            trackptr->context[ 0 ].loopcount        = loopcount;
            trackptr->context[ 0 ].pos              = trackptr->pos;
            trackptr->context[ 0 ].loopstart        = trackptr->pos;
            trackptr->context[ 0 ].RunningStatus    = trackptr->RunningStatus;
            trackptr->context[ 0 ].active           = trackptr->active;
            trackptr->context[ 0 ].delay            = trackptr->delay;
            trackptr->context[ 0 ].time             = _MIDI_Time;
            trackptr->context[ 0 ].FPSecondsPerTick = _MIDI_FPSecondsPerTick;
            trackptr->context[ 0 ].tick             = _MIDI_Tick;
            trackptr->context[ 0 ].beat             = _MIDI_Beat;
            trackptr->context[ 0 ].measure          = _MIDI_Measure;
            trackptr->context[ 0 ].BeatsPerMeasure  = _MIDI_BeatsPerMeasure;
            trackptr->context[ 0 ].TicksPerBeat     = _MIDI_TicksPerBeat;
            trackptr->context[ 0 ].TimeBase         = _MIDI_TimeBase;
            trackptr++;
            tracknum--;
            }
         break;

      case EMIDI_LOOP_END :
      case EMIDI_SONG_LOOP_END :
         if ( ( c2 != EMIDI_END_LOOP_VALUE ) ||
            ( Track->context[ 0 ].loopstart == NULL ) ||
            ( Track->context[ 0 ].loopcount == 0 ) )
            {
            break;
            }

         if ( c1 == EMIDI_SONG_LOOP_END )
            {
            trackptr = _MIDI_TrackPtr;
            tracknum = _MIDI_NumTracks;
            _MIDI_ActiveTracks = 0;
            }
         else
            {
            trackptr = Track;
            tracknum = 1;
            _MIDI_ActiveTracks--;
            }

         while( tracknum > 0 )
            {
            if ( trackptr->context[ 0 ].loopcount != EMIDI_INFINITE )
               {
               trackptr->context[ 0 ].loopcount--;
               }

            trackptr->pos           = trackptr->context[ 0 ].loopstart;
            trackptr->RunningStatus = trackptr->context[ 0 ].RunningStatus;
            trackptr->delay         = trackptr->context[ 0 ].delay;
            trackptr->active        = trackptr->context[ 0 ].active;
            if ( trackptr->active )
               {
               _MIDI_ActiveTracks++;
               }

            if ( !TimeSet )
               {
               _MIDI_Time             = trackptr->context[ 0 ].time;
               _MIDI_FPSecondsPerTick = trackptr->context[ 0 ].FPSecondsPerTick;
               _MIDI_Tick             = trackptr->context[ 0 ].tick;
               _MIDI_Beat             = trackptr->context[ 0 ].beat;
               _MIDI_Measure          = trackptr->context[ 0 ].measure;
               _MIDI_BeatsPerMeasure  = trackptr->context[ 0 ].BeatsPerMeasure;
               _MIDI_TicksPerBeat     = trackptr->context[ 0 ].TicksPerBeat;
               _MIDI_TimeBase         = trackptr->context[ 0 ].TimeBase;
               TimeSet = TRUE;
               }

            trackptr++;
            tracknum--;
            }
         break;

      default :
         if ( _MIDI_Funcs->ControlChange )
            {
            _MIDI_Funcs->ControlChange( channel, c1, c2 );
            }
      }

   return TimeSet;
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
leal -0x6e(%rcx), %eax
cmpl $0x10, %eax
ja 0x885e
leaq 0x2702(%rip), %rsi      # 0xad78
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x1, %r8d
sbbl %eax, %eax
movl $0x1, %edx
cmpl $0x76, %ecx
jne 0x8697
movl 0x10ff1(%rip), %edx     # 0x19688
testl %edx, %edx
jle 0x8993
orl %r8d, %eax
cmpl $0x76, %ecx
jne 0x86ae
movq 0x10fd2(%rip), %rdi     # 0x19680
movl 0x10ff8(%rip), %ecx     # 0x196ac
movl 0x10fe6(%rip), %esi     # 0x196a0
movzwl 0x10fee(%rip), %r8d     # 0x196b0
movzwl 0x7bda(%rip), %r9d      # 0x102a4
movzwl 0x7bd6(%rip), %r10d     # 0x102a8
movzwl 0x11066(%rip), %r11d    # 0x19740
movzwl 0x11063(%rip), %ebp     # 0x19744
movzwl 0x1105f(%rip), %r14d    # 0x19748
incl %edx
addq $0x4c, %rdi
movw %ax, -0x1c(%rdi)
movq -0x44(%rdi), %r15
movq %r15, -0x2c(%rdi)
movq %r15, -0x24(%rdi)
movzwl -0x36(%rdi), %r15d
movw %r15w, -0x1a(%rdi)
movzwl -0x38(%rdi), %r15d
movw %r15w, (%rdi)
movl -0x3c(%rdi), %r15d
movl %r15d, -0x4(%rdi)
movl %ecx, -0x18(%rdi)
movl %esi, -0x14(%rdi)
movw %r8w, -0x10(%rdi)
movw %r9w, -0xe(%rdi)
movw %r10w, -0xc(%rdi)
movw %r11w, -0xa(%rdi)
movw %bp, -0x8(%rdi)
movw %r14w, -0x6(%rdi)
decl %edx
addq $0x178, %rdi            # imm = 0x178
cmpl $0x1, %edx
jg 0x86ef
jmp 0x8993
cmpl $0x7f, %r8d
jne 0x8993
cmpq $0x0, 0x28(%rdi)
je 0x8993
cmpw $0x0, 0x30(%rdi)
je 0x8993
movl 0x10f32(%rip), %edx     # 0x196a8
decl %edx
xorl %eax, %eax
cmpl $0x77, %ecx
cmovnel %edx, %eax
movl $0x1, %edx
cmovel 0x10efc(%rip), %edx     # 0x19688
movq 0x10eed(%rip), %rsi     # 0x19680
movl %eax, 0x10f0f(%rip)     # 0x196a8
testl %edx, %edx
jle 0x8993
cmpl $0x77, %ecx
cmoveq %rsi, %rdi
testl %ebx, %ebx
sete %cl
incl %edx
addq $0x4c, %rdi
movl $0x1, %ebx
movzwl -0x1c(%rdi), %esi
cmpw $-0x1, %si
je 0x87c8
decl %esi
movw %si, -0x1c(%rdi)
movq -0x24(%rdi), %rsi
movq %rsi, -0x44(%rdi)
movzwl -0x1a(%rdi), %esi
movw %si, -0x36(%rdi)
movl -0x4(%rdi), %esi
movl %esi, -0x3c(%rdi)
movzwl (%rdi), %esi
movw %si, -0x38(%rdi)
testw %si, %si
je 0x87f2
incl %eax
movl %eax, 0x10eb6(%rip)     # 0x196a8
testb $0x1, %cl
je 0x8845
movl -0x18(%rdi), %ecx
movl %ecx, 0x10eac(%rip)     # 0x196ac
movl -0x14(%rdi), %ecx
movl %ecx, 0x10e97(%rip)     # 0x196a0
movswl -0x10(%rdi), %ecx
movl %ecx, 0x10e9d(%rip)     # 0x196b0
movswl -0xe(%rdi), %ecx
movl %ecx, 0x7a87(%rip)      # 0x102a4
movswl -0xc(%rdi), %ecx
movl %ecx, 0x7a81(%rip)      # 0x102a8
movswl -0xa(%rdi), %ecx
movl %ecx, 0x10f0f(%rip)     # 0x19740
movswl -0x8(%rdi), %ecx
movl %ecx, 0x10f09(%rip)     # 0x19744
movswl -0x6(%rdi), %ecx
movl %ecx, 0x10f03(%rip)     # 0x19748
decl %edx
addq $0x178, %rdi            # imm = 0x178
xorl %ecx, %ecx
cmpl $0x1, %edx
jg 0x87b8
jmp 0x8993
cmpl $0x7, %ecx
jne 0x8875
cmpb $0x0, 0x172(%rdi)
jne 0x8993
jmp 0x8983
movq 0x10dec(%rip), %rax     # 0x19668
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x8993
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
callq *%rax
jmp 0x8993
movswl 0x18(%rdi), %eax
movl 0x10dcf(%rip), %edx     # 0x19670
cmpl %eax, %edx
sete %al
testl %edx, %edx
sets %cl
orb %al, %cl
jne 0x8993
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
cmpq $0x0, 0x20(%rdi,%rax)
je 0x8993
leaq 0x20(%rdi), %rcx
movw %dx, 0x18(%rdi)
movq 0x8(%rcx,%rax), %rdx
movq %rdx, 0x28(%rdi)
movzwl 0x10(%rcx,%rax), %edx
movw %dx, 0x30(%rdi)
movq (%rcx,%rax), %rdx
movq %rdx, 0x8(%rdi)
movzwl 0x12(%rcx,%rax), %edx
movw %dx, 0x16(%rdi)
testl %ebx, %ebx
jne 0x894c
movl 0x14(%rcx,%rax), %edx
movl %edx, 0x10dac(%rip)     # 0x196ac
movl 0x18(%rcx,%rax), %edx
movl %edx, 0x10d96(%rip)     # 0x196a0
movswl 0x1c(%rcx,%rax), %edx
movl %edx, 0x10d9b(%rip)     # 0x196b0
movswl 0x1e(%rcx,%rax), %edx
movl %edx, 0x7984(%rip)      # 0x102a4
movswl 0x20(%rcx,%rax), %edx
movl %edx, 0x797d(%rip)      # 0x102a8
movswl 0x22(%rcx,%rax), %edx
movl %edx, 0x10e0a(%rip)     # 0x19740
movswl 0x24(%rcx,%rax), %edx
movl %edx, 0x10e03(%rip)     # 0x19744
movswl 0x26(%rcx,%rax), %eax
movl %eax, 0x10dfc(%rip)     # 0x19748
movl $0x1, %ebx
jmp 0x8993
cmpb $0x0, 0x171(%rdi)
je 0x8993
movq 0x10d05(%rip), %rax     # 0x19668
andl $0x7f, %r8d
leaq 0x10d52(%rip), %rcx     # 0x196c0
movsbl (%r8,%rcx), %esi
movl %edx, %edi
callq *0x20(%rax)
jmp 0x8993
cmpb $0x0, 0x172(%rdi)
je 0x8993
movl %edx, %edi
movl %r8d, %esi
callq 0x6dea
jmp 0x8993
incq 0x8(%rdi)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq