// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/music.c
// Function: MUSIC_Init
int MUSIC_Init
   (
   int SoundCard,
   const char *params
   )

   {
   int i;
   int status;
   int mincard, maxcard, card;

   for( i = 0; i < 128; i++ )
      {
      MIDI_PatchMap[ i ] = i;
      }

   if (SoundCard == ASS_AutoDetect)
      {
      mincard = ASS_NoSound + 1;
      maxcard = ASS_NumSoundCards - 1;
      }
   else if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards)
      {
      MUSIC_ErrorCode = MUSIC_InvalidCard;
      return MUSIC_Error;
      }
   else
      {
      mincard = SoundCard;
      maxcard = SoundCard;
      }

   for (card = mincard; card <= maxcard; card++)
      {
      if (!SoundDriver_IsMIDISupported(card))
         {
         continue;
         }
      else if (SoundCard == ASS_AutoDetect)
         {
         ASS_Message("MUSIC_Init: trying %s\n", SoundDriver_GetName(card));
         }

      ASS_MIDISoundDriver = card;
      status = SoundDriver_MIDI_Init(&MUSIC_MidiFunctions, params);
      if (status == MUSIC_Ok)
         {
         MIDI_SetMidiFuncs( &MUSIC_MidiFunctions );
         return MUSIC_Ok;
         }
      }

   if (SoundCard == ASS_AutoDetect)
      {
      // A failure to autodetect falls back to no sound.
      ASS_MIDISoundDriver = ASS_NoSound;
      MIDI_SetMidiFuncs( &MUSIC_MidiFunctions );
      return MUSIC_Ok;
      }

   MUSIC_ErrorCode = MUSIC_DriverError;
   return MUSIC_Error;
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jge 0xa5bd
movl -0x14(%rbp), %eax
movb %al, %dl
movslq -0x14(%rbp), %rcx
leaq 0x14b51(%rip), %rax     # 0x1f100
movb %dl, (%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xa596
cmpl $-0x2, -0x8(%rbp)
jne 0xa5d3
movl $0x1, -0x1c(%rbp)
movl $0x6, -0x20(%rbp)
jmp 0xa603
cmpl $0x0, -0x8(%rbp)
jl 0xa5df
cmpl $0x7, -0x8(%rbp)
jl 0xa5f5
movl $0x2, 0x1497f(%rip)     # 0x1ef68
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa6c1
movl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0xa603
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0xa688
movl -0x24(%rbp), %edi
callq 0x2dd0
cmpl $0x0, %eax
jne 0xa620
jmp 0xa67d
cmpl $-0x2, -0x8(%rbp)
jne 0xa63f
movl -0x24(%rbp), %edi
callq 0x2e00
movq %rax, %rsi
leaq 0x51a7(%rip), %rdi      # 0xf7df
movb $0x0, %al
callq 0xd640
jmp 0xa641
movl -0x24(%rbp), %ecx
leaq 0xabbd(%rip), %rax      # 0x15208
movl %ecx, (%rax)
movq -0x10(%rbp), %rsi
leaq 0x14918(%rip), %rdi     # 0x1ef70
callq 0x3380
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0xa67b
leaq 0x14903(%rip), %rdi     # 0x1ef70
callq 0xb190
movl $0x0, -0x4(%rbp)
jmp 0xa6c1
jmp 0xa67d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa609
cmpl $-0x2, -0x8(%rbp)
jne 0xa6b0
leaq 0xab73(%rip), %rax      # 0x15208
movl $0x0, (%rax)
leaq 0x148ce(%rip), %rdi     # 0x1ef70
callq 0xb190
movl $0x0, -0x4(%rbp)
jmp 0xa6c1
movl $0x1, 0x148ae(%rip)     # 0x1ef68
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)