// File: /workspace/github_c_makefile_star2_O2/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 0x7ef6
leaq 0x200f(%rip), %rsi      # 0x9d48
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
xorl %eax, %eax
cmpl $0x1, %r8d
sbbl %eax, %eax
orl %r8d, %eax
cmpl $0x76, %ecx
movl 0x10966(%rip), %ecx     # 0x186bc
movl 0x10954(%rip), %edx     # 0x186b0
movzwl 0x1095d(%rip), %esi     # 0x186c0
movzwl 0x7549(%rip), %r8d      # 0xf2b4
movzwl 0x7545(%rip), %r9d      # 0xf2b8
movzwl 0x109d5(%rip), %r10d    # 0x18750
movzwl 0x109d1(%rip), %r11d    # 0x18754
movzwl 0x109ce(%rip), %ebp     # 0x18758
cmoveq 0x108fe(%rip), %rdi     # 0x18690
pushq $0x1
popq %r14
cmovel 0x108fa(%rip), %r14d    # 0x18698
addq $0x4c, %rdi
testl %r14d, %r14d
jle 0x8025
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 %edx, -0x14(%rdi)
movw %si, -0x10(%rdi)
movw %r8w, -0xe(%rdi)
movw %r9w, -0xc(%rdi)
movw %r10w, -0xa(%rdi)
movw %r11w, -0x8(%rdi)
movw %bp, -0x6(%rdi)
decl %r14d
addq $0x178, %rdi            # imm = 0x178
jmp 0x7da2
cmpl $0x7f, %r8d
jne 0x8025
cmpq $0x0, 0x28(%rdi)
je 0x8025
cmpw $0x0, 0x30(%rdi)
je 0x8025
movl 0x1088e(%rip), %edx     # 0x186b8
decl %edx
xorl %eax, %eax
cmpl $0x77, %ecx
cmovnel %edx, %eax
movl %eax, 0x1087e(%rip)     # 0x186b8
cmoveq 0x1084e(%rip), %rdi     # 0x18690
pushq $0x1
popq %rcx
movl 0x1084d(%rip), %edx     # 0x18698
cmovnel %ecx, %edx
addq $0x4c, %rdi
testl %edx, %edx
jle 0x8025
movzwl -0x1c(%rdi), %esi
cmpw $-0x1, %si
je 0x7e6a
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 0x7e94
incl %eax
movl %eax, 0x10824(%rip)     # 0x186b8
testl %ebx, %ebx
jne 0x7ee6
movl -0x18(%rdi), %esi
movl %esi, 0x1081b(%rip)     # 0x186bc
movl -0x14(%rdi), %esi
movl %esi, 0x10806(%rip)     # 0x186b0
movswl -0x10(%rdi), %esi
movl %esi, 0x1080c(%rip)     # 0x186c0
movswl -0xe(%rdi), %esi
movl %esi, 0x73f6(%rip)      # 0xf2b4
movswl -0xc(%rdi), %esi
movl %esi, 0x73f0(%rip)      # 0xf2b8
movswl -0xa(%rdi), %esi
movl %esi, 0x1087e(%rip)     # 0x18750
movswl -0x8(%rdi), %esi
movl %esi, 0x10878(%rip)     # 0x18754
movswl -0x6(%rdi), %esi
movl %esi, 0x10872(%rip)     # 0x18758
decl %edx
addq $0x178, %rdi            # imm = 0x178
movl %ecx, %ebx
jmp 0x7e52
cmpl $0x7, %ecx
jne 0x7f0d
cmpb $0x0, 0x172(%rdi)
jne 0x8025
jmp 0x8015
movq 0x10764(%rip), %rax     # 0x18678
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x8025
movl %edx, %edi
movl %ecx, %esi
movl %r8d, %edx
callq *%rax
jmp 0x8025
movswl 0x18(%rdi), %eax
movl 0x10747(%rip), %edx     # 0x18680
cmpl %eax, %edx
sete %al
testl %edx, %edx
sets %cl
orb %al, %cl
jne 0x8025
imulq $0x30, %rdx, %rax
movq 0x20(%rdi,%rax), %rsi
testq %rsi, %rsi
je 0x8025
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)
pushq $0x1
popq %rdx
testl %ebx, %ebx
jne 0x7fe1
movl 0x14(%rcx,%rax), %esi
movl %esi, 0x10727(%rip)     # 0x186bc
movl 0x18(%rcx,%rax), %esi
movl %esi, 0x10711(%rip)     # 0x186b0
movswl 0x1c(%rcx,%rax), %esi
movl %esi, 0x10716(%rip)     # 0x186c0
movswl 0x1e(%rcx,%rax), %esi
movl %esi, 0x72ff(%rip)      # 0xf2b4
movswl 0x20(%rcx,%rax), %esi
movl %esi, 0x72f8(%rip)      # 0xf2b8
movswl 0x22(%rcx,%rax), %esi
movl %esi, 0x10785(%rip)     # 0x18750
movswl 0x24(%rcx,%rax), %esi
movl %esi, 0x1077e(%rip)     # 0x18754
movswl 0x26(%rcx,%rax), %eax
movl %eax, 0x10777(%rip)     # 0x18758
movl %edx, %ebx
jmp 0x8025
cmpb $0x0, 0x171(%rdi)
je 0x8025
movq 0x10683(%rip), %rax     # 0x18678
andl $0x7f, %r8d
leaq 0x106d0(%rip), %rcx     # 0x186d0
movsbl (%r8,%rcx), %esi
movl %edx, %edi
callq *0x20(%rax)
jmp 0x8025
cmpb $0x0, 0x172(%rdi)
je 0x8025
movl %edx, %edi
movl %r8d, %esi
callq 0x68d0
jmp 0x8025
incq 0x8(%rdi)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq