// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/multivoc.c
// Function: MV_Init
int MV_Init
   (
   int soundcard,
   int * MixRate,
   int Voices,
   int * numchannels,
   int * samplebits,
   void * initdata
   )

   {
   char *ptr;
   int  status;
   int  buffer;
   int  index;

   if ( MV_Installed )
      {
      MV_Shutdown();
      }

   MV_SetErrorCode( MV_Ok );

   MV_TotalMemory = Voices * sizeof( VoiceNode ) + sizeof( HARSH_CLIP_TABLE_8 ) + TotalBufferSize;
   ptr = (char *) malloc( MV_TotalMemory );
   if ( !ptr )
      {
      MV_SetErrorCode( MV_NoMem );
      return( MV_Error );
      }

   memset(ptr, 0, MV_TotalMemory);

   MV_Voices = ( VoiceNode * )ptr;
   ptr += Voices * sizeof( VoiceNode );

   MV_HarshClipTable = ptr;
   ptr += sizeof(HARSH_CLIP_TABLE_8);

   // Set number of voices before calculating volume table
   MV_MaxVoices = Voices;

   LL_Reset( (VoiceNode*) &VoiceList, next, prev );
   LL_Reset( (VoiceNode*) &VoicePool, next, prev );

   for( index = 0; index < Voices; index++ )
      {
      LL_Add( (VoiceNode*) &VoicePool, &MV_Voices[ index ], next, prev );
      }

   MV_SetReverseStereo( FALSE );

   ASS_PCMSoundDriver = soundcard;

   // Initialize the sound card
   status = SoundDriver_PCM_Init(MixRate, numchannels, samplebits, initdata);
   if ( status != MV_Ok ) {
      MV_SetErrorCode( MV_DriverError );
   }

   if ( MV_ErrorCode != MV_Ok )
      {
      status = MV_ErrorCode;

      free( MV_Voices );
      MV_Voices      = NULL;
      MV_HarshClipTable = NULL;
      MV_TotalMemory = 0;

      MV_SetErrorCode( status );
      return( MV_Error );
      }

   MV_Installed    = TRUE;
   MV_CallBackFunc = NULL;
   MV_RecordFunc   = NULL;
   MV_Recording    = FALSE;
   MV_ReverbLevel  = 0;
   MV_ReverbTable  = NULL;

   // Set the sampling rate
   MV_RequestedMixRate = *MixRate;

   // Set Mixer to play stereo digitized sound
   MV_SetMixMode( *numchannels, *samplebits );
   MV_ReverbDelay = MV_BufferSize * 3;

   // Make sure we don't cross a physical page
   MV_MixBuffer[ MV_NumberOfBuffers ] = ptr;
   for( buffer = 0; buffer < MV_NumberOfBuffers; buffer++ )
      {
      MV_MixBuffer[ buffer ] = ptr;
      ptr += MV_BufferSize;
      }

   // Calculate pan table
   MV_CalcPanTable();

   MV_SetVolume( MV_MaxTotalVolume );

   // Start the playback engine
   status = MV_StartPlayback();
   if ( status != MV_Ok )
      {
      // Preserve error code while we shutdown.
      status = MV_ErrorCode;
      MV_Shutdown();
      MV_SetErrorCode( status );
      return( MV_Error );
      }

   return( MV_Ok );
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpl $0x0, 0xe11b(%rip)      # 0x15c90
je 0x7b7c
callq 0x7ea0
movl $0x0, 0xe10e(%rip)      # 0x15c94
movslq -0x14(%rbp), %rax
imulq $0xa8, %rax, %rax
addq $0x800, %rax            # imm = 0x800
addq $0x1000, %rax           # imm = 0x1000
movl %eax, 0x17395(%rip)     # 0x1ef38
movslq 0x1738e(%rip), %rdi     # 0x1ef38
callq 0x2290
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x7bd0
movl $0x5, 0xe0d0(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7e89
movq -0x38(%rbp), %rdi
movslq 0x1735d(%rip), %rdx     # 0x1ef38
xorl %esi, %esi
callq 0x2100
movq -0x38(%rbp), %rax
movq %rax, 0x17353(%rip)     # 0x1ef40
movslq -0x14(%rbp), %rax
imulq $0xa8, %rax, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, 0x1733d(%rip)     # 0x1ef48
movq -0x38(%rbp), %rax
addq $0x800, %rax            # imm = 0x800
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl %eax, 0xdb1a(%rip)      # 0x1573c
leaq 0xe06f(%rip), %rax      # 0x15c98
movq %rax, 0xe070(%rip)      # 0x15ca0
leaq 0xe061(%rip), %rax      # 0x15c98
movq %rax, 0xe05a(%rip)      # 0x15c98
leaq 0xe10b(%rip), %rax      # 0x15d50
movq %rax, 0xe10c(%rip)      # 0x15d58
leaq 0xe0fd(%rip), %rax      # 0x15d50
movq %rax, 0xe0f6(%rip)      # 0x15d50
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x7cf5
movq 0x172cc(%rip), %rax     # 0x1ef40
movslq -0x44(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
leaq 0xe0c7(%rip), %rcx      # 0x15d50
movq %rcx, (%rax)
movq 0xe0c5(%rip), %rcx      # 0x15d58
movq 0x172a6(%rip), %rax     # 0x1ef40
movslq -0x44(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x1728d(%rip), %rcx     # 0x1ef40
movslq -0x44(%rbp), %rax
imulq $0xa8, %rax, %rax
addq %rax, %rcx
movq 0xe090(%rip), %rax      # 0x15d58
movq %rcx, (%rax)
movq 0x1726e(%rip), %rax     # 0x1ef40
movslq -0x44(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xe071(%rip)      # 0x15d58
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7c61
xorl %edi, %edi
callq 0x7b20
movl -0x8(%rbp), %ecx
leaq 0xd4fa(%rip), %rax      # 0x15200
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x30a0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x7d30
movl $0x3, 0xdf64(%rip)      # 0x15c94
cmpl $0x0, 0xdf5d(%rip)      # 0x15c94
je 0x7d83
movl 0xdf55(%rip), %eax      # 0x15c94
movl %eax, -0x3c(%rbp)
movq 0x171f7(%rip), %rdi     # 0x1ef40
callq 0x2270
movq $0x0, 0x171e7(%rip) # 0x1ef40
movq $0x0, 0x171e4(%rip) # 0x1ef48
movl $0x0, 0x171ca(%rip)     # 0x1ef38
movl -0x3c(%rbp), %eax
movl %eax, 0xdf1d(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7e89
movl $0x1, 0xdf03(%rip)      # 0x15c90
movq $0x0, 0xdfa8(%rip) # 0x15d40
movq $0x0, 0x171ad(%rip) # 0x1ef50
movl $0x0, 0xdf9b(%rip)      # 0x15d48
movl $0x0, 0x17069(%rip)     # 0x1ee20
movq $0x0, 0x17066(%rip) # 0x1ee28
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, 0x17162(%rip)     # 0x1ef30
movq -0x20(%rbp), %rax
movl (%rax), %edi
movq -0x28(%rbp), %rax
movl (%rax), %esi
callq 0x5740
imull $0x3, 0xd94e(%rip), %eax # 0x15734
movl %eax, 0x17044(%rip)     # 0x1ee30
movq -0x38(%rbp), %rdx
movslq 0xd935(%rip), %rcx      # 0x1572c
leaq 0x17052(%rip), %rax     # 0x1ee50
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl 0xd91a(%rip), %eax      # 0x1572c
jge 0x7e45
movq -0x38(%rbp), %rdx
movslq -0x40(%rbp), %rcx
leaq 0x1702d(%rip), %rax     # 0x1ee50
movq %rdx, (%rax,%rcx,8)
movl 0xd907(%rip), %ecx      # 0x15734
movq -0x38(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7e09
callq 0x7f90
movl $0xff, %edi
callq 0x79d0
callq 0x5890
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x7e82
movl 0xde2c(%rip), %eax      # 0x15c94
movl %eax, -0x3c(%rbp)
callq 0x7ea0
movl -0x3c(%rbp), %eax
movl %eax, 0xde1b(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7e89
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)