// File: /workspace/github_c_makefile_star2_O3/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 0x88ce
leaq 0x2702(%rip), %rsi      # 0xade8
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 0x8707
movl 0x10f81(%rip), %edx     # 0x19688
testl %edx, %edx
jle 0x8a01
orl %r8d, %eax
cmpl $0x76, %ecx
jne 0x871e
movq 0x10f62(%rip), %rdi     # 0x19680
movl 0x10f88(%rip), %ecx     # 0x196ac
movl 0x10f76(%rip), %esi     # 0x196a0
movzwl 0x10f7e(%rip), %r8d     # 0x196b0
movzwl 0x7b6a(%rip), %r9d      # 0x102a4
movzwl 0x7b66(%rip), %r10d     # 0x102a8
movzwl 0x10ff6(%rip), %r11d    # 0x19740
movzwl 0x10ff3(%rip), %ebp     # 0x19744
movzwl 0x10fef(%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
ja 0x875f
jmp 0x8a01
cmpl $0x7f, %r8d
jne 0x8a01
cmpq $0x0, 0x28(%rdi)
je 0x8a01
cmpw $0x0, 0x30(%rdi)
je 0x8a01
movl 0x10ec2(%rip), %edx     # 0x196a8
decl %edx
xorl %eax, %eax
cmpl $0x77, %ecx
movq 0x10e8c(%rip), %rsi     # 0x19680
cmovnel %edx, %eax
movl %eax, 0x10eab(%rip)     # 0x196a8
movl $0x1, %edx
cmovel 0x10e7f(%rip), %edx     # 0x19688
testl %edx, %edx
jle 0x8a01
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 0x8838
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 0x8862
incl %eax
movl %eax, 0x10e46(%rip)     # 0x196a8
testb $0x1, %cl
je 0x88b5
movl -0x18(%rdi), %ecx
movl %ecx, 0x10e3c(%rip)     # 0x196ac
movl -0x14(%rdi), %ecx
movl %ecx, 0x10e27(%rip)     # 0x196a0
movswl -0x10(%rdi), %ecx
movl %ecx, 0x10e2d(%rip)     # 0x196b0
movswl -0xe(%rdi), %ecx
movl %ecx, 0x7a17(%rip)      # 0x102a4
movswl -0xc(%rdi), %ecx
movl %ecx, 0x7a11(%rip)      # 0x102a8
movswl -0xa(%rdi), %ecx
movl %ecx, 0x10e9f(%rip)     # 0x19740
movswl -0x8(%rdi), %ecx
movl %ecx, 0x10e99(%rip)     # 0x19744
movswl -0x6(%rdi), %ecx
movl %ecx, 0x10e93(%rip)     # 0x19748
decl %edx
addq $0x178, %rdi            # imm = 0x178
xorl %ecx, %ecx
cmpl $0x1, %edx
jg 0x8828
jmp 0x8a01
cmpl $0x7, %ecx
jne 0x88e5
cmpb $0x0, 0x172(%rdi)
jne 0x8a01
jmp 0x89f1
movq 0x10d7c(%rip), %rax     # 0x19668
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x8a01
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
callq *%rax
jmp 0x8a01
movswl 0x18(%rdi), %eax
movl 0x10d5f(%rip), %edx     # 0x19670
cmpl %eax, %edx
sete %al
testl %edx, %edx
sets %cl
orb %al, %cl
jne 0x8a01
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
movq 0x20(%rdi,%rax), %rsi
testq %rsi, %rsi
je 0x8a01
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 %rsi, 0x8(%rdi)
movzwl 0x12(%rcx,%rax), %edx
movw %dx, 0x16(%rdi)
testl %ebx, %ebx
jne 0x89ba
movl 0x14(%rcx,%rax), %edx
movl %edx, 0x10d3e(%rip)     # 0x196ac
movl 0x18(%rcx,%rax), %edx
movl %edx, 0x10d28(%rip)     # 0x196a0
movswl 0x1c(%rcx,%rax), %edx
movl %edx, 0x10d2d(%rip)     # 0x196b0
movswl 0x1e(%rcx,%rax), %edx
movl %edx, 0x7916(%rip)      # 0x102a4
movswl 0x20(%rcx,%rax), %edx
movl %edx, 0x790f(%rip)      # 0x102a8
movswl 0x22(%rcx,%rax), %edx
movl %edx, 0x10d9c(%rip)     # 0x19740
movswl 0x24(%rcx,%rax), %edx
movl %edx, 0x10d95(%rip)     # 0x19744
movswl 0x26(%rcx,%rax), %eax
movl %eax, 0x10d8e(%rip)     # 0x19748
movl $0x1, %ebx
jmp 0x8a01
cmpb $0x0, 0x171(%rdi)
je 0x8a01
movq 0x10c97(%rip), %rax     # 0x19668
andl $0x7f, %r8d
leaq 0x10ce4(%rip), %rcx     # 0x196c0
movsbl (%r8,%rcx), %esi
movl %edx, %edi
callq *0x20(%rax)
jmp 0x8a01
cmpb $0x0, 0x172(%rdi)
je 0x8a01
movl %edx, %edi
movl %r8d, %esi
callq 0x6e76
jmp 0x8a01
incq 0x8(%rdi)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq