decompiled_code:
__int64 sysdep_mixer_list_plugins()
{
fwrite("Sound mixer plugins:\n\n", 1uLL, 0x16uLL, stdout);
plugin_manager_list_plugins(sysdep_mixer_plugin_manager, stdout);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
fwrite("Sound mixer plugins:\n\n", 1uLL, 0x16uLL, stdout);
plugin_manager_list_plugins(sysdep_mixer_plugin_manager, stdout);
return 0xFFFFFFFFLL;
}

original_code:
static int sysdep_mixer_list_plugins(struct rc_option *option,
   const char *arg, int priority)
{
   fprintf(stdout, "Sound mixer plugins:\n\n");
   plugin_manager_list_plugins(sysdep_mixer_plugin_manager, stdout);
   return -1;
}

canonical_original_code:
static int sysdep_mixer_list_plugins(struct rc_option *option, char *arg, int priority)
{
   fprintf(stdout, "Sound mixer plugins:\n\n");
   plugin_manager_list_plugins(sysdep_mixer_plugin_manager, stdout);
   return -1;
}

variable_types: struct rc_option { char *name; char *shortname; int type; void *dest; char *deflt; float min; float max; int (*func)(struct rc_option *option, char *arg, int priority); char *help; int priority; } *

variable_types:
arg
char *

variable_types: priority int


decompiled_code:
__int64 sysdep_mixer_exit()
{
__int64 result; // rax

if ( sysdep_mixer_plugin_manager )
{
result = plugin_manager_destroy();
sysdep_mixer_plugin_manager = 0LL;
}
if ( sysdep_mixer_rc )
{
result = rc_unregister(sysdep_mixer_rc, &sysdep_mixer_opts);
sysdep_mixer_rc = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

if ( sysdep_mixer_plugin_manager )
{
result = plugin_manager_destroy();
sysdep_mixer_plugin_manager = 0LL;
}
if ( sysdep_mixer_rc )
{
result = rc_unregister(sysdep_mixer_rc, &sysdep_mixer_opts);
sysdep_mixer_rc = 0LL;
}
return result;
}

original_code:
void sysdep_mixer_exit(void)
{
   if(sysdep_mixer_plugin_manager)
   {
      plugin_manager_destroy(sysdep_mixer_plugin_manager);
      sysdep_mixer_plugin_manager = ((void *)0);
   }
   if(sysdep_mixer_rc)
   {
      rc_unregister(sysdep_mixer_rc, sysdep_mixer_opts);
      sysdep_mixer_rc = ((void *)0);
   }
}

canonical_original_code:
void sysdep_mixer_exit()
{
   if(sysdep_mixer_plugin_manager)
   {
      plugin_manager_destroy(sysdep_mixer_plugin_manager);
      sysdep_mixer_plugin_manager = ((void *)0);
   }
   if(sysdep_mixer_rc)
   {
      rc_unregister(sysdep_mixer_rc, sysdep_mixer_opts);
      sysdep_mixer_rc = ((void *)0);
   }
}

return_type: void


decompiled_code:
__int64 __fastcall sysdep_mixer_channel_available(__int64 a1, int a2)
{
return (unsigned int)*(char *)(a2 + a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
return (unsigned int)*(char *)(a2 + a1 + 4);
}

original_code:
int sysdep_mixer_channel_available(struct sysdep_mixer_struct *mixer,
   int channel)
{
   return mixer->channel_available[channel];
}

variable_types: struct sysdep_mixer_struct { int flags; char channel_available[10]; char restore_channel[10]; int cache_left[10]; int cache_right[10]; int orig_left[10]; int orig_right[10]; void *_priv; int (*set)(struct sysdep_mixer_struct *mixer, int channel, int left, int right); int (*get)(struct sysdep_mixer_struct *mixer, int channel, int *left, int *right); void (*destroy)(struct sysdep_mixer_struct *mixer); } *

variable_types: channel int

return_type: int


decompiled_code:
__int64 __fastcall sysdep_mixer_set(int *a1, int a2, int a3, int a4)
{
int v6; // eax
__int64 result; // rax

if ( !*((_BYTE *)a1 + a2 + 4) || (*((unsigned int (**)(void))a1 + 24))() )
return 0xFFFFFFFFLL;
v6 = *a1;
a1[a2 + 6] = a3;
a1[a2 + 16] = a4;
result = v6 & 1;
if ( (_DWORD)result )
{
*((_BYTE *)a1 + a2 + 14) = 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int *a1, int a2, int a3, int a4)
{
int v6; // eax
__int64 result; // rax

if ( !*((_BYTE *)a1 + a2 + 4) || (*((unsigned int (**)(void))a1 + 24))() )
return 0xFFFFFFFFLL;
v6 = *a1;
a1[a2 + 6] = a3;
a1[a2 + 16] = a4;
result = v6 & 1;
if ( (_DWORD)result )
{
*((_BYTE *)a1 + a2 + 14) = 1;
result = 0LL;
}
return result;
}

original_code:
int sysdep_mixer_set(struct sysdep_mixer_struct *mixer, int channel,
   int left, int right)
{
   if(!mixer->channel_available[channel])
      return -1;
   if(mixer->set(mixer, channel, left, right))
      return -1;
   mixer->cache_left[channel] = left;
   mixer->cache_right[channel] = right;
   if(mixer->flags & 0x01)
      mixer->restore_channel[channel] = 1;
   return 0;
}

variable_types: left int

variable_types: right int

user_defined_types: struct sysdep_mixer_struct { int flags; char channel_available[10]; char restore_channel[10]; int cache_left[10]; int cache_right[10]; int orig_left[10]; int orig_right[10]; void *_priv; int (*set)(struct sysdep_mixer_struct *mixer, int channel, int left, int right); int (*get)(struct sysdep_mixer_struct *mixer, int channel, int *left, int *right); void (*destroy)(struct sysdep_mixer_struct *mixer); }


original_code:
int sysdep_mixer_get(struct sysdep_mixer_struct *mixer, int channel,
   int *left, int *right)
{
   if(!mixer->channel_available[channel])
      return -1;
   if(mixer->get(mixer, channel, left, right))
      return -1;
   if((*left >= (mixer->cache_left[channel] - 5)) &&
      (*left <= (mixer->cache_left[channel] + 5)) &&
      (*right >= (mixer->cache_right[channel] - 5)) &&
      (*right <= (mixer->cache_right[channel] + 5)))
   {
      *left = mixer->cache_left[channel];
      *right = mixer->cache_right[channel];
   }
   else
   {
      mixer->restore_channel[channel] = 0;
      mixer->cache_left[channel] = *left;
      mixer->cache_right[channel] = *right;
      mixer->orig_left[channel] = *left;
      mixer->orig_right[channel] = *right;
   }
   return 0;
}

variable_types:
left
int *

variable_types:
right
int *


original_code:
void sysdep_mixer_destroy(struct sysdep_mixer_struct *mixer)
{
   int i, left, right;
   for(i = 0; i < 10; i++)
   {
      sysdep_mixer_get(mixer, i, &left, &right);
      if(mixer->restore_channel[i])
      {
         sysdep_mixer_set(mixer, i, mixer->orig_left[i],
            mixer->orig_right[i]);
      }
   }
   mixer->destroy(mixer);
}

canonical_original_code:
void sysdep_mixer_destroy(struct sysdep_mixer_struct *mixer)
{
   int i; int left; int right;
   for(i = 0; i < 10; i++)
   {
      sysdep_mixer_get(mixer, i, &left, &right);
      if(mixer->restore_channel[i])
      {
         sysdep_mixer_set(mixer, i, mixer->orig_left[i],
            mixer->orig_right[i]);
      }
   }
   mixer->destroy(mixer);
}

variable_types: i int


decompiled_code:
__int64 __fastcall sysdep_mixer_create(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // r8
__int64 v5; // rax
__int64 v6; // r12
_DWORD *v7; // rbx
__int64 v8; // rbp
__int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

v3 = a1;
if ( !a1 )
v3 = sysdep_mixer_plugin;
v10[0] = a2;
v5 = plugin_manager_create_instance(sysdep_mixer_plugin_manager, v3, v10);
v6 = v5;
if ( !v5 )
return v6;
v7 = (_DWORD *)(v5 + 24);
v8 = 0LL;
while ( !*(_BYTE *)(v6 + v8 + 4) )
{
LABEL_8:
++v8;
++v7;
if ( v8 == 10 )
{
*(_DWORD *)v6 = a3;
return v6;
}
}
if ( !(*(unsigned int (__fastcall **)(__int64, _QWORD, _DWORD *, _DWORD *))(v6 + 200))(
v6,
(unsigned int)v8,
v7,
v7 + 10) )
{
v7[20] = *v7;
v7[30] = v7[10];
goto LABEL_8;
}
sysdep_mixer_destroy(v6);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // r8
__int64 v5; // rax
__int64 v6; // r12
_DWORD *v7; // rbx
__int64 v8; // rbp
__int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

v3 = a1;
if ( !a1 )
v3 = sysdep_mixer_plugin;
v10[0] = a2;
v5 = plugin_manager_create_instance(sysdep_mixer_plugin_manager, v3, v10);
v6 = v5;
if ( !v5 )
return v6;
v7 = (_DWORD *)(v5 + 24);
v8 = 0LL;
while ( !*(_BYTE *)(v6 + v8 + 4) )
{
LABEL_8:
++v8;
++v7;
if ( v8 == 10 )
{
*(_DWORD *)v6 = a3;
return v6;
}
}
if ( !(*(unsigned int (__fastcall **)(__int64, _QWORD, _DWORD *, _DWORD *))(v6 + 200))(
v6,
(unsigned int)v8,
v7,
v7 + 10) )
{
v7[20] = *v7;
v7[30] = v7[10];
goto LABEL_8;
}
func6(v6);
return 0LL;
}

original_code:
struct sysdep_mixer_struct *sysdep_mixer_create(const char *plugin,
   const char *device, int flags)
{
   int i;
   struct sysdep_mixer_struct *mixer = ((void *)0);
   struct sysdep_mixer_create_params params;
   params.device = device;
   if(!(mixer = plugin_manager_create_instance(sysdep_mixer_plugin_manager,
      plugin? plugin:sysdep_mixer_plugin, &params)))
      return ((void *)0);
   for(i = 0; i < 10; i++)
   {
      if(mixer->channel_available[i])
      {
         if(mixer->get(mixer, i, &mixer->cache_left[i],
            &mixer->cache_right[i]))
         {
            sysdep_mixer_destroy(mixer);
            return ((void *)0);
         }
         mixer->orig_left[i] = mixer->cache_left[i];
         mixer->orig_right[i] = mixer->cache_right[i];
      }
   }
   mixer->flags = flags;
   return mixer;
}

canonical_original_code:
struct sysdep_mixer_struct *sysdep_mixer_create(char *plugin, char *device, int flags)
{
   int i;
   struct sysdep_mixer_struct *mixer = ((void *)0);
   struct sysdep_mixer_create_params params;
   params.device = device;
   if(!(mixer = plugin_manager_create_instance(sysdep_mixer_plugin_manager,
      plugin? plugin:sysdep_mixer_plugin, &params)))
      return ((void *)0);
   for(i = 0; i < 10; i++)
   {
      if(mixer->channel_available[i])
      {
         if(mixer->get(mixer, i, &mixer->cache_left[i],
            &mixer->cache_right[i]))
         {
            sysdep_mixer_destroy(mixer);
            return ((void *)0);
         }
         mixer->orig_left[i] = mixer->cache_left[i];
         mixer->orig_right[i] = mixer->cache_right[i];
      }
   }
   mixer->flags = flags;
   return mixer;
}

variable_types:
plugin
char *

variable_types:
device
char *

variable_types: flags int

variable_types: struct sysdep_mixer_create_params { char *device; }

return_type: struct sysdep_mixer_struct { int flags; char channel_available[10]; char restore_channel[10]; int cache_left[10]; int cache_right[10]; int orig_left[10]; int orig_right[10]; void *_priv; int (*set)(struct sysdep_mixer_struct *mixer, int channel, int left, int right); int (*get)(struct sysdep_mixer_struct *mixer, int channel, int *left, int *right); void (*destroy)(struct sysdep_mixer_struct *mixer); } *


decompiled_code:
__int64 __fastcall sample_buf_fifo_get(__int64 a1, _QWORD *a2)
{
int v2; // ecx
int v3; // eax
int v4; // edx
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 4) + 1;
*a2 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * *(int *)(a1 + 4));
v4 = v3 % *(_DWORD *)a1;
*(_DWORD *)(a1 + 8) = v2 - 1;
result = 0LL;
*(_DWORD *)(a1 + 4) = v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2)
{
int v2; // ecx
int v3; // eax
int v4; // edx
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 8);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 4) + 1;
*a2 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * *(int *)(a1 + 4));
v4 = v3 % *(_DWORD *)a1;
*(_DWORD *)(a1 + 8) = v2 - 1;
result = 0LL;
*(_DWORD *)(a1 + 4) = v4;
return result;
}

original_code: static __inline__ int sample_buf_fifo_get(struct sample_buf_fifo_struct *fifo, struct sound_stream_sample_buf * *data) { if(!fifo->in_use) return -1; *data = fifo->buffer[fifo->head]; fifo->head = (fifo->head + 1) % fifo->size; fifo->in_use--; return 0; }

canonical_original_code: static __inline__ int sample_buf_fifo_get(struct sample_buf_fifo_struct *fifo, struct sound_stream_sample_buf **data) { if(!fifo->in_use) return -1; *data = fifo->buffer[fifo->head]; fifo->head = (fifo->head + 1) % fifo->size; fifo->in_use--; return 0; }

variable_types: struct sample_buf_fifo_struct { int size; int head; int in_use; struct sound_stream_sample_buf { int length; int pos; unsigned char *data; } **buffer; } *

variable_types:
data
struct sound_stream_sample_buf **

user_defined_types: struct sample_buf_fifo_struct { int size; int head; int in_use; struct sound_stream_sample_buf **buffer; }


decompiled_code:
__int64 __fastcall sample_buf_fifo_peek(__int64 a1, _QWORD *a2)
{
if ( !*(_DWORD *)(a1 + 8) )
return 0xFFFFFFFFLL;
*a2 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * *(int *)(a1 + 4));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
if ( !*(_DWORD *)(a1 + 8) )
return 0xFFFFFFFFLL;
*a2 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * *(int *)(a1 + 4));
return 0LL;
}

original_code: static __inline__ int sample_buf_fifo_peek(struct sample_buf_fifo_struct *fifo, struct sound_stream_sample_buf * *data) { if(!fifo->in_use) return -1; *data = fifo->buffer[fifo->head]; return 0; }

canonical_original_code: static __inline__ int sample_buf_fifo_peek(struct sample_buf_fifo_struct *fifo, struct sound_stream_sample_buf **data) { if(!fifo->in_use) return -1; *data = fifo->buffer[fifo->head]; return 0; }

user_defined_types: struct sound_stream_sample_buf { int length; int pos; unsigned char *data; }


decompiled_code:
void __fastcall sample_buf_fifo_destroy(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
free(ptr);
}

original_code: static __inline__ void sample_buf_fifo_destroy(struct sample_buf_fifo_struct *fifo) { if(fifo->buffer) free(fifo->buffer); free(fifo); }


decompiled_code:
__int64 __fastcall oss_dsp_get_freespace(__int64 a1)
{
_DWORD v2[6]; // [rsp+0h] [rbp-18h] BYREF

if ( ioctl(**(_DWORD **)(a1 + 40), 0x8010500CuLL, v2) >= 0 )
return (unsigned int)(v2[3] / oss_dsp_bytes_per_sample[*(int *)(a1 + 4)]);
perror("error: SNDCTL_DSP_GETOSPACE");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_DWORD v2[6]; // [rsp+0h] [rbp-18h] BYREF

if ( ioctl(**(_DWORD **)(a1 + 40), 0x8010500CuLL, v2) >= 0 )
return (unsigned int)(v2[3] / oss_dsp_bytes_per_sample[*(int *)(a1 + 4)]);
perror("error: SNDCTL_DSP_GETOSPACE");
return 0xFFFFFFFFLL;
}

original_code:
static int oss_dsp_get_freespace(struct sysdep_dsp_struct *dsp)
{
   audio_buf_info info;
   struct oss_dsp_priv_data *priv = dsp->_priv;
   if (ioctl(priv->fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((12)) << 0) | ((((sizeof(audio_buf_info)))) << ((0 +8)+8))), &info) < 0)
   {
      perror("error: SNDCTL_DSP_GETOSPACE");
      return -1;
   }
   return info.bytes / oss_dsp_bytes_per_sample[dsp->hw_info.type];
}

canonical_original_code:
static int oss_dsp_get_freespace(struct sysdep_dsp_struct *dsp)
{
   struct audio_buf_info info;
   struct oss_dsp_priv_data *priv = dsp->_priv;
   if (ioctl(priv->fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((12)) << 0) | ((((sizeof(audio_buf_info)))) << ((0 +8)+8))), &info) < 0)
   {
      perror("error: SNDCTL_DSP_GETOSPACE");
      return -1;
   }
   return info.bytes / oss_dsp_bytes_per_sample[dsp->hw_info.type];
}

variable_types: struct sysdep_dsp_struct { struct sysdep_dsp_info { int samplerate; int type; int bufsize; } hw_info; struct sysdep_dsp_info emu_info; unsigned char *convert_buf; long last_update; void *_priv; int (*get_freespace)(struct sysdep_dsp_struct *dsp); int (*write)(struct sysdep_dsp_struct *dsp, unsigned char *data, int count); void (*destroy)(struct sysdep_dsp_struct *dsp); } *

variable_types: struct audio_buf_info { int fragments; int fragstotal; int fragsize; int bytes; }

variable_types:
priv
struct oss_dsp_priv_data { int fd; } *

user_defined_types: struct sysdep_dsp_struct { struct sysdep_dsp_info hw_info; struct sysdep_dsp_info emu_info; unsigned char *convert_buf; long last_update; void *_priv; int (*get_freespace)(struct sysdep_dsp_struct *dsp); int (*write)(struct sysdep_dsp_struct *dsp, unsigned char *data, int count); void (*destroy)(struct sysdep_dsp_struct *dsp); }


decompiled_code:
__int64 __fastcall oss_dsp_write(__int64 a1, const void *a2, int a3)
{
int v3; // eax
__int64 result; // rax

v3 = write(**(_DWORD **)(a1 + 40), a2, oss_dsp_bytes_per_sample[*(int *)(a1 + 4)] * a3);
if ( v3 < 0 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(v3 / oss_dsp_bytes_per_sample[*(int *)(a1 + 4)]);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const void *a2, int a3)
{
int v3; // eax
__int64 result; // rax

v3 = write(**(_DWORD **)(a1 + 40), a2, oss_dsp_bytes_per_sample[*(int *)(a1 + 4)] * a3);
if ( v3 < 0 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(v3 / oss_dsp_bytes_per_sample[*(int *)(a1 + 4)]);
return result;
}

original_code:
static int oss_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data,
   int count)
{
   int result;
   struct oss_dsp_priv_data *priv = dsp->_priv;
   result = write(priv->fd, data, count *
      oss_dsp_bytes_per_sample[dsp->hw_info.type]);
   if (result < 0)
      return -1;
   return result / oss_dsp_bytes_per_sample[dsp->hw_info.type];
}

variable_types:
data
unsigned char *

variable_types: count int

variable_types: result int

user_defined_types: struct sysdep_dsp_info { int samplerate; int type; int bufsize; }


decompiled_code:
void __fastcall oss_dsp_destroy(void *ptr)
{
int *v1; // r12

v1 = (int *)*((_QWORD *)ptr + 5);
if ( v1 )
{
if ( *v1 >= 0 )
close(*v1);
free(v1);
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
int *v1; // r12

v1 = (int *)*((_QWORD *)ptr + 5);
if ( v1 )
{
if ( *v1 >= 0 )
close(*v1);
free(v1);
}
free(ptr);
}

original_code:
static void oss_dsp_destroy(struct sysdep_dsp_struct *dsp)
{
   struct oss_dsp_priv_data *priv = dsp->_priv;
   if (priv)
   {
      if (priv->fd >= 0)
         close(priv->fd);
      free(priv);
   }
   free(dsp);
}


decompiled_code:
__int64 the_end()
{
xmame_system_term();
return x11_system_term();
}

canonical_decompiled_code:
__int64 func0()
{
xmame_system_term();
return x11_system_term();
}

original_code:
static void the_end( void )
{
  xmame_system_term();
  x11_system_term();
}

canonical_original_code:
static void the_end()
{
  xmame_system_term();
  x11_system_term();
}


decompiled_code:
__int64 stateload_system()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
int stateload_system( void )
{
  return (1);
}

canonical_original_code:
int stateload_system()
{
  return (1);
}


decompiled_code:
// attributes: thunk
__int64 statesave_system()
{
return stateload_system();
}

canonical_decompiled_code:
__int64 func2()
{
return func1();
}

original_code:
int statesave_system( void )
{
  return (1);
}

canonical_original_code:
int statesave_system()
{
  return (1);
}


decompiled_code:
__int64 __fastcall about_msg_init(int a1)
{
about_line = 0;
about_lang = a1 != 0;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
about_line = 0;
about_lang = a1 != 0;
return 0xFFFFFFFFLL;
}

original_code:
int about_msg_init( int japanese )
{
  about_lang = ( japanese ) ? 1 : 0;
  about_line = 0;
  return -1;
}

canonical_original_code:
int about_msg_init(int japanese)
{
  about_lang = ( japanese ) ? 1 : 0;
  about_line = 0;
  return -1;
}

variable_types: japanese int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__uid_t v3; // eax
int v4; // er12

x11_system_init(argc, argv, envp);
v3 = getuid();
if ( setuid(v3) )
{
v4 = -1;
fprintf(stderr, "%s : setuid error\n", *argv);
x11_system_term();
}
else
{
v4 = 0;
if ( !getuid() )
snapshot_cmd_enable = 0;
xmame_system_init();
quasi88_atexit(the_end);
if ( (unsigned int)osd_environment() && (unsigned int)config_init((unsigned int)argc, argv) )
quasi88();
xmame_system_term();
x11_system_term();
}
return v4;
}

original_code:
int main( int argc, char *argv[] )
{
  int x = 1;
  x11_system_init();
  if( setuid( getuid() ) != 0 ){
    fprintf( stderr, "%s : setuid error\n", argv[0] );
    x11_system_term();
    return -1;
  }
  if( getuid() == 0 ) snapshot_cmd_enable = (0);
  if( *(char *)&x != 1 ){
    fprintf( stderr,
      "%s CAN'T EXCUTE !\n"
      "This machine is Big-Endian.\n"
      "Compile again comment-out 'LSB_FIRST = 1' in Makefile.\n",
      argv[0] );
    x11_system_term();
    return -1;
  }
  xmame_system_init();
  quasi88_atexit( the_end );
  if( osd_environment() ){
    if( config_init( argc, argv ) ){
      quasi88();
    }
  }
  xmame_system_term();
  x11_system_term();
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  int x = 1;
  x11_system_init();
  if( setuid( getuid() ) != 0 ){
    fprintf( stderr, "%s : setuid error\n", argv[0] );
    x11_system_term();
    return -1;
  }
  if( getuid() == 0 ) snapshot_cmd_enable = (0);
  if( *(char *)&x != 1 ){
    fprintf( stderr,
      "%s CAN'T EXCUTE !\n"
      "This machine is Big-Endian.\n"
      "Compile again comment-out 'LSB_FIRST = 1' in Makefile.\n",
      argv[0] );
    x11_system_term();
    return -1;
  }
  xmame_system_init();
  quasi88_atexit( the_end );
  if( osd_environment() ){
    if( config_init( argc, argv ) ){
      quasi88();
    }
  }
  xmame_system_term();
  x11_system_term();
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: x int


decompiled_code:
_BOOL8 xmame_system_init()
{
__int64 v0; // rax
_BOOL8 result; // rax

v0 = rc_create();
rc = v0;
if ( !v0 || (unsigned int)sysdep_dsp_init(v0, 0LL) || (unsigned int)sysdep_mixer_init(rc, 0LL) )
result = 1LL;
else
result = (unsigned int)rc_register(rc, &sound_opts) != 0;
return result;
}

canonical_decompiled_code:
_BOOL8 func0()
{
__int64 v0; // rax
_BOOL8 result; // rax

v0 = rc_create();
rc = v0;
if ( !v0 || (unsigned int)sysdep_dsp_init(v0, 0LL) || (unsigned int)sysdep_mixer_init(rc, 0LL) )
result = 1LL;
else
result = (unsigned int)rc_register(rc, &sound_opts) != 0;
return result;
}

original_code:
int xmame_system_init( void )
{
   if (!(rc = rc_create()))
      return (1);
   if(sysdep_dsp_init(rc, ((void *)0)))
      return (1);
   if(sysdep_mixer_init(rc, ((void *)0)))
      return (1);
   if(rc_register(rc, sound_opts))
      return (1);
   return (0);
}

canonical_original_code:
int xmame_system_init()
{
   if (!(rc = rc_create()))
      return (1);
   if(sysdep_dsp_init(rc, ((void *)0)))
      return (1);
   if(sysdep_mixer_init(rc, ((void *)0)))
      return (1);
   if(rc_register(rc, sound_opts))
      return (1);
   return (0);
}


decompiled_code:
__int64 xmame_system_term()
{
__int64 result; // rax

if ( rc )
{
sysdep_mixer_exit();
sysdep_dsp_exit();
result = rc_destroy(rc);
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

if ( rc )
{
sysdep_mixer_exit();
sysdep_dsp_exit();
result = rc_destroy(rc);
}
return result;
}

original_code:
void xmame_system_term( void )
{
   if(rc)
   {
      sysdep_mixer_exit();
      sysdep_dsp_exit();
      rc_destroy(rc);
   }
}

canonical_original_code:
void xmame_system_term()
{
   if(rc)
   {
      sysdep_mixer_exit();
      sysdep_dsp_exit();
      rc_destroy(rc);
   }
}


decompiled_code:
__int64 __fastcall xmame_check_option(__int64 a1, __int64 a2, unsigned int a3)
{
return rc_quasi88(rc, a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3)
{
return rc_quasi88(rc, a1, a2, a3);
}

original_code:
int xmame_check_option( char *arg1, char *arg2, int priority )
{
  return rc_quasi88( rc, arg1, arg2, priority );
}

canonical_original_code:
int xmame_check_option(char *arg1, char *arg2, int priority)
{
  return rc_quasi88( rc, arg1, arg2, priority );
}

variable_types: priority int


decompiled_code:
__int64 xmame_sound_start()
{
void *v0; // rax

if ( verbose_proc )
printf("Starting sound server: .....");
if ( !(unsigned int)sound_start() )
{
v0 = &xmame_func_sound;
if ( !use_sound )
v0 = &xmame_func_nosound;
xmame_func = v0;
if ( verbose_proc )
puts("...OK");
sound_reset();
return 1LL;
}
if ( !verbose_proc )
return 1LL;
puts("...FAILED, Can't use sound");
return 1LL;
}

canonical_decompiled_code:
__int64 func4()
{
void *v0; // rax

if ( verbose_proc )
printf("Starting sound server: .....");
if ( !(unsigned int)sound_start() )
{
v0 = &xmame_func_sound;
if ( !use_sound )
v0 = &xmame_func_nosound;
xmame_func = v0;
if ( verbose_proc )
puts("...OK");
sound_reset();
return 1LL;
}
if ( !verbose_proc )
return 1LL;
puts("...FAILED, Can't use sound");
return 1LL;
}

original_code:
int xmame_sound_start( void )
{
  if(verbose_proc) printf("Starting sound server: .....");
  if( sound_start()==0 ){
    do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
    if(verbose_proc) printf("...OK\n");
    sound_reset();
  }else{
    if(verbose_proc) printf("...FAILED, Can't use sound\n");
  }
  return 1;
}

canonical_original_code:
int xmame_sound_start()
{
  if(verbose_proc) printf("Starting sound server: .....");
  if( sound_start()==0 ){
    do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
    if(verbose_proc) printf("...OK\n");
    sound_reset();
  }else{
    if(verbose_proc) printf("...FAILED, Can't use sound\n");
  }
  return 1;
}


decompiled_code:
// attributes: thunk
__int64 xmame_sound_update()
{
return sound_update();
}

canonical_decompiled_code:
__int64 func5()
{
return sound_update();
}

original_code:
void xmame_sound_update( void )
{
  sound_update();
}

canonical_original_code:
void xmame_sound_update()
{
  sound_update();
}


decompiled_code:
// attributes: thunk
__int64 xmame_sound_stop()
{
return sound_stop();
}

canonical_decompiled_code:
__int64 func6()
{
return sound_stop();
}

original_code:
void xmame_sound_stop( void )
{
  sound_stop();
}

canonical_original_code:
void xmame_sound_stop()
{
  sound_stop();
}


decompiled_code:
__int64 xmame_sound_suspend()
{
__int64 result; // rax

result = close_device;
if ( close_device )
result = osd_sound_enable(0LL);
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax

result = close_device;
if ( close_device )
result = osd_sound_enable(0LL);
return result;
}

original_code:
void xmame_sound_suspend( void )
{
  if( close_device )
    osd_sound_enable(0);
}

canonical_original_code:
void xmame_sound_suspend()
{
  if( close_device )
    osd_sound_enable(0);
}


decompiled_code:
__int64 xmame_sound_resume()
{
__int64 result; // rax

result = close_device;
if ( close_device )
result = osd_sound_enable(1LL);
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax

result = close_device;
if ( close_device )
result = osd_sound_enable(1LL);
return result;
}

original_code:
void xmame_sound_resume( void )
{
  if( close_device )
    osd_sound_enable(1);
}

canonical_original_code:
void xmame_sound_resume()
{
  if( close_device )
    osd_sound_enable(1);
}


decompiled_code:
// attributes: thunk
__int64 xmame_sound_reset()
{
return sound_reset();
}

canonical_decompiled_code:
__int64 func9()
{
return sound_reset();
}

original_code:
void xmame_sound_reset( void )
{
  sound_reset();
}

canonical_original_code:
void xmame_sound_reset()
{
  sound_reset();
}


decompiled_code:
_BOOL8 xmame_sound_is_enable()
{
return sound_stream != 0;
}

canonical_decompiled_code:
_BOOL8 func10()
{
return sound_stream != 0;
}

original_code:
int xmame_sound_is_enable( void )
{
  if( sound_stream ) return (1);
  else return (0);
}

canonical_original_code:
int xmame_sound_is_enable()
{
  if( sound_stream ) return (1);
  else return (0);
}


decompiled_code:
_BOOL8 xmame_volume_is_variable()
{
return (unsigned int)osd_has_sound_mixer() != 0;
}

canonical_decompiled_code:
_BOOL8 func11()
{
return (unsigned int)osd_has_sound_mixer() != 0;
}

original_code:
int xmame_volume_is_variable( void )
{
  if( osd_has_sound_mixer() ) return (1);
  else return (0);
}

canonical_original_code:
int xmame_volume_is_variable()
{
  if( osd_has_sound_mixer() ) return (1);
  else return (0);
}


decompiled_code:
__int64 xmame_update_video_and_audio()
{
__int64 result; // rax

if ( sound_stream )
{
result = (unsigned int)use_sound;
if ( use_sound )
result = sound_stream_update();
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 result; // rax

if ( sound_stream )
{
result = (unsigned int)use_sound;
if ( use_sound )
result = sound_stream_update();
}
return result;
}

original_code:
void xmame_update_video_and_audio( void )
{
   if (sound_stream && use_sound)
      sound_stream_update(sound_stream);
}

canonical_original_code:
void xmame_update_video_and_audio()
{
   if (sound_stream && use_sound)
      sound_stream_update(sound_stream);
}


decompiled_code:
__int64 xmame_sound_in_data()
{
__int64 (__fastcall *v0)(_QWORD); // rax
__int64 result; // rax

v0 = (__int64 (__fastcall *)(_QWORD))*((_QWORD *)xmame_func + 1);
if ( v0 )
result = v0(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 (__fastcall *v0)(_QWORD); // rax
__int64 result; // rax

v0 = (__int64 (__fastcall *)(_QWORD))*((_QWORD *)xmame_func + 1);
if ( v0 )
result = v0(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
byte xmame_sound_in_data( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_data)(0);
  else return 0xff;
}

canonical_original_code:
unsigned char xmame_sound_in_data()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_data)(0);
  else return 0xff;
}

return_type: unsigned char


decompiled_code:
__int64 xmame_sound_in_status()
{
__int64 result; // rax

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 2))(0LL);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 2))(0LL);
else
result = 0LL;
return result;
}

original_code:
byte xmame_sound_in_status( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_status)(0);
  else return 0;
}

canonical_original_code:
unsigned char xmame_sound_in_status()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_status)(0);
  else return 0;
}


decompiled_code:
void *__fastcall xmame_sound_out_reg(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 3))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func15(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 3))(0LL, a1);
return result;
}

original_code:
void xmame_sound_out_reg( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_reg)(0,data);
}

canonical_original_code:
void xmame_sound_out_reg(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_reg)(0,data);
}

variable_types:
data
unsigned char


decompiled_code:
void *__fastcall xmame_sound_out_data(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 4))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func16(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 4))(0LL, a1);
return result;
}

original_code:
void xmame_sound_out_data( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_data)(0,data);
}

canonical_original_code:
void xmame_sound_out_data(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_data)(0,data);
}


decompiled_code:
__int64 xmame_sound2_in_data()
{
__int64 result; // rax
int v1; // eax

result = 0xFFFFFFFFLL;
if ( use_sound )
{
v1 = sound_board;
LOBYTE(v1) = sound_board == 0;
result = (unsigned int)-v1;
}
return result;
}

canonical_decompiled_code:
__int64 func17()
{
__int64 result; // rax
int v1; // eax

result = 0xFFFFFFFFLL;
if ( use_sound )
{
v1 = sound_board;
LOBYTE(v1) = sound_board == 0;
result = (unsigned int)-v1;
}
return result;
}

original_code:
byte xmame_sound2_in_data( void )
{
  if( !use_sound ) return 0xff;
  else{
    if( sound_board==SOUND_I ) return 0xff;
    else return 0;
  }
}

canonical_original_code:
unsigned char xmame_sound2_in_data()
{
  if( !use_sound ) return 0xff;
  else{
    if( sound_board==SOUND_I ) return 0xff;
    else return 0;
  }
}


decompiled_code:
__int64 xmame_sound2_in_status()
{
__int64 result; // rax

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 6))(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func18()
{
__int64 result; // rax

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 6))(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
byte xmame_sound2_in_status( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound2_in_status)(0);
  else return 0xff;
}

canonical_original_code:
unsigned char xmame_sound2_in_status()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound2_in_status)(0);
  else return 0xff;
}


decompiled_code:
void *__fastcall xmame_sound2_out_reg(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 7))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func19(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 7))(0LL, a1);
return result;
}

original_code:
void xmame_sound2_out_reg( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_reg)(0,data);
}

canonical_original_code:
void xmame_sound2_out_reg(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_reg)(0,data);
}


decompiled_code:
void *__fastcall xmame_sound2_out_data(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 8))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func20(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 8))(0LL, a1);
return result;
}

original_code:
void xmame_sound2_out_data( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_data)(0,data);
}

canonical_original_code:
void xmame_sound2_out_data(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_data)(0,data);
}


decompiled_code:
// attributes: thunk
__int64 xmame_get_sound_volume()
{
return osd_get_mastervolume();
}

canonical_decompiled_code:
__int64 func21()
{
return osd_get_mastervolume();
}

original_code:
int xmame_get_sound_volume( void )
{
  return osd_get_mastervolume();
}

canonical_original_code:
int xmame_get_sound_volume()
{
  return osd_get_mastervolume();
}


decompiled_code:
__int64 __fastcall xmame_set_sound_volume(__int64 a1)
{
if ( (int)a1 < -32 )
a1 = 4294967264LL;
if ( (int)a1 > 0 )
a1 = 0LL;
return osd_set_mastervolume(a1);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
if ( (int)a1 < -32 )
a1 = 4294967264LL;
if ( (int)a1 > 0 )
a1 = 0LL;
return osd_set_mastervolume(a1);
}

original_code:
void xmame_set_sound_volume( int vol )
{
    if( vol > (0) ) vol = (0);
    if( vol < (-32) ) vol = (-32);
    osd_set_mastervolume( vol );
}

canonical_original_code:
void xmame_set_sound_volume(int vol)
{
    if( vol > (0) ) vol = (0);
    if( vol < (-32) ) vol = (-32);
    osd_set_mastervolume( vol );
}

variable_types: vol int


decompiled_code:
__int64 __fastcall xmame_get_mixer_volume(__int64 a1)
{
__int64 result; // rax

if ( use_fmgen )
{
if ( (_DWORD)a1 != 2 )
{
if ( (_DWORD)a1 != 5 )
return 0LL;
a1 = 0LL;
}
return mixer_get_mixing_level(a1);
}
result = sound_board;
if ( sound_board )
{
switch ( (int)a1 )
{
case 0:
return mixer_get_mixing_level(a1);
case 1:
return mixer_get_mixing_level(3LL);
case 2:
return mixer_get_mixing_level(5LL);
case 3:
return rhythmvol;
case 4:
return adpcmvol;
default:
JUMPOUT(0x83BLL);
}
}
switch ( (_DWORD)a1 )
{
case 1:
return mixer_get_mixing_level(3LL);
case 2:
return mixer_get_mixing_level(4LL);
case 0:
return mixer_get_mixing_level(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
__int64 result; // rax

if ( use_fmgen )
{
if ( (_DWORD)a1 != 2 )
{
if ( (_DWORD)a1 != 5 )
return 0LL;
a1 = 0LL;
}
return mixer_get_mixing_level(a1);
}
result = sound_board;
if ( sound_board )
{
switch ( (int)a1 )
{
case 0:
return mixer_get_mixing_level(a1);
case 1:
return mixer_get_mixing_level(3LL);
case 2:
return mixer_get_mixing_level(5LL);
case 3:
return rhythmvol;
case 4:
return adpcmvol;
default:
JUMPOUT(0x83BLL);
}
}
switch ( (_DWORD)a1 )
{
case 1:
return mixer_get_mixing_level(3LL);
case 2:
return mixer_get_mixing_level(4LL);
case 0:
return mixer_get_mixing_level(a1);
}
return result;
}

original_code:
int xmame_get_mixer_volume( int ch )
{
  if( use_fmgen==0 ){
    if( sound_board==SOUND_I ){
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 4; break;
      case XMAME_MIXER_RHYTHM: return 0;
      case XMAME_MIXER_ADPCM: return 0;
      default: return 0;
      }
    }else{
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 5; break;
      case XMAME_MIXER_RHYTHM: return rhythmvol;
      case XMAME_MIXER_ADPCM: return adpcmvol;
      default: return 0;
      }
    }
  }else{
    switch( ch ){
    case XMAME_MIXER_FMPSG: ch = 0; break;
    case XMAME_MIXER_BEEP: ch = 2; break;
    default: return 0;
    }
  }
  return mixer_get_mixing_level( ch );
}

canonical_original_code:
int xmame_get_mixer_volume(int ch)
{
  if( use_fmgen==0 ){
    if( sound_board==SOUND_I ){
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 4; break;
      case XMAME_MIXER_RHYTHM: return 0;
      case XMAME_MIXER_ADPCM: return 0;
      default: return 0;
      }
    }else{
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 5; break;
      case XMAME_MIXER_RHYTHM: return rhythmvol;
      case XMAME_MIXER_ADPCM: return adpcmvol;
      default: return 0;
      }
    }
  }else{
    switch( ch ){
    case XMAME_MIXER_FMPSG: ch = 0; break;
    case XMAME_MIXER_BEEP: ch = 2; break;
    default: return 0;
    }
  }
  return mixer_get_mixing_level( ch );
}

variable_types: ch int


decompiled_code:
void __fastcall xmame_set_mixer_volume(int a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // r12
unsigned int v4; // eax
unsigned int i; // ebx
const char *v6; // r12
unsigned int v7; // eax
unsigned int v8; // er12
unsigned int v9; // er12
__int64 v10; // rdi
unsigned int v11; // er12

v2 = use_fmgen;
if ( use_fmgen )
{
if ( a1 == 2 )
{
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
LABEL_30:
mixer_set_mixing_level(2LL, a2);
}
else if ( a1 == 5 )
{
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v8 = 0;
if ( (int)a2 >= 0 )
v8 = a2;
mixer_set_mixing_level(0LL, v8);
mixer_set_mixing_level(1LL, v8);
}
else
{
for ( i = 0; i != 16; ++i )
{
v6 = (const char *)mixer_get_name(i);
if ( v6 )
{
v7 = mixer_get_mixing_level(i);
printf("%d[ch] %s\t:%d\n", i, v6, v7);
}
}
}
}
else
{
switch ( a1 )
{
case 0:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v9 = 0;
if ( (int)a2 >= 0 )
v9 = a2;
mixer_set_mixing_level(0LL, v9);
mixer_set_mixing_level(1LL, v9);
a2 = v9;
goto LABEL_30;
case 1:
v10 = 3LL;
v11 = 0;
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
if ( (int)a2 >= 0 )
v11 = a2;
a2 = v11;
if ( !sound_board )
goto LABEL_50;
mixer_set_mixing_level(3LL, v11);
a2 = v11;
LABEL_43:
mixer_set_mixing_level(4LL, a2);
break;
case 2:
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
if ( !sound_board )
goto LABEL_43;
v10 = 5LL;
LABEL_50:
mixer_set_mixing_level(v10, a2);
break;
case 3:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
rhythmvol = a2;
}
return;
case 4:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
adpcmvol = a2;
}
return;
default:
do
{
v3 = (const char *)mixer_get_name(v2);
if ( v3 )
{
v4 = mixer_get_mixing_level(v2);
printf("%d[ch] %s\t:%d\n", v2, v3, v4);
}
++v2;
}
while ( v2 != 16 );
return;
}
}
}

canonical_decompiled_code:
void __fastcall func24(int a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // r12
unsigned int v4; // eax
unsigned int i; // ebx
const char *v6; // r12
unsigned int v7; // eax
unsigned int v8; // er12
unsigned int v9; // er12
__int64 v10; // rdi
unsigned int v11; // er12

v2 = use_fmgen;
if ( use_fmgen )
{
if ( a1 == 2 )
{
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
LABEL_30:
mixer_set_mixing_level(2LL, a2);
}
else if ( a1 == 5 )
{
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v8 = 0;
if ( (int)a2 >= 0 )
v8 = a2;
mixer_set_mixing_level(0LL, v8);
mixer_set_mixing_level(1LL, v8);
}
else
{
for ( i = 0; i != 16; ++i )
{
v6 = (const char *)mixer_get_name(i);
if ( v6 )
{
v7 = mixer_get_mixing_level(i);
printf("%d[ch] %s\t:%d\n", i, v6, v7);
}
}
}
}
else
{
switch ( a1 )
{
case 0:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v9 = 0;
if ( (int)a2 >= 0 )
v9 = a2;
mixer_set_mixing_level(0LL, v9);
mixer_set_mixing_level(1LL, v9);
a2 = v9;
goto LABEL_30;
case 1:
v10 = 3LL;
v11 = 0;
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
if ( (int)a2 >= 0 )
v11 = a2;
a2 = v11;
if ( !sound_board )
goto LABEL_50;
mixer_set_mixing_level(3LL, v11);
a2 = v11;
LABEL_43:
mixer_set_mixing_level(4LL, a2);
break;
case 2:
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
if ( !sound_board )
goto LABEL_43;
v10 = 5LL;
LABEL_50:
mixer_set_mixing_level(v10, a2);
break;
case 3:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
rhythmvol = a2;
}
return;
case 4:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
adpcmvol = a2;
}
return;
default:
do
{
v3 = (const char *)mixer_get_name(v2);
if ( v3 )
{
v4 = mixer_get_mixing_level(v2);
printf("%d[ch] %s\t:%d\n", v2, v3, v4);
}
++v2;
}
while ( v2 != 16 );
return;
}
}
}

original_code:
void xmame_set_mixer_volume( int ch, int level )
{
  if( use_fmgen ){
  switch( ch ){
  case XMAME_MIXER_FMPSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 2, level );
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      const char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
  return;
  }
  switch( ch ){
  case XMAME_MIXER_PSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    mixer_set_mixing_level( 2, level );
    break;
  case XMAME_MIXER_FM:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 3, level );
    }else{
      mixer_set_mixing_level( 3, level );
      mixer_set_mixing_level( 4, level );
    }
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 4, level );
    }else{
      mixer_set_mixing_level( 5, level );
    }
    break;
  case XMAME_MIXER_RHYTHM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      rhythmvol = level;
    }
    break;
  case XMAME_MIXER_ADPCM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      adpcmvol = level;
    }
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      const char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
}

canonical_original_code:
void xmame_set_mixer_volume(int ch, int level)
{
  if( use_fmgen ){
  switch( ch ){
  case XMAME_MIXER_FMPSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 2, level );
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
  return;
  }
  switch( ch ){
  case XMAME_MIXER_PSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    mixer_set_mixing_level( 2, level );
    break;
  case XMAME_MIXER_FM:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 3, level );
    }else{
      mixer_set_mixing_level( 3, level );
      mixer_set_mixing_level( 4, level );
    }
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 4, level );
    }else{
      mixer_set_mixing_level( 5, level );
    }
    break;
  case XMAME_MIXER_RHYTHM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      rhythmvol = level;
    }
    break;
  case XMAME_MIXER_ADPCM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      adpcmvol = level;
    }
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
}

variable_types: level int

variable_types:
name
char *


decompiled_code:
__int64 __fastcall YM2203UpdateRequest(int a1)
{
return stream_update((unsigned int)stream[a1], 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return stream_update((unsigned int)stream[a1], 0LL);
}

original_code:
void YM2203UpdateRequest(int chip)
{
 stream_update(stream[chip],0);
}

variable_types: chip int


decompiled_code:
_BOOL8 __fastcall YM2203_sh_start(__int64 a1)
{
int v2; // er8
_BOOL8 result; // rax
unsigned int *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbx
const char *v7; // rax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = AY8910_sh_start_ym();
result = 1LL;
if ( !v2 )
{
v4 = *(unsigned int **)(a1 + 8);
v5 = *v4;
intf = *(_QWORD *)(a1 + 8);
if ( (int)v5 > 0 )
{
v6 = 0LL;
do
{
v7 = (const char *)sound_name(a1);
sprintf(v8, "%s #%d FM", v7, (unsigned int)v6);
stream[v6] = stream_init(
v8,
(unsigned int)*(__int16 *)(intf + 4LL * (int)v6 + 10),
sample_rate,
(unsigned int)v6,
&YM2203UpdateOne);
v4 = (unsigned int *)intf;
++v6;
v5 = *(unsigned int *)intf;
}
while ( (int)v5 > (int)v6 );
}
result = (unsigned int)YM2203Init(v5, v4[1], sample_rate, 0LL, 0LL) != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
int v2; // er8
_BOOL8 result; // rax
unsigned int *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbx
const char *v7; // rax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = AY8910_sh_start_ym();
result = 1LL;
if ( !v2 )
{
v4 = *(unsigned int **)(a1 + 8);
v5 = *v4;
intf = *(_QWORD *)(a1 + 8);
if ( (int)v5 > 0 )
{
v6 = 0LL;
do
{
v7 = (const char *)sound_name(a1);
sprintf(v8, "%s #%d FM", v7, (unsigned int)v6);
stream[v6] = stream_init(
v8,
(unsigned int)*(__int16 *)(intf + 4LL * (int)v6 + 10),
sample_rate,
(unsigned int)v6,
&YM2203UpdateOne);
v4 = (unsigned int *)intf;
++v6;
v5 = *(unsigned int *)intf;
}
while ( (int)v5 > (int)v6 );
}
result = (unsigned int)YM2203Init(v5, v4[1], sample_rate, 0LL, 0LL) != 0;
}
return result;
}

original_code:
int YM2203_sh_start(const struct MachineSound *msound)
{
 int i;
 if (AY8910_sh_start_ym(msound)) return 1;
 intf = msound->sound_interface;
 FMTimerInit();
 for (i = 0;i < intf->num;i++)
 {
  int volume;
  char name[20];
  sprintf(name,"%s #%d FM",sound_name(msound),i);
  volume = intf->mixing_level[i]>>16;
  stream[i] = stream_init(name,volume,sample_rate,i,YM2203UpdateOne );
 }
 if (YM2203Init(intf->num,intf->baseclock,sample_rate,0,0) == 0)
 {
  return 0;
 }
 return 1;
}

canonical_original_code:
int YM2203_sh_start(struct MachineSound *msound)
{
 int i;
 if (AY8910_sh_start_ym(msound)) return 1;
 intf = msound->sound_interface;
 FMTimerInit();
 for (i = 0;i < intf->num;i++)
 {
  int volume;
  char name[20];
  sprintf(name,"%s #%d FM",sound_name(msound),i);
  volume = intf->mixing_level[i]>>16;
  stream[i] = stream_init(name,volume,sample_rate,i,YM2203UpdateOne );
 }
 if (YM2203Init(intf->num,intf->baseclock,sample_rate,0,0) == 0)
 {
  return 0;
 }
 return 1;
}

variable_types: struct MachineSound { int sound_type; void *sound_interface; char *tag; } *

variable_types: i int

variable_types: volume int

variable_types:
name
char [20]


decompiled_code:
__int64 YM2203_sh_stop()
{
YM2203Shutdown();
return AY8910_sh_stop_ym();
}

canonical_decompiled_code:
__int64 func3()
{
YM2203Shutdown();
return AY8910_sh_stop_ym();
}

original_code:
void YM2203_sh_stop(void)
{
 YM2203Shutdown();
 AY8910_sh_stop_ym();
}

canonical_original_code:
void YM2203_sh_stop()
{
 YM2203Shutdown();
 AY8910_sh_stop_ym();
}


decompiled_code:
__int64 YM2203_sh_reset()
{
__int64 result; // rax
unsigned int v1; // ebx
__int64 v2; // rdi

result = *(unsigned int *)intf;
if ( (int)result > 0 )
{
v1 = 0;
do
{
v2 = v1++;
YM2203ResetChip(v2);
result = intf;
}
while ( *(_DWORD *)intf > (signed int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
unsigned int v1; // ebx
__int64 v2; // rdi

result = *(unsigned int *)intf;
if ( (int)result > 0 )
{
v1 = 0;
do
{
v2 = v1++;
YM2203ResetChip(v2);
result = intf;
}
while ( *(_DWORD *)intf > (signed int)v1 );
}
return result;
}

original_code:
void YM2203_sh_reset(void)
{
 int i;
 for (i = 0;i < intf->num;i++)
  YM2203ResetChip(i);
}

canonical_original_code:
void YM2203_sh_reset()
{
 int i;
 for (i = 0;i < intf->num;i++)
  YM2203ResetChip(i);
}


decompiled_code:
__int64 YM2203_status_port_0_r()
{
return YM2203Read(0LL, 0LL);
}

canonical_decompiled_code:
__int64 func5()
{
return YM2203Read(0LL, 0LL);
}

original_code: data8_t YM2203_status_port_0_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(0,0); }

canonical_original_code: unsigned char YM2203_status_port_0_r(unsigned int offset) { return YM2203Read(0,0); }

variable_types:
offset
unsigned int


decompiled_code:
__int64 YM2203_status_port_1_r()
{
return YM2203Read(1LL, 0LL);
}

canonical_decompiled_code:
__int64 func6()
{
return YM2203Read(1LL, 0LL);
}

original_code: data8_t YM2203_status_port_1_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(1,0); }

canonical_original_code: unsigned char YM2203_status_port_1_r(unsigned int offset) { return YM2203Read(1,0); }


decompiled_code:
__int64 YM2203_status_port_2_r()
{
return YM2203Read(2LL, 0LL);
}

canonical_decompiled_code:
__int64 func7()
{
return YM2203Read(2LL, 0LL);
}

original_code: data8_t YM2203_status_port_2_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(2,0); }

canonical_original_code: unsigned char YM2203_status_port_2_r(unsigned int offset) { return YM2203Read(2,0); }


decompiled_code:
__int64 YM2203_status_port_3_r()
{
return YM2203Read(3LL, 0LL);
}

canonical_decompiled_code:
__int64 func8()
{
return YM2203Read(3LL, 0LL);
}

original_code: data8_t YM2203_status_port_3_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(3,0); }

canonical_original_code: unsigned char YM2203_status_port_3_r(unsigned int offset) { return YM2203Read(3,0); }


decompiled_code:
__int64 YM2203_status_port_4_r()
{
return YM2203Read(4LL, 0LL);
}

canonical_decompiled_code:
__int64 func9()
{
return YM2203Read(4LL, 0LL);
}

original_code: data8_t YM2203_status_port_4_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(4,0); }

canonical_original_code: unsigned char YM2203_status_port_4_r(unsigned int offset) { return YM2203Read(4,0); }


decompiled_code:
__int64 YM2203_read_port_0_r()
{
return YM2203Read(0LL, 1LL);
}

canonical_decompiled_code:
__int64 func10()
{
return YM2203Read(0LL, 1LL);
}

original_code: data8_t YM2203_read_port_0_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(0,1); }

canonical_original_code: unsigned char YM2203_read_port_0_r(unsigned int offset) { return YM2203Read(0,1); }


decompiled_code:
__int64 YM2203_read_port_1_r()
{
return YM2203Read(1LL, 1LL);
}

canonical_decompiled_code:
__int64 func11()
{
return YM2203Read(1LL, 1LL);
}

original_code: data8_t YM2203_read_port_1_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(1,1); }

canonical_original_code: unsigned char YM2203_read_port_1_r(unsigned int offset) { return YM2203Read(1,1); }


decompiled_code:
__int64 YM2203_read_port_2_r()
{
return YM2203Read(2LL, 1LL);
}

canonical_decompiled_code:
__int64 func12()
{
return YM2203Read(2LL, 1LL);
}

original_code: data8_t YM2203_read_port_2_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(2,1); }

canonical_original_code: unsigned char YM2203_read_port_2_r(unsigned int offset) { return YM2203Read(2,1); }


decompiled_code:
__int64 YM2203_read_port_3_r()
{
return YM2203Read(3LL, 1LL);
}

canonical_decompiled_code:
__int64 func13()
{
return YM2203Read(3LL, 1LL);
}

original_code: data8_t YM2203_read_port_3_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(3,1); }

canonical_original_code: unsigned char YM2203_read_port_3_r(unsigned int offset) { return YM2203Read(3,1); }


decompiled_code:
__int64 YM2203_read_port_4_r()
{
return YM2203Read(4LL, 1LL);
}

canonical_decompiled_code:
__int64 func14()
{
return YM2203Read(4LL, 1LL);
}

original_code: data8_t YM2203_read_port_4_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(4,1); }

canonical_original_code: unsigned char YM2203_read_port_4_r(unsigned int offset) { return YM2203Read(4,1); }


decompiled_code:
__int64 __fastcall YM2203_control_port_0_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 0LL, a2);
}

original_code:
void YM2203_control_port_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(0,0,data);
}

canonical_original_code:
void YM2203_control_port_0_w(unsigned int offset, unsigned char data)
{
 YM2203Write(0,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_1_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 0LL, a2);
}

original_code:
void YM2203_control_port_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(1,0,data);
}

canonical_original_code:
void YM2203_control_port_1_w(unsigned int offset, unsigned char data)
{
 YM2203Write(1,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_2_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 0LL, a2);
}

original_code:
void YM2203_control_port_2_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(2,0,data);
}

canonical_original_code:
void YM2203_control_port_2_w(unsigned int offset, unsigned char data)
{
 YM2203Write(2,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_3_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 0LL, a2);
}

original_code:
void YM2203_control_port_3_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(3,0,data);
}

canonical_original_code:
void YM2203_control_port_3_w(unsigned int offset, unsigned char data)
{
 YM2203Write(3,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_4_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 0LL, a2);
}

original_code:
void YM2203_control_port_4_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(4,0,data);
}

canonical_original_code:
void YM2203_control_port_4_w(unsigned int offset, unsigned char data)
{
 YM2203Write(4,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_0_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 1LL, a2);
}

original_code:
void YM2203_write_port_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(0,1,data);
}

canonical_original_code:
void YM2203_write_port_0_w(unsigned int offset, unsigned char data)
{
 YM2203Write(0,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_1_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 1LL, a2);
}

original_code:
void YM2203_write_port_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(1,1,data);
}

canonical_original_code:
void YM2203_write_port_1_w(unsigned int offset, unsigned char data)
{
 YM2203Write(1,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_2_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 1LL, a2);
}

original_code:
void YM2203_write_port_2_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(2,1,data);
}

canonical_original_code:
void YM2203_write_port_2_w(unsigned int offset, unsigned char data)
{
 YM2203Write(2,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_3_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 1LL, a2);
}

original_code:
void YM2203_write_port_3_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(3,1,data);
}

canonical_original_code:
void YM2203_write_port_3_w(unsigned int offset, unsigned char data)
{
 YM2203Write(3,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_4_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 1LL, a2);
}

original_code:
void YM2203_write_port_4_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(4,1,data);
}

