// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl -0x14(%rbp), %eax
addl $-0x7, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x77, %eax
ja 0xd332
movq -0x30(%rbp), %rax
leaq 0x2a77(%rip), %rcx      # 0xf860
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
jmp 0xd358
movq -0x8(%rbp), %rax
cmpb $0x0, 0x172(%rax)
jne 0xce1f
movl -0x10(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0xabf0
jmp 0xd358
jmp 0xd358
movq -0x8(%rbp), %rax
cmpb $0x0, 0x171(%rax)
je 0xce5a
movq 0x1226b(%rip), %rax     # 0x1f0a8
movq 0x20(%rax), %rax
movl -0x10(%rbp), %edi
movl -0x18(%rbp), %ecx
andl $0x7f, %ecx
movslq %ecx, %rdx
leaq 0x122ac(%rip), %rcx     # 0x1f100
movsbl (%rcx,%rdx), %esi
callq *%rax
jmp 0xd358
movq -0x8(%rbp), %rax
cmpb $0x0, 0x172(%rax)
je 0xce77
movl -0x10(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0xabf0
jmp 0xd358
jmp 0xd358
movq -0x8(%rbp), %rax
movswl 0x18(%rax), %eax
cmpl 0x12221(%rip), %eax     # 0x1f0b0
je 0xceb6
cmpl $0x0, 0x12218(%rip)     # 0x1f0b0
jl 0xceb6
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12207(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0xcebb
jmp 0xd358
movl 0x121ef(%rip), %eax     # 0x1f0b0
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x18(%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x121d5(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x121b3(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movw 0x10(%rax), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x30(%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12191(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12170(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movw 0x12(%rax), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x16(%rax)
cmpl $0x0, -0xc(%rbp)
je 0xcf5e
jmp 0xd358
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12143(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, 0x12173(%rip)     # 0x1f0f0
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12124(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, 0x12148(%rip)     # 0x1f0e4
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12105(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x1c(%rax), %eax
movl %eax, 0x12138(%rip)     # 0x1f0f4
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x120e5(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x1e(%rax), %eax
movl %eax, 0x8c88(%rip)      # 0x15c64
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x120c5(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x20(%rax), %eax
movl %eax, 0x8c6c(%rip)      # 0x15c68
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x120a5(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x22(%rax), %eax
movl %eax, 0x12164(%rip)     # 0x1f180
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12085(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x24(%rax), %eax
movl %eax, 0x12148(%rip)     # 0x1f184
movq -0x8(%rbp), %rax
addq $0x20, %rax
movslq 0x12065(%rip), %rcx     # 0x1f0b0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movswl 0x26(%rax), %eax
movl %eax, 0x1212c(%rip)     # 0x1f188
movl $0x1, -0xc(%rbp)
jmp 0xd358
cmpl $0x0, -0x18(%rbp)
jne 0xd077
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0xd07d
movl -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x76, -0x14(%rbp)
jne 0xd099
movq 0x12036(%rip), %rax     # 0x1f0c0
movq %rax, -0x20(%rbp)
movl 0x12034(%rip), %eax     # 0x1f0c8
movl %eax, -0x24(%rbp)
jmp 0xd0a8
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
jmp 0xd0aa
cmpl $0x0, -0x24(%rbp)
jle 0xd1ac
movl -0x28(%rbp), %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
movw 0x16(%rax), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x32(%rax)
movq -0x20(%rbp), %rax
movw 0x14(%rax), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x4c(%rax)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x48(%rax)
movl 0x11fda(%rip), %ecx     # 0x1f0f0
movq -0x20(%rbp), %rax
movl %ecx, 0x34(%rax)
movl 0x11fc1(%rip), %ecx     # 0x1f0e4
movq -0x20(%rbp), %rax
movl %ecx, 0x38(%rax)
movl 0x11fc4(%rip), %eax     # 0x1f0f4
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x3c(%rax)
movl 0x8b23(%rip), %eax      # 0x15c64
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x3e(%rax)
movl 0x8b16(%rip), %eax      # 0x15c68
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x40(%rax)
movl 0x1201d(%rip), %eax     # 0x1f180
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x42(%rax)
movl 0x12010(%rip), %eax     # 0x1f184
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x44(%rax)
movl 0x12003(%rip), %eax     # 0x1f188
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x46(%rax)
movq -0x20(%rbp), %rax
addq $0x178, %rax            # imm = 0x178
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd0aa
jmp 0xd358
cmpl $0x7f, -0x18(%rbp)
jne 0xd1cf
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0xd1cf
movq -0x8(%rbp), %rax
movswl 0x30(%rax), %eax
cmpl $0x0, %eax
jne 0xd1d4
jmp 0xd358
cmpl $0x77, -0x14(%rbp)
jne 0xd1fa
movq 0x11edf(%rip), %rax     # 0x1f0c0
movq %rax, -0x20(%rbp)
movl 0x11edd(%rip), %eax     # 0x1f0c8
movl %eax, -0x24(%rbp)
movl $0x0, 0x11ef4(%rip)     # 0x1f0ec
jmp 0xd218
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl 0x11edd(%rip), %eax     # 0x1f0ec
addl $-0x1, %eax
movl %eax, 0x11ed4(%rip)     # 0x1f0ec
jmp 0xd21a
cmpl $0x0, -0x24(%rbp)
jle 0xd330
movq -0x20(%rbp), %rax
movswl 0x30(%rax), %eax
cmpl $-0x1, %eax
je 0xd241
movq -0x20(%rbp), %rax
movw 0x30(%rax), %cx
addw $-0x1, %cx
movw %cx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movw 0x32(%rax), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x16(%rax)
movq -0x20(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rax
movw 0x4c(%rax), %cx
movq -0x20(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x20(%rbp), %rax
cmpw $0x0, 0x14(%rax)
je 0xd299
movl 0x11e5c(%rip), %eax     # 0x1f0ec
addl $0x1, %eax
movl %eax, 0x11e53(%rip)     # 0x1f0ec
cmpl $0x0, -0xc(%rbp)
jne 0xd314
movq -0x20(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, 0x11e44(%rip)     # 0x1f0f0
movq -0x20(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, 0x11e2b(%rip)     # 0x1f0e4
movq -0x20(%rbp), %rax
movswl 0x3c(%rax), %eax
movl %eax, 0x11e2d(%rip)     # 0x1f0f4
movq -0x20(%rbp), %rax
movswl 0x3e(%rax), %eax
movl %eax, 0x898f(%rip)      # 0x15c64
movq -0x20(%rbp), %rax
movswl 0x40(%rax), %eax
movl %eax, 0x8985(%rip)      # 0x15c68
movq -0x20(%rbp), %rax
movswl 0x42(%rax), %eax
movl %eax, 0x11e8f(%rip)     # 0x1f180
movq -0x20(%rbp), %rax
movswl 0x44(%rax), %eax
movl %eax, 0x11e85(%rip)     # 0x1f184
movq -0x20(%rbp), %rax
movswl 0x46(%rax), %eax
movl %eax, 0x11e7b(%rip)     # 0x1f188
movl $0x1, -0xc(%rbp)
movq -0x20(%rbp), %rax
addq $0x178, %rax            # imm = 0x178
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd21a
jmp 0xd358
movq 0x11d6f(%rip), %rax     # 0x1f0a8
cmpq $0x0, 0x18(%rax)
je 0xd356
movq 0x11d61(%rip), %rax     # 0x1f0a8
movq 0x18(%rax), %rax
movl -0x10(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq *%rax
jmp 0xd358
movl -0xc(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)