canonical_original_code:
void YM2203_write_port_4_w(unsigned int offset, unsigned char data)
{
 YM2203Write(4,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_word_0_w(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = YM2203_write_port_0_w(0LL, a2);
else
result = YM2203_control_port_0_w(0LL, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = func20(0LL, a2);
else
result = func15(0LL, a2);
return result;
}

original_code:
void YM2203_word_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 if (offset)
  YM2203_write_port_0_w(0,data);
 else
  YM2203_control_port_0_w(0,data);
}

canonical_original_code:
void YM2203_word_0_w(unsigned int offset, unsigned char data)
{
 if (offset)
  YM2203_write_port_0_w(0,data);
 else
  YM2203_control_port_0_w(0,data);
}


decompiled_code:
__int64 __fastcall YM2203_word_1_w(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = YM2203_write_port_1_w(0LL, a2);
else
result = YM2203_control_port_1_w(0LL, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func26(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = func21(0LL, a2);
else
result = func16(0LL, a2);
return result;
}

original_code:
void YM2203_word_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 if (offset)
  YM2203_write_port_1_w(0,data);
 else
  YM2203_control_port_1_w(0,data);
}

canonical_original_code:
void YM2203_word_1_w(unsigned int offset, unsigned char data)
{
 if (offset)
  YM2203_write_port_1_w(0,data);
 else
  YM2203_control_port_1_w(0,data);
}


decompiled_code:
__int64 pause_init()
{
status_message(0LL, 0LL, " PAUSE ");
status_message(1LL, 0LL, "<ESC> key to return");
status_message(2LL, 0LL, 0LL);
return draw_screen_force();
}

canonical_decompiled_code:
__int64 func0()
{
status_message(0LL, 0LL, " PAUSE ");
status_message(1LL, 0LL, "<ESC> key to return");
status_message(2LL, 0LL, 0LL);
return draw_screen_force();
}

original_code:
static void pause_init( void )
{
  status_message( 0, 0, " PAUSE " );
  status_message( 1, 0, "<ESC> key to return" );
  status_message( 2, 0, ((void *)0) );
  draw_screen_force();
}

canonical_original_code:
static void pause_init()
{
  status_message( 0, 0, " PAUSE " );
  status_message( 1, 0, "<ESC> key to return" );
  status_message( 2, 0, ((void *)0) );
  draw_screen_force();
}


decompiled_code:
__int64 pause_event_focus_out_when_exec()
{
__int64 result; // rax

result = (unsigned int)need_focus;
if ( need_focus )
{
pause_by_focus_out = 1;
result = set_emu_mode(7LL);
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = (unsigned int)need_focus;
if ( need_focus )
{
pause_by_focus_out = 1;
result = set_emu_mode(7LL);
}
return result;
}

original_code:
void pause_event_focus_out_when_exec( void )
{
  if( need_focus ){
    pause_by_focus_out = (1);
    set_emu_mode( PAUSE );
  }
}

canonical_original_code:
void pause_event_focus_out_when_exec()
{
  if( need_focus ){
    pause_by_focus_out = (1);
    set_emu_mode( PAUSE );
  }
}


decompiled_code:
__int64 pause_event_focus_in_when_pause()
{
__int64 result; // rax

result = (unsigned int)pause_by_focus_out;
if ( pause_by_focus_out )
result = set_emu_mode(1LL);
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

result = (unsigned int)pause_by_focus_out;
if ( pause_by_focus_out )
result = set_emu_mode(1LL);
return result;
}

original_code:
void pause_event_focus_in_when_pause( void )
{
  if( pause_by_focus_out ){
    set_emu_mode( GO );
  }
}

canonical_original_code:
void pause_event_focus_in_when_pause()
{
  if( pause_by_focus_out ){
    set_emu_mode( GO );
  }
}


decompiled_code:
__int64 pause_event_key_on_esc()
{
return set_emu_mode(1LL);
}

canonical_decompiled_code:
__int64 func3()
{
return set_emu_mode(1LL);
}

original_code:
void pause_event_key_on_esc( void )
{
  set_emu_mode( GO );
}

canonical_original_code:
void pause_event_key_on_esc()
{
  set_emu_mode( GO );
}


decompiled_code:
__int64 pause_event_key_on_menu()
{
return set_emu_mode(6LL);
}

canonical_decompiled_code:
__int64 func4()
{
return set_emu_mode(6LL);
}

original_code:
void pause_event_key_on_menu( void )
{
  set_emu_mode( MENU );
}

canonical_original_code:
void pause_event_key_on_menu()
{
  set_emu_mode( MENU );
}


decompiled_code:
__int64 pause_main()
{
__int64 result; // rax

pause_init();
while ( 1 )
{
result = next_emu_mode();
if ( (_DWORD)result != 7 )
break;
event_handle();
wait_menu();
}
pause_by_focus_out = 0;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

func0();
while ( 1 )
{
result = next_emu_mode();
if ( (_DWORD)result != 7 )
break;
event_handle();
wait_menu();
}
pause_by_focus_out = 0;
return result;
}

original_code:
void pause_main( void )
{
  pause_init();
  while( next_emu_mode() == PAUSE ){
    event_handle();
    wait_menu();
  }
  pause_by_focus_out = (0);
}

canonical_original_code:
void pause_main()
{
  pause_init();
  while( next_emu_mode() == PAUSE ){
    event_handle();
    wait_menu();
  }
  pause_by_focus_out = (0);
}


decompiled_code:
int joystick_init()
{
int result; // eax

if ( use_joydevice && (result = verbose_proc) != 0 )
{
result = puts("\nJoystick not supported");
enable_joystick = 0;
}
else
{
enable_joystick = 0;
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

if ( use_joydevice && (result = verbose_proc) != 0 )
{
result = puts("\nJoystick not supported");
enable_joystick = 0;
}
else
{
enable_joystick = 0;
}
return result;
}

original_code:
void joystick_init( void )
{
  if( use_joydevice ){
    if( verbose_proc ) printf( "\nJoystick not supported\n" );
  }
  enable_joystick = (0);
}

canonical_original_code:
void joystick_init()
{
  if( use_joydevice ){
    if( verbose_proc ) printf( "\nJoystick not supported\n" );
  }
  enable_joystick = (0);
}


decompiled_code:
void joystick_term()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void joystick_term( void )
{
}

canonical_original_code:
void joystick_term()
{
}


decompiled_code:
void joystick_event()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void joystick_event( void )
{
}

canonical_original_code:
void joystick_event()
{
}


decompiled_code:
_BOOL8 check_break_point_PC()
{
__int64 v0; // rax
int v1; // edx
unsigned __int64 v2; // rax

v0 = 0LL;
while ( 1 )
{
v1 = v0;
if ( break_point[2 * v0] == 1 )
break;
if ( ++v0 == 10 )
{
v1 = 10;
break;
}
}
v2 = (unsigned int)((_DWORD)break_point + 40);
while ( *(_WORD *)v2 != 1 )
{
v2 += 4LL;
if ( (_DWORD)break_point + 80 == v2 )
return v1 != 10;
}
return 1LL;
}

canonical_decompiled_code:
_BOOL8 func0()
{
__int64 v0; // rax
int v1; // edx
unsigned __int64 v2; // rax

v0 = 0LL;
while ( 1 )
{
v1 = v0;
if ( break_point[2 * v0] == 1 )
break;
if ( ++v0 == 10 )
{
v1 = 10;
break;
}
}
v2 = (unsigned int)((_DWORD)break_point + 40);
while ( *(_WORD *)v2 != 1 )
{
v2 += 4LL;
if ( (_DWORD)break_point + 80 == v2 )
return v1 != 10;
}
return 1LL;
}

original_code:
static __inline__ int check_break_point_PC( void )
{
  int i, j;
  for( i=0; i<(10); i++ ) if( break_point[BP_MAIN][i].type == BP_PC ) break;
  for( j=0; j<(10); j++ ) if( break_point[BP_SUB][j].type == BP_PC ) break;
  if( i==(10) && j==(10) ) return (0);
  else return (1);
}

canonical_original_code:
static __inline__ int check_break_point_PC()
{
  int i; int j;
  for( i=0; i<(10); i++ ) if( break_point[BP_MAIN][i].type == BP_PC ) break;
  for( j=0; j<(10); j++ ) if( break_point[BP_SUB][j].type == BP_PC ) break;
  if( i==(10) && j==(10) ) return (0);
  else return (1);
}

variable_types: j int


decompiled_code:
__int64 emu_init()
{
status_message(0LL, 0xFFFFFFFFLL, 0LL);
status_message(1LL, 0xFFFFFFFFLL, 0LL);
status_message(2LL, 0xFFFFFFFFLL, 0LL);
return draw_screen_force();
}

canonical_decompiled_code:
__int64 func1()
{
status_message(0LL, 0xFFFFFFFFLL, 0LL);
status_message(1LL, 0xFFFFFFFFLL, 0LL);
status_message(2LL, 0xFFFFFFFFLL, 0LL);
return draw_screen_force();
}

original_code:
static void emu_init( void )
{
  status_message( 0, -1, ((void *)0) );
  status_message( 1, -1, ((void *)0) );
  status_message( 2, -1, ((void *)0) );
  draw_screen_force();
}

canonical_original_code:
static void emu_init()
{
  status_message( 0, -1, ((void *)0) );
  status_message( 1, -1, ((void *)0) );
  status_message( 2, -1, ((void *)0) );
  draw_screen_force();
}


decompiled_code:
__int64 __fastcall set_emu_mode(int a1)
{
__int64 result; // rax

if ( !a1 )
{
a1 = 1;
goto LABEL_6;
}
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 3 )
{
LABEL_6:
emu_mode_next = 0;
emu_mode_execute = a1;
goto LABEL_4;
}
emu_mode_next = a1;
emu_rest_step = 1;
LABEL_4:
z80_state_intchk = 0;
z80_state_goal = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax

if ( !a1 )
{
a1 = 1;
goto LABEL_6;
}
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 3 )
{
LABEL_6:
emu_mode_next = 0;
emu_mode_execute = a1;
goto LABEL_4;
}
emu_mode_next = a1;
emu_rest_step = 1;
LABEL_4:
z80_state_intchk = 0;
z80_state_goal = 1;
return result;
}

original_code:
void set_emu_mode( int mode )
{
  if( mode == EXEC ) mode = GO;
  if( mode == GO ||
      mode == STEP ||
      mode == TRACE ||
      mode == TRACE_CHANGE ){
    emu_mode_next = EXEC;
    emu_mode_execute = mode;
  }else{
    emu_mode_next = mode;
    emu_rest_step = 1;
  }
  do{ z80_state_intchk = 0; z80_state_goal = 1; }while(0);
}

canonical_original_code:
void set_emu_mode(int mode)
{
  if( mode == EXEC ) mode = GO;
  if( mode == GO ||
      mode == STEP ||
      mode == TRACE ||
      mode == TRACE_CHANGE ){
    emu_mode_next = EXEC;
    emu_mode_execute = mode;
  }else{
    emu_mode_next = mode;
    emu_rest_step = 1;
  }
  do{ z80_state_intchk = 0; z80_state_goal = 1; }while(0);
}

variable_types: mode int


decompiled_code:
__int64 emu_main()
{
__int64 (__fastcall *v0)(); // rbx
__int64 result; // rax
int v2; // er13
unsigned int v3; // ebp
int v4; // er12
int v5; // eax
int v6; // ebp
int v7; // er12
int v8; // eax
int v9; // edx
int v10; // esi
int v11; // eax
int v12; // eax
unsigned int v13; // eax
int v14; // eax
__int64 v15; // rsi
int v16; // eax

v0 = z80_emu_with_breakpoint;
if ( !check_break_point_PC() )
v0 = (__int64 (__fastcall *)())&z80_emu;
result = (unsigned int)emu_mode_execute;
if ( emu_mode_execute == 3 )
{
v2 = 1;
goto LABEL_11;
}
if ( emu_mode_execute == 4 )
{
v6 = select_main_cpu;
emu_rest_step = 0;
v7 = select_main_cpu;
if ( cpu_timing > 0 )
{
puts("command 'trace change' can use when -cpu 0");
return set_emu_mode(5);
}
while ( 1 )
{
if ( v6 != v7 )
goto LABEL_37;
if ( v6 )
{
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
v8 = emu_rest_step;
v9 = select_main_cpu;
if ( !emu_rest_step )
goto LABEL_30;
}
else
{
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v8 = emu_rest_step;
v9 = select_main_cpu;
if ( !emu_rest_step )
goto LABEL_30;
}
result = (unsigned int)(v8 - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
{
if ( v7 == v9 )
return result;
v7 = v9;
LABEL_37:
if ( v7 )
{
LABEL_38:
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
return set_emu_mode(5);
}
LABEL_26:
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return set_emu_mode(5);
}
LABEL_30:
v7 = v9;
}
}
v2 = trace_counter;
if ( emu_mode_execute != 2 )
{
emu_rest_step = 0;
if ( emu_mode_execute > 3 || emu_mode_execute != 1 )
return result;
v3 = 0;
v2 = 0;
goto LABEL_12;
}
LABEL_11:
emu_rest_step = v2;
v3 = 1;
LABEL_12:
v4 = cpu_timing;
if ( cpu_timing != 1 )
{
if ( cpu_timing != 2 )
{
if ( cpu_timing )
{
if ( v2 <= 0 && emu_mode_execute != 1 )
return set_emu_mode(5);
return result;
}
while ( 1 )
{
while ( !select_main_cpu )
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80sub_cpu, v3);
v5 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_21;
}
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
v5 = emu_rest_step;
if ( emu_rest_step )
{
LABEL_21:
++v4;
emu_rest_step = v5 - 1;
if ( v5 - 1 <= 0 )
goto LABEL_22;
}
}
}
v4 = 0;
while ( 1 )
{
while ( 1 )
{
v11 = main_state;
if ( main_state <= 255 )
break;
LABEL_45:
v13 = v11 >> 8;
if ( v3 )
v13 = v3;
v14 = ((__int64 (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v13);
v10 = sub_state;
main_state -= v14 << 8;
if ( sub_state > 255 )
goto LABEL_48;
LABEL_43:
v12 = emu_rest_step;
if ( emu_rest_step )
{
LABEL_51:
++v4;
emu_rest_step = v12 - 1;
if ( v12 - 1 <= 0 )
goto LABEL_22;
}
}
v10 = sub_state;
if ( sub_state <= 255 )
{
v11 = (int)(cpu_clock_mhz * (double)cpu_slice_us * 256.0 + (double)main_state);
main_state = v11;
v10 = (int)((double)cpu_slice_us * 3.9936 * 256.0 + (double)sub_state);
sub_state = v10;
if ( v11 > 255 )
goto LABEL_45;
if ( v10 <= 255 )
goto LABEL_43;
}
LABEL_48:
v15 = (unsigned int)(v10 >> 8);
if ( v3 )
v15 = v3;
sub_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, v15) << 8;
v12 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_51;
}
}
v4 = 0;
do
{
do
{
while ( !dual_cpu_count )
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
v16 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_57;
}
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v16 = emu_rest_step;
--dual_cpu_count;
}
while ( !emu_rest_step );
LABEL_57:
++v4;
emu_rest_step = v16 - 1;
}
while ( v16 - 1 > 0 );
LABEL_22:
result = (unsigned int)emu_mode_execute;
if ( v4 < v2 || emu_mode_execute == 1 )
return result;
if ( cpu_timing != 1 )
{
if ( cpu_timing == 2 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
}
else
{
if ( cpu_timing )
return set_emu_mode(5);
if ( select_main_cpu )
goto LABEL_38;
}
goto LABEL_26;
}
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
if ( dual_cpu_count )
goto LABEL_26;
return set_emu_mode(5);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 (__fastcall *v0)(); // rbx
__int64 result; // rax
int v2; // er13
unsigned int v3; // ebp
int v4; // er12
int v5; // eax
int v6; // ebp
int v7; // er12
int v8; // eax
int v9; // edx
int v10; // esi
int v11; // eax
int v12; // eax
unsigned int v13; // eax
int v14; // eax
__int64 v15; // rsi
int v16; // eax

v0 = z80_emu_with_breakpoint;
if ( !func0() )
v0 = (__int64 (__fastcall *)())&z80_emu;
result = (unsigned int)emu_mode_execute;
if ( emu_mode_execute == 3 )
{
v2 = 1;
goto LABEL_11;
}
if ( emu_mode_execute == 4 )
{
v6 = select_main_cpu;
emu_rest_step = 0;
v7 = select_main_cpu;
if ( cpu_timing > 0 )
{
puts("command 'trace change' can use when -cpu 0");
return func2(5);
}
while ( 1 )
{
if ( v6 != v7 )
goto LABEL_37;
if ( v6 )
{
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
v8 = emu_rest_step;
v9 = select_main_cpu;
if ( !emu_rest_step )
goto LABEL_30;
}
else
{
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v8 = emu_rest_step;
v9 = select_main_cpu;
if ( !emu_rest_step )
goto LABEL_30;
}
result = (unsigned int)(v8 - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
{
if ( v7 == v9 )
return result;
v7 = v9;
LABEL_37:
if ( v7 )
{
LABEL_38:
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
return func2(5);
}
LABEL_26:
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return func2(5);
}
LABEL_30:
v7 = v9;
}
}
v2 = trace_counter;
if ( emu_mode_execute != 2 )
{
emu_rest_step = 0;
if ( emu_mode_execute > 3 || emu_mode_execute != 1 )
return result;
v3 = 0;
v2 = 0;
goto LABEL_12;
}
LABEL_11:
emu_rest_step = v2;
v3 = 1;
LABEL_12:
v4 = cpu_timing;
if ( cpu_timing != 1 )
{
if ( cpu_timing != 2 )
{
if ( cpu_timing )
{
if ( v2 <= 0 && emu_mode_execute != 1 )
return func2(5);
return result;
}
while ( 1 )
{
while ( !select_main_cpu )
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80sub_cpu, v3);
v5 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_21;
}
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
v5 = emu_rest_step;
if ( emu_rest_step )
{
LABEL_21:
++v4;
emu_rest_step = v5 - 1;
if ( v5 - 1 <= 0 )
goto LABEL_22;
}
}
}
v4 = 0;
while ( 1 )
{
while ( 1 )
{
v11 = main_state;
if ( main_state <= 255 )
break;
LABEL_45:
v13 = v11 >> 8;
if ( v3 )
v13 = v3;
v14 = ((__int64 (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v13);
v10 = sub_state;
main_state -= v14 << 8;
if ( sub_state > 255 )
goto LABEL_48;
LABEL_43:
v12 = emu_rest_step;
if ( emu_rest_step )
{
LABEL_51:
++v4;
emu_rest_step = v12 - 1;
if ( v12 - 1 <= 0 )
goto LABEL_22;
}
}
v10 = sub_state;
if ( sub_state <= 255 )
{
v11 = (int)(cpu_clock_mhz * (double)cpu_slice_us * 256.0 + (double)main_state);
main_state = v11;
v10 = (int)((double)cpu_slice_us * 3.9936 * 256.0 + (double)sub_state);
sub_state = v10;
if ( v11 > 255 )
goto LABEL_45;
if ( v10 <= 255 )
goto LABEL_43;
}
LABEL_48:
v15 = (unsigned int)(v10 >> 8);
if ( v3 )
v15 = v3;
sub_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, v15) << 8;
v12 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_51;
}
}
v4 = 0;
do
{
do
{
while ( !dual_cpu_count )
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
v16 = emu_rest_step;
if ( emu_rest_step )
goto LABEL_57;
}
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v16 = emu_rest_step;
--dual_cpu_count;
}
while ( !emu_rest_step );
LABEL_57:
++v4;
emu_rest_step = v16 - 1;
}
while ( v16 - 1 > 0 );
LABEL_22:
result = (unsigned int)emu_mode_execute;
if ( v4 < v2 || emu_mode_execute == 1 )
return result;
if ( cpu_timing != 1 )
{
if ( cpu_timing == 2 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
}
else
{
if ( cpu_timing )
return func2(5);
if ( select_main_cpu )
goto LABEL_38;
}
goto LABEL_26;
}
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
if ( dual_cpu_count )
goto LABEL_26;
return func2(5);
}

original_code:
static void emu_main( void )
{
  int passed_step;
  int target_step;
  int infinity, only_1step;
  int wk;
  int (*z80_exec)( z80arch *, int );
  if( check_break_point_PC() ) z80_exec = z80_emu_with_breakpoint;
  else z80_exec = z80_emu;
  passed_step = 0;
  switch( emu_mode_execute ){
  default:
  case GO:
    target_step = 0;
    infinity = (0);
    only_1step = (1);
    break;
  case TRACE:
    target_step = trace_counter;
    infinity = (1);
    only_1step = (1);
    break;
  case STEP:
    target_step = 1;
    infinity = (1);
    only_1step = (1);
    break;
  case TRACE_CHANGE:
    target_step = 0;
    infinity = (1);
    only_1step = (1);
    break;
  }
  emu_rest_step = target_step;
  switch( emu_mode_execute ){
  case GO:
  case TRACE:
  case STEP:
    switch( cpu_timing ){
    case 0:
      for(;;){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 1:
      for(;;){
 if( dual_cpu_count==0 ) (z80_exec)( &z80main_cpu, infinity );
 else{
   (z80_exec)( &z80main_cpu, only_1step );
   (z80_exec)( &z80sub_cpu, only_1step );
   dual_cpu_count --;
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 2:
      for(;;){
 if( main_state < 1*(256) && sub_state < 1*(256) ){
   main_state += (cpu_clock_mhz * cpu_slice_us) * (256);
   sub_state += (3.9936 * cpu_slice_us) * (256);
 }
 if( main_state >= 1*(256) ){
   wk = (infinity==(0)) ? main_state/(256) : (1);
   main_state -= (z80_exec( &z80main_cpu, wk ) ) * (256);
 }
 if( sub_state >= 1*(256) ){
   wk = (infinity==(0)) ? sub_state/(256) : (1);
   sub_state -= (z80_exec( &z80sub_cpu, wk ) ) * (256);
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    }
    if( emu_mode_execute != GO ){
      if( passed_step >= target_step ){
 switch( cpu_timing ){
 case 0:
   if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 1:
                        z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   if( dual_cpu_count ) z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 2:
   z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 }
 set_emu_mode( MONITOR );
      }
    }
    break;
    case TRACE_CHANGE:
      if( cpu_timing >= 1 ){
 printf( "command 'trace change' can use when -cpu 0\n");
 set_emu_mode( MONITOR );
 break;
      }
      wk = select_main_cpu;
      while( wk==select_main_cpu ){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      if( wk != select_main_cpu ){
 if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
 set_emu_mode( MONITOR );
      }
      break;
  }
}

canonical_original_code:
static void emu_main()
{
  int passed_step;
  int target_step;
  int infinity; int only_1step;
  int wk;
  int (*z80_exec)(struct z80arch *, int);
  if( check_break_point_PC() ) z80_exec = z80_emu_with_breakpoint;
  else z80_exec = z80_emu;
  passed_step = 0;
  switch( emu_mode_execute ){
  default:
  case GO:
    target_step = 0;
    infinity = (0);
    only_1step = (1);
    break;
  case TRACE:
    target_step = trace_counter;
    infinity = (1);
    only_1step = (1);
    break;
  case STEP:
    target_step = 1;
    infinity = (1);
    only_1step = (1);
    break;
  case TRACE_CHANGE:
    target_step = 0;
    infinity = (1);
    only_1step = (1);
    break;
  }
  emu_rest_step = target_step;
  switch( emu_mode_execute ){
  case GO:
  case TRACE:
  case STEP:
    switch( cpu_timing ){
    case 0:
      for(;;){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 1:
      for(;;){
 if( dual_cpu_count==0 ) (z80_exec)( &z80main_cpu, infinity );
 else{
   (z80_exec)( &z80main_cpu, only_1step );
   (z80_exec)( &z80sub_cpu, only_1step );
   dual_cpu_count --;
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 2:
      for(;;){
 if( main_state < 1*(256) && sub_state < 1*(256) ){
   main_state += (cpu_clock_mhz * cpu_slice_us) * (256);
   sub_state += (3.9936 * cpu_slice_us) * (256);
 }
 if( main_state >= 1*(256) ){
   wk = (infinity==(0)) ? main_state/(256) : (1);
   main_state -= (z80_exec( &z80main_cpu, wk ) ) * (256);
 }
 if( sub_state >= 1*(256) ){
   wk = (infinity==(0)) ? sub_state/(256) : (1);
   sub_state -= (z80_exec( &z80sub_cpu, wk ) ) * (256);
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    }
    if( emu_mode_execute != GO ){
      if( passed_step >= target_step ){
 switch( cpu_timing ){
 case 0:
   if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 1:
                        z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   if( dual_cpu_count ) z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 2:
   z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 }
 set_emu_mode( MONITOR );
      }
    }
    break;
    case TRACE_CHANGE:
      if( cpu_timing >= 1 ){
 printf( "command 'trace change' can use when -cpu 0\n");
 set_emu_mode( MONITOR );
 break;
      }
      wk = select_main_cpu;
      while( wk==select_main_cpu ){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      if( wk != select_main_cpu ){
 if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
 set_emu_mode( MONITOR );
      }
      break;
  }
}

variable_types: infinity int

variable_types: wk int

variable_types: int (*)(struct z80arch { union pair { struct { unsigned char l; } B; unsigned short W; } AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; } *, int)

user_defined_types: struct z80arch { union pair AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; }


decompiled_code:
__int64 __fastcall z80_emu_with_breakpoint(unsigned __int16 *a1)
{
unsigned int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rcx
__int64 v5; // rsi

v1 = z80_emu(a1, 1LL);
v2 = 0LL;
v3 = 20LL * (a1 != (unsigned __int16 *)&z80main_cpu);
do
{
while ( 1 )
{
v4 = (unsigned int)(v2 + 1);
if ( break_point[2 * v2 + v3] == 1 )
{
v5 = a1[6];
if ( break_point[2 * v2 + 1 + v3] == (_WORD)v5 )
break;
}
if ( ++v2 == 10 )
return v1;
}
if ( v2 == 9 )
break_point[20 * (a1 != (unsigned __int16 *)&z80main_cpu) + 18] = 0;
if ( a1 == (unsigned __int16 *)&z80main_cpu )
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", v5, "MAIN", v4);
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
}
else
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", v5, "SUB", v4);
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
}
++v2;
set_emu_mode(5);
}
while ( v2 != 10 );
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int16 *a1)
{
unsigned int v1; // er12
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rcx
__int64 v5; // rsi

v1 = z80_emu(a1, 1LL);
v2 = 0LL;
v3 = 20LL * (a1 != (unsigned __int16 *)&z80main_cpu);
do
{
while ( 1 )
{
v4 = (unsigned int)(v2 + 1);
if ( break_point[2 * v2 + v3] == 1 )
{
v5 = a1[6];
if ( break_point[2 * v2 + 1 + v3] == (_WORD)v5 )
break;
}
if ( ++v2 == 10 )
return v1;
}
if ( v2 == 9 )
break_point[20 * (a1 != (unsigned __int16 *)&z80main_cpu) + 18] = 0;
if ( a1 == (unsigned __int16 *)&z80main_cpu )
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", v5, "MAIN", v4);
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
}
else
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", v5, "SUB", v4);
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
}
++v2;
func2(5);
}
while ( v2 != 10 );
return v1;
}

original_code:
static int z80_emu_with_breakpoint( z80arch *z80, int unused )
{
  int i, cpu, states;
  states = z80_emu( z80, 1 );
  if( z80==&z80main_cpu ) cpu = BP_MAIN;
  else cpu = BP_SUB;
  for( i=0; i<(10); i++ ){
    if( break_point[cpu][i].type == BP_PC &&
 break_point[cpu][i].addr == z80->PC.W ){
      if( i==(9) ){
 break_point[cpu][i].type = BP_NONE;
      }
      printf( "*** Break at %04x *** ( %s[#%d] : PC )\n",
       z80->PC.W, (cpu==BP_MAIN)?"MAIN":"SUB", i+1 );
      if( cpu==BP_MAIN ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
      else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
      set_emu_mode( MONITOR );
    }
  }
  return states;
}

canonical_original_code:
static int z80_emu_with_breakpoint(struct z80arch *z80, int unused)
{
  int i; int cpu; int states;
  states = z80_emu( z80, 1 );
  if( z80==&z80main_cpu ) cpu = BP_MAIN;
  else cpu = BP_SUB;
  for( i=0; i<(10); i++ ){
    if( break_point[cpu][i].type == BP_PC &&
 break_point[cpu][i].addr == z80->PC.W ){
      if( i==(9) ){
 break_point[cpu][i].type = BP_NONE;
      }
      printf( "*** Break at %04x *** ( %s[#%d] : PC )\n",
       z80->PC.W, (cpu==BP_MAIN)?"MAIN":"SUB", i+1 );
      if( cpu==BP_MAIN ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
      else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
      set_emu_mode( MONITOR );
    }
  }
  return states;
}

variable_types: struct z80arch { union pair { struct { unsigned char l; } B; unsigned short W; } AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; } *

variable_types: unused int

variable_types: cpu int

variable_types: states int


decompiled_code:
__int64 get_emu_mode()
{
return (unsigned int)emu_mode;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)emu_mode;
}

original_code:
int get_emu_mode( void )
{
  return emu_mode;
}

canonical_original_code:
int get_emu_mode()
{
  return emu_mode;
}


decompiled_code:
__int64 next_emu_mode()
{
return (unsigned int)emu_mode_next;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)emu_mode_next;
}

original_code:
int next_emu_mode( void )
{
  return emu_mode_next;
}

canonical_original_code:
int next_emu_mode()
{
  return emu_mode_next;
}


decompiled_code:
void emu_reset()
{
select_main_cpu = 1;
dual_cpu_count = 0;
main_state = 0;
sub_state = 0;
}

canonical_decompiled_code:
void func7()
{
select_main_cpu = 1;
dual_cpu_count = 0;
main_state = 0;
sub_state = 0;
}

original_code:
void emu_reset( void )
{
  select_main_cpu = (1);
  dual_cpu_count = 0;
  main_state = 0;
  sub_state = 0;
}

canonical_original_code:
void emu_reset()
{
  select_main_cpu = (1);
  dual_cpu_count = 0;
  main_state = 0;
  sub_state = 0;
}


emu

decompiled_code:
__int64 emu()
{
__int16 *v0; // rax
unsigned __int64 v1; // rax
char *v2; // rax
int v3; // edx
__int64 result; // rax

v0 = break_point;
do
{
v0 += 2;
*(v0 - 2) = 0;
}
while ( v0 != &break_point[20] );
v1 = (unsigned int)((_DWORD)break_point + 40);
do
{
v1 += 4LL;
*(_WORD *)(v1 - 4) = 0;
}
while ( (__int16 *)v1 != &break_point[40] );
v2 = (char *)&break_point_fdc;
do
{
v2 += 8;
*((_WORD *)v2 - 4) = 0;
}
while ( v2 != (char *)&break_point_fdc + 80 );
v3 = emu_mode;
while ( 1 )
{
if ( emu_mode_next != v3 )
{
emu_mode = emu_mode_next;
if ( !emu_mode_next )
emu_init();
}
wait_vsync_reset();
v3 = emu_mode;
result = (unsigned int)emu_mode;
switch ( emu_mode )
{
case 0:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_resume();
event_init();
keyboard_start();
emu_main();
v3 = emu_mode;
break;
case 5:
set_emu_mode(7);
break;
case 6:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_suspend();
event_init();
keyboard_stop();
menu_main();
v3 = emu_mode;
break;
case 7:
set_window_title("QUASI88 (PAUSE)");
xmame_sound_suspend();
event_init();
keyboard_stop();
pause_main();
v3 = emu_mode;
break;
case 8:
return result;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 func8()
{
__int16 *v0; // rax
unsigned __int64 v1; // rax
char *v2; // rax
int v3; // edx
__int64 result; // rax

v0 = break_point;
do
{
v0 += 2;
*(v0 - 2) = 0;
}
while ( v0 != &break_point[20] );
v1 = (unsigned int)((_DWORD)break_point + 40);
do
{
v1 += 4LL;
*(_WORD *)(v1 - 4) = 0;
}
while ( (__int16 *)v1 != &break_point[40] );
v2 = (char *)&break_point_fdc;
do
{
v2 += 8;
*((_WORD *)v2 - 4) = 0;
}
while ( v2 != (char *)&break_point_fdc + 80 );
v3 = emu_mode;
while ( 1 )
{
if ( emu_mode_next != v3 )
{
emu_mode = emu_mode_next;
if ( !emu_mode_next )
func1();
}
wait_vsync_reset();
v3 = emu_mode;
result = (unsigned int)emu_mode;
switch ( emu_mode )
{
case 0:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_resume();
event_init();
keyboard_start();
func3();
v3 = emu_mode;
break;
case 5:
func2(7);
break;
case 6:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_suspend();
event_init();
keyboard_stop();
menu_main();
v3 = emu_mode;
break;
case 7:
set_window_title("QUASI88 (PAUSE)");
xmame_sound_suspend();
event_init();
keyboard_stop();
pause_main();
v3 = emu_mode;
break;
case 8:
return result;
default:
continue;
}
}
}

original_code:
void emu( void )
{
  int i, j;
  for( j=0; j<2; j++ )
    for( i=0; i<(10); i++ )
      break_point[j][i].type = BP_NONE;
  for( i=0; i<(10); i++ )
    break_point_fdc[i].type = BP_NONE;
  for( ;; ){
    if( emu_mode != emu_mode_next ){
      emu_mode = emu_mode_next;
      if( emu_mode == EXEC ){
 emu_init();
      }
    }
    wait_vsync_reset();
    switch( emu_mode ){
    case EXEC:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_resume();
      event_init();
      keyboard_start();
      emu_main();
      break;
    case MONITOR:
      set_emu_mode( PAUSE );
      break;
    case MENU:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      menu_main();
      break;
    case PAUSE:
      set_window_title( "QUASI88" " (PAUSE)" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      pause_main();
      break;
    case QUIT:
      return;
    }
  }
}

canonical_original_code:
void emu()
{
  int i; int j;
  for( j=0; j<2; j++ )
    for( i=0; i<(10); i++ )
      break_point[j][i].type = BP_NONE;
  for( i=0; i<(10); i++ )
    break_point_fdc[i].type = BP_NONE;
  for( ;; ){
    if( emu_mode != emu_mode_next ){
      emu_mode = emu_mode_next;
      if( emu_mode == EXEC ){
 emu_init();
      }
    }
    wait_vsync_reset();
    switch( emu_mode ){
    case EXEC:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_resume();
      event_init();
      keyboard_start();
      emu_main();
      break;
    case MONITOR:
      set_emu_mode( PAUSE );
      break;
    case MENU:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      menu_main();
      break;
    case PAUSE:
      set_window_title( "QUASI88" " (PAUSE)" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      pause_main();
      break;
    case QUIT:
      return;
    }
  }
}


decompiled_code:
_BOOL8 statesave_emu()
{
return (unsigned int)statesave_table("EMU ", &suspend_emu_work) == 0;
}

canonical_decompiled_code:
_BOOL8 func9()
{
return (unsigned int)statesave_table("EMU ", &suspend_emu_work) == 0;
}

original_code:
int statesave_emu( void )
{
  if( statesave_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
}

canonical_original_code:
int statesave_emu()
{
  if( statesave_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
}


decompiled_code:
_BOOL8 stateload_emu()
{
return (unsigned int)stateload_table("EMU ", &suspend_emu_work) == 0;
}

canonical_decompiled_code:
_BOOL8 func10()
{
return (unsigned int)stateload_table("EMU ", &suspend_emu_work) == 0;
}

original_code:
int stateload_emu( void )
{
  if( stateload_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
  set_emu_mode( EXEC );
}

canonical_original_code:
int stateload_emu()
{
  if( stateload_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
  set_emu_mode( EXEC );
}


decompiled_code:
__int64 __fastcall sound_set_options(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
bool v5; // cf

if ( use_sound )
{
v3 = sound_samplerate;
*(_DWORD *)(a1 + 64) = a3;
sample_rate = v3;
}
else
{
v5 = sound_fake == 0;
*(_DWORD *)(a1 + 64) = a3;
sample_rate = v5 ? 0 : 0x1F40;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
bool v5; // cf

if ( use_sound )
{
v3 = sound_samplerate;
*(_DWORD *)(a1 + 64) = a3;
sample_rate = v3;
}
else
{
v5 = sound_fake == 0;
*(_DWORD *)(a1 + 64) = a3;
sample_rate = v5 ? 0 : 0x1F40;
}
return 0LL;
}

original_code:
static int sound_set_options(struct rc_option *option, const char *arg,
   int priority)
{
  if(use_sound)
  {
     sample_rate = sound_samplerate;
  }
  else if(sound_fake)
  {
     sample_rate = 8000;
  }
  else
     sample_rate = 0;
  option->priority = priority;
  return 0;
}

canonical_original_code:
static int sound_set_options(struct rc_option *option, char *arg, int priority)
{
  if(use_sound)
  {
     sample_rate = sound_samplerate;
  }
  else if(sound_fake)
  {
     sample_rate = 8000;
  }
  else
     sample_rate = 0;
  option->priority = priority;
  return 0;
}

variable_types: struct rc_option { char *name; char *shortname; int type; void *dest; char *deflt; float min; float max; int (*func)(struct rc_option *option, char *arg, int priority); char *help; int priority; } *

variable_types:
arg
char *

variable_types: priority int


decompiled_code:
_BOOL8 osd_has_sound_mixer()
{
return sound_mixer != 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
return sound_mixer != 0;
}

original_code: int osd_has_sound_mixer(void){ return (sound_mixer) ? 1 : 0; }

canonical_original_code: int osd_has_sound_mixer(){ return (sound_mixer) ? 1 : 0; }


decompiled_code:
__int64 __fastcall osd_set_mastervolume(int a1)
{
float v1; // xmm0_4
__int64 result; // rax

if ( sound_mixer )
{
v1 = (float)((float)((float)((float)a1 + 32.0) * 100.0) * 0.03125) + 0.5;
result = sysdep_mixer_set(sound_mixer, 1LL, (unsigned int)(int)v1, (unsigned int)(int)v1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
float v1; // xmm0_4
__int64 result; // rax

if ( sound_mixer )
{
v1 = (float)((float)((float)((float)a1 + 32.0) * 100.0) * 0.03125) + 0.5;
result = sysdep_mixer_set(sound_mixer, 1LL, (unsigned int)(int)v1, (unsigned int)(int)v1);
}
return result;
}

original_code:
void osd_set_mastervolume (int attenuation)
{
   float f = attenuation;
   if(!sound_mixer)
      return;
   f += 32.0;
   f *= 100.0;
   f /= 32.0;
   f += 0.50;
   sysdep_mixer_set(sound_mixer, 1, f, f);
}

canonical_original_code:
void osd_set_mastervolume(int attenuation)
{
   float f = attenuation;
   if(!sound_mixer)
      return;
   f += 32.0;
   f *= 100.0;
   f /= 32.0;
   f += 0.50;
   sysdep_mixer_set(sound_mixer, 1, f, f);
}

variable_types: attenuation int

variable_types: f float