decompiled_code:
__int64 __fastcall tpool_init(_QWORD *a1, __int64 a2, __int64 a3)
{
*a1 = a3;
bitar_init(a1 + 1, a2);
bitar_init(a1 + 7, a2);
bitar_init(a1 + 4, a2);
bitar_init(a1 + 10, a2);
return bitar_init(a1 + 13, a2);
}

canonical_decompiled_code:
__int64 __fastcall func16(_QWORD *a1, __int64 a2, __int64 a3)
{
*a1 = a3;
bitar_init(a1 + 1, a2);
bitar_init(a1 + 7, a2);
bitar_init(a1 + 4, a2);
bitar_init(a1 + 10, a2);
return bitar_init(a1 + 13, a2);
}

original_code:
void
tpool_init(struct tpool *tp, size_t output_w, struct synar *synar)
{
  tp->synar = synar;
  bitar_init(tp->and, output_w);
  bitar_init(tp->in_prev, output_w);
  bitar_init(tp->out_prev, output_w);
  bitar_init(tp->tmp, output_w);
  bitar_init(tp->tmp + 1, output_w);
}

canonical_original_code:
void tpool_init(struct tpool *tp, unsigned long output_w, struct synar *synar)
{
  tp->synar = synar;
  bitar_init(tp->and, output_w);
  bitar_init(tp->in_prev, output_w);
  bitar_init(tp->out_prev, output_w);
  bitar_init(tp->tmp, output_w);
  bitar_init(tp->tmp + 1, output_w);
}

variable_types: struct tpool { struct synar { unsigned long syns; unsigned long wconns; struct synapse { unsigned long totcount; struct wconn { unsigned long id; unsigned long count; } *wconn; } *array; } *synar; struct bitar { unsigned long count; unsigned long map_size; unsigned long *map; } and[1]; struct bitar out_prev[1]; struct bitar in_prev[1]; struct bitar tmp[2]; } *

variable_types:
synar
struct synar *

user_defined_types: struct tpool { struct synar *synar; struct bitar and[1]; struct bitar out_prev[1]; struct bitar in_prev[1]; struct bitar tmp[2]; }


tpool

repo: glguida/libhacktm-old

decompiled_code:
__int64 __fastcall tpool(__int64 a1, _QWORD *a2)
{
__int64 v2; // r15
int i; // ebp
int v4; // ebx
__int64 result; // rax
__int64 v6; // [rsp+8h] [rbp-40h]

v6 = a1 + 32;
bitar_and(a2, a1 + 32, a1 + 8);
if ( *(_QWORD *)(a1 + 8) == *a2 )
{
bitar_copy(a1 + 56, a2);
bitar_copy(a2, v6);
result = 0LL;
}
else
{
bitar_copy(a1 + 56, a2);
v2 = a1 + 80;
bitar_copy(a1 + 80, a2);
for ( i = 0; i != 5; bitar_or(v2 + 24LL * (i % 2), a2, a2) )
{
v4 = i++;
bitar_reset(v2 + 24LL * (i % 2));
synarray_predict(*(_QWORD **)a1, v2 + 24LL * (v4 % 2), v2 + 24LL * (i % 2));
}
bitar_copy(v6, a2);
result = 1LL;
}
return result;
}

original_code:
int
tpool(struct tpool *tp, bitar_t *out)
{
  int i;
  bitar_and(out, tp->out_prev, tp->and);
  if ( tp->and->count == out->count ) {
    bitar_copy(tp->in_prev, out);
    bitar_copy(out, tp->out_prev);
    return 0;
  }
  bitar_copy(tp->in_prev, out);
  bitar_copy(tp->tmp, out);
  for ( i = 0; i < 5; i++ ) {
    bitar_reset(tp->tmp + ((i + 1) % 2));
    synarray_predict(tp->synar, tp->tmp + (i % 2),
       tp->tmp + ((i + 1) % 2));
    bitar_or(tp->tmp + ((i + 1) % 2), out, out);
  }
  bitar_copy(tp->out_prev, out);
  return 1;
}

canonical_original_code:
int tpool(struct tpool *tp, struct bitar *out)
{
  int i;
  bitar_and(out, tp->out_prev, tp->and);
  if ( tp->and->count == out->count ) {
    bitar_copy(tp->in_prev, out);
    bitar_copy(out, tp->out_prev);
    return 0;
  }
  bitar_copy(tp->in_prev, out);
  bitar_copy(tp->tmp, out);
  for ( i = 0; i < 5; i++ ) {
    bitar_reset(tp->tmp + ((i + 1) % 2));
    synarray_predict(tp->synar, tp->tmp + (i % 2),
       tp->tmp + ((i + 1) % 2));
    bitar_or(tp->tmp + ((i + 1) % 2), out, out);
  }
  bitar_copy(tp->out_prev, out);
  return 1;
}

variable_types:
out
struct bitar *

variable_types: i int

return_type: int

user_defined_types: struct synar { unsigned long syns; unsigned long wconns; struct synapse *array; }

user_defined_types: struct bitar { unsigned long count; unsigned long map_size; unsigned long *map; }

user_defined_types: struct synapse { unsigned long totcount; struct wconn *wconn; }

user_defined_types: struct wconn { unsigned long id; unsigned long count; }


decompiled_code:
__int64 __fastcall node_conn_init(__int64 a1, __int64 a2)
{
((void (*)(void))bitar_init)();
return bitar_init(a1 + 24, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
((void (*)(void))bitar_init)();
return bitar_init(a1 + 24, a2);
}

original_code:
void
node_conn_init(struct node_conn *nc, size_t mapsize)
{
  bitar_init(nc->val, mapsize);
  bitar_init(nc->val + 1, mapsize);
}

canonical_original_code:
void node_conn_init(struct node_conn *nc, unsigned long mapsize)
{
  bitar_init(nc->val, mapsize);
  bitar_init(nc->val + 1, mapsize);
}

variable_types: struct node_conn { struct bitar { unsigned long count; unsigned long map_size; unsigned long *map; } val[2]; } *

variable_types:
mapsize
unsigned long

return_type: void

user_defined_types: struct node_conn { struct bitar val[2]; }


original_code:
void
node_init(node_t *n, size_t input_w, size_t columns_w,
   size_t sp_in_conn_fct, size_t sp_act_fct,
   size_t sq_cells_per_col, size_t sq_col_conn_fct)
{
  n->input_w = input_w;
  n->output_w = columns_w * sq_cells_per_col;
  bitar_init(n->col_temp, columns_w);
  bitar_init(n->col_exp, columns_w);
  spool_init_std(n->sp, input_w, columns_w, sp_in_conn_fct, sp_act_fct);
  seqlearn_init_std(n->sq, columns_w, sq_cells_per_col, sq_col_conn_fct);
  tpool_init(n->tp, n->output_w, n->sq->prev2cur);
}

canonical_original_code:
void node_init(struct node *n, unsigned long input_w, unsigned long columns_w, unsigned long sp_in_conn_fct, unsigned long sp_act_fct, unsigned long sq_cells_per_col, unsigned long sq_col_conn_fct)
{
  n->input_w = input_w;
  n->output_w = columns_w * sq_cells_per_col;
  bitar_init(n->col_temp, columns_w);
  bitar_init(n->col_exp, columns_w);
  spool_init_std(n->sp, input_w, columns_w, sp_in_conn_fct, sp_act_fct);
  seqlearn_init_std(n->sq, columns_w, sq_cells_per_col, sq_col_conn_fct);
  tpool_init(n->tp, n->output_w, n->sq->prev2cur);
}

variable_types: struct node { unsigned long input_w; unsigned long output_w; struct bitar { unsigned long count; unsigned long map_size; unsigned long *map; } col_temp[1]; struct bitar col_exp[1]; struct spool { unsigned long input_w; unsigned long columns_w; unsigned long conns; unsigned long maxbits; struct bitar input[1]; struct fdr { unsigned long input_mapsize; unsigned long output_mapsize; unsigned long conn_bits; unsigned long trunc; struct bitar and; struct bitar *incols; struct coinc_array { unsigned long col; unsigned long val; } *coinc_array; } in2col[1]; struct synar { unsigned long syns; unsigned long wconns; struct synapse { unsigned long totcount; struct wconn { unsigned long id; unsigned long count; } *wconn; } *array; } synar[1]; } sp[1]; struct seqlearn { unsigned long columns_w; unsigned long output_w; struct fdr col2cur[1]; unsigned long col2cur_conns; struct synar prev2cur[1]; struct bitar col_prev[1]; struct bitar prev[1]; struct bitar expected[1]; } sq[1]; struct tpool { struct synar *synar; struct bitar and[1]; struct bitar out_prev[1]; struct bitar in_prev[1]; struct bitar tmp[2]; } tp[1]; } *

user_defined_types: struct node { unsigned long input_w; unsigned long output_w; struct bitar col_temp[1]; struct bitar col_exp[1]; struct spool sp[1]; struct seqlearn sq[1]; struct tpool tp[1]; }

user_defined_types: struct spool { unsigned long input_w; unsigned long columns_w; unsigned long conns; unsigned long maxbits; struct bitar input[1]; struct fdr in2col[1]; struct synar synar[1]; }

user_defined_types: struct fdr { unsigned long input_mapsize; unsigned long output_mapsize; unsigned long conn_bits; unsigned long trunc; struct bitar and; struct bitar *incols; struct coinc_array *coinc_array; }


decompiled_code:
__int64 __fastcall node_process(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

bitar_reset(a3);
bitar_reset(a1 + 16);
bitar_reset(a1 + 40);
bitar_scale(a1 + 384, a1 + 40);
spool(a1 + 64, a2, a1 + 40, a1 + 16);
result = seqlearn(a1 + 216, a1 + 16, a3 + 24, a3);
if ( (_DWORD)result )
result = (unsigned int)tpool(a1 + 408, a3) != 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

bitar_reset(a3);
bitar_reset(a1 + 16);
bitar_reset(a1 + 40);
bitar_scale(a1 + 384, a1 + 40);
spool(a1 + 64, a2, a1 + 40, a1 + 16);
result = seqlearn(a1 + 216, a1 + 16, a3 + 24, a3);
if ( (_DWORD)result )
result = (unsigned int)tpool(a1 + 408, a3) != 0;
return result;
}

original_code:
int
node_process(node_t *n, struct node_conn *in, struct node_conn *out)
{
  int r;
  bitar_reset(((out)->val));
  bitar_reset(n->col_temp);
  bitar_reset(n->col_exp);
  bitar_scale(n->sq->expected, n->col_exp);
  spool(n->sp, ((in)->val), n->col_exp, n->col_temp);
  r = seqlearn(n->sq, n->col_temp, ((out)->val + 1), ((out)->val));
  if ( !r )
    return 0;
  r = tpool(n->tp, ((out)->val));
  if ( !r )
    return 0;
  return 1;
}

canonical_original_code:
int node_process(struct node *n, struct node_conn *in, struct node_conn *out)
{
  int r;
  bitar_reset(((out)->val));
  bitar_reset(n->col_temp);
  bitar_reset(n->col_exp);
  bitar_scale(n->sq->expected, n->col_exp);
  spool(n->sp, ((in)->val), n->col_exp, n->col_temp);
  r = seqlearn(n->sq, n->col_temp, ((out)->val + 1), ((out)->val));
  if ( !r )
    return 0;
  r = tpool(n->tp, ((out)->val));
  if ( !r )
    return 0;
  return 1;
}

variable_types: struct node_conn { struct bitar val[2]; } *

variable_types:
out
struct node_conn *

variable_types: r int

user_defined_types: struct seqlearn { unsigned long columns_w; unsigned long output_w; struct fdr col2cur[1]; unsigned long col2cur_conns; struct synar prev2cur[1]; struct bitar col_prev[1]; struct bitar prev[1]; struct bitar expected[1]; }

user_defined_types: struct coinc_array { unsigned long col; unsigned long val; }


original_code:
void bytequeue_init(byteQueue_t * queue, uint8_t * dataArray, byteQueueIndex_t arrayLen){
   queue->length = arrayLen;
   queue->data = dataArray;
   queue->start = queue->end = 0;
}

canonical_original_code:
void bytequeue_init(struct byteQueue_t *queue, unsigned char *dataArray, unsigned char arrayLen){
   queue->length = arrayLen;
   queue->data = dataArray;
   queue->start = queue->end = 0;
}

variable_types: struct byteQueue_t { unsigned char start; unsigned char end; unsigned char length; unsigned char *data; } *

variable_types:
dataArray
unsigned char *

variable_types:
arrayLen
unsigned char


decompiled_code:
__int64 __fastcall bytequeue_enqueue(unsigned __int8 *a1, char a2)
{
unsigned __int8 v3; // di
unsigned __int8 v4; // cl
__int64 result; // rax

v3 = store_and_clear_interrupt();
v4 = a1[1];
if ( (v4 + 1) % a1[2] == *a1 )
{
restore_interrupt_setting(v3);
result = 0LL;
}
else
{
*(_BYTE *)(*((_QWORD *)a1 + 1) + v4) = a2;
a1[1] = (a1[1] + 1) % a1[2];
restore_interrupt_setting(v3);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, char a2)
{
unsigned __int8 v3; // di
unsigned __int8 v4; // cl
__int64 result; // rax

v3 = store_and_clear_interrupt();
v4 = a1[1];
if ( (v4 + 1) % a1[2] == *a1 )
{
restore_interrupt_setting(v3);
result = 0LL;
}
else
{
*(_BYTE *)(*((_QWORD *)a1 + 1) + v4) = a2;
a1[1] = (a1[1] + 1) % a1[2];
restore_interrupt_setting(v3);
result = 1LL;
}
return result;
}

original_code:
_Bool bytequeue_enqueue(byteQueue_t * queue, uint8_t item){
   interrupt_setting_t setting = store_and_clear_interrupt();
   if(((queue->end + 1) % queue->length) == queue->start){
      restore_interrupt_setting(setting);
      return 0;
   } else {
      queue->data[queue->end] = item;
      queue->end = (queue->end + 1) % queue->length;
      restore_interrupt_setting(setting);
      return 1;
   }
}

canonical_original_code:
_Bool bytequeue_enqueue(struct byteQueue_t *queue, unsigned char item){
   unsigned char setting = store_and_clear_interrupt();
   if(((queue->end + 1) % queue->length) == queue->start){
      restore_interrupt_setting(setting);
      return 0;
   } else {
      queue->data[queue->end] = item;
      queue->end = (queue->end + 1) % queue->length;
      restore_interrupt_setting(setting);
      return 1;
   }
}

variable_types:
item
unsigned char

variable_types:
setting
unsigned char

user_defined_types: struct byteQueue_t { unsigned char start; unsigned char end; unsigned char length; unsigned char *data; }


decompiled_code:
__int64 __fastcall bytequeue_length(unsigned __int8 *a1)
{
unsigned __int8 v2; // di
int v3; // eax
int v4; // edx
unsigned int v5; // ebx

v2 = store_and_clear_interrupt();
v3 = a1[1];
v4 = *a1;
if ( (unsigned __int8)v3 < (unsigned __int8)v4 )
LOBYTE(v3) = a1[2] + v3;
v5 = v3 - v4;
restore_interrupt_setting(v2);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1)
{
unsigned __int8 v2; // di
int v3; // eax
int v4; // edx
unsigned int v5; // ebx

v2 = store_and_clear_interrupt();
v3 = a1[1];
v4 = *a1;
if ( (unsigned __int8)v3 < (unsigned __int8)v4 )
LOBYTE(v3) = a1[2] + v3;
v5 = v3 - v4;
restore_interrupt_setting(v2);
return v5;
}

original_code:
byteQueueIndex_t bytequeue_length(byteQueue_t * queue){
   byteQueueIndex_t len;
   interrupt_setting_t setting = store_and_clear_interrupt();
   if(queue->end >= queue->start)
      len = queue->end - queue->start;
   else
      len = (queue->length - queue->start) + queue->end;
   restore_interrupt_setting(setting);
   return len;
}

canonical_original_code:
unsigned char bytequeue_length(struct byteQueue_t *queue){
   unsigned char len;
   unsigned char setting = store_and_clear_interrupt();
   if(queue->end >= queue->start)
      len = queue->end - queue->start;
   else
      len = (queue->length - queue->start) + queue->end;
   restore_interrupt_setting(setting);
   return len;
}

variable_types:
len
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall bytequeue_get(unsigned __int8 *a1, unsigned __int8 a2)
{
return *(unsigned __int8 *)(*((_QWORD *)a1 + 1) + (a2 + *a1) % a1[2]);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 *a1, unsigned __int8 a2)
{
return *(unsigned __int8 *)(*((_QWORD *)a1 + 1) + (a2 + *a1) % a1[2]);
}

original_code:
uint8_t bytequeue_get(byteQueue_t * queue, byteQueueIndex_t index){
   return queue->data[(queue->start + index) % queue->length];
}

canonical_original_code:
unsigned char bytequeue_get(struct byteQueue_t *queue, unsigned char index){
   return queue->data[(queue->start + index) % queue->length];
}

variable_types:
index
unsigned char


decompiled_code:
__int64 __fastcall bytequeue_remove(unsigned __int8 *a1, unsigned __int8 a2)
{
unsigned __int8 v2; // al

v2 = store_and_clear_interrupt();
*a1 = (a2 + *a1) % a1[2];
return restore_interrupt_setting(v2);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 *a1, unsigned __int8 a2)
{
unsigned __int8 v2; // al

v2 = store_and_clear_interrupt();
*a1 = (a2 + *a1) % a1[2];
return restore_interrupt_setting(v2);
}

original_code:
void bytequeue_remove(byteQueue_t * queue, byteQueueIndex_t numToRemove){
   interrupt_setting_t setting = store_and_clear_interrupt();
   queue->start = (queue->start + numToRemove) % queue->length;
   restore_interrupt_setting(setting);
}

canonical_original_code:
void bytequeue_remove(struct byteQueue_t *queue, unsigned char numToRemove){
   unsigned char setting = store_and_clear_interrupt();
   queue->start = (queue->start + numToRemove) % queue->length;
   restore_interrupt_setting(setting);
}

variable_types:
numToRemove
unsigned char


decompiled_code:
char __fastcall midi_is_statusbyte(unsigned __int8 a1)
{
return a1 >> 7;
}

canonical_decompiled_code:
char __fastcall func0(unsigned __int8 a1)
{
return a1 >> 7;
}

original_code:
_Bool midi_is_statusbyte(uint8_t theByte){
   return (_Bool)(theByte & 0x80);
}

canonical_original_code:
_Bool midi_is_statusbyte(unsigned char theByte){
   return (_Bool)(theByte & 0x80);
}

variable_types:
theByte
unsigned char


decompiled_code:
bool __fastcall midi_is_realtime(unsigned __int8 a1)
{
return a1 > 0xF7u;
}

canonical_decompiled_code:
bool __fastcall func1(unsigned __int8 a1)
{
return a1 > 0xF7u;
}

original_code:
_Bool midi_is_realtime(uint8_t theByte){
   return (theByte >= 0xF8);
}

canonical_original_code:
_Bool midi_is_realtime(unsigned char theByte){
   return (theByte >= 0xF8);
}


decompiled_code:
__int64 __fastcall midi_packet_length(char a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = a1 & 0xF0;
if ( (a1 & 0xF0) == 0xE0 )
return 3LL;
if ( (a1 & 0xF0u) > 0xE0 )
{
result = 0LL;
if ( v1 == 0xF0 )
{
if ( (unsigned __int8)a1 < 0xF1u )
{
LABEL_13:
result = 0LL;
}
else
{
switch ( a1 )
{
case -15:
case -13:
result = 2LL;
break;
case -14:
result = 3LL;
break;
case -12:
case -11:
case -9:
case -3:
goto LABEL_13;
case -10:
case -8:
case -7:
case -6:
case -5:
case -4:
case -2:
case -1:
result = 1LL;
break;
}
}
}
}
else if ( v1 > 0xB0u )
{
result = 2 * (unsigned int)((a1 & 0xE0) == 0xC0);
}
else
{
result = 0LL;
if ( a1 < 0 )
result = ((1LL << (v1 + 0x80)) & 0x1000100010001LL) != 0 ? 3 : 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = a1 & 0xF0;
if ( (a1 & 0xF0) == 0xE0 )
return 3LL;
if ( (a1 & 0xF0u) > 0xE0 )
{
result = 0LL;
if ( v1 == 0xF0 )
{
if ( (unsigned __int8)a1 < 0xF1u )
{
LABEL_13:
result = 0LL;
}
else
{
switch ( a1 )
{
case -15:
case -13:
result = 2LL;
break;
case -14:
result = 3LL;
break;
case -12:
case -11:
case -9:
case -3:
goto LABEL_13;
case -10:
case -8:
case -7:
case -6:
case -5:
case -4:
case -2:
case -1:
result = 1LL;
break;
}
}
}
}
else if ( v1 > 0xB0u )
{
result = 2 * (unsigned int)((a1 & 0xE0) == 0xC0);
}
else
{
result = 0LL;
if ( a1 < 0 )
result = ((1LL << (v1 + 0x80)) & 0x1000100010001LL) != 0 ? 3 : 0;
}
return result;
}

original_code:
midi_packet_length_t midi_packet_length(uint8_t status){
   switch(status & 0xF0){
      case 0xB0:
      case 0x90:
      case 0x80:
      case 0xA0:
      case 0xE0:
         return THREE;
      case 0xC0:
      case 0xD0:
      case 0xF3:
         return TWO;
      case 0xF0:
         switch(status) {
            case 0xF8:
            case 0xF9:
            case 0xFA:
            case 0xFB:
            case 0xFC:
            case 0xFE:
            case 0xFF:
            case 0xF6:
               return ONE;
            case 0xF2:
               return THREE;
            case 0xF1:
            case 0xF3:
               return TWO;
            case 0xF7:
            case 0xF0:
            default:
               return UNDEFINED;
         }
      default:
         return UNDEFINED;
   }
}

canonical_original_code:
enum midi_packet_length_t midi_packet_length(unsigned char status){
   switch(status & 0xF0){
      case 0xB0:
      case 0x90:
      case 0x80:
      case 0xA0:
      case 0xE0:
         return THREE;
      case 0xC0:
      case 0xD0:
      case 0xF3:
         return TWO;
      case 0xF0:
         switch(status) {
            case 0xF8:
            case 0xF9:
            case 0xFA:
            case 0xFB:
            case 0xFC:
            case 0xFE:
            case 0xFF:
            case 0xF6:
               return ONE;
            case 0xF2:
               return THREE;
            case 0xF1:
            case 0xF3:
               return TWO;
            case 0xF7:
            case 0xF0:
            default:
               return UNDEFINED;
         }
      default:
         return UNDEFINED;
   }
}

variable_types:
status
unsigned char

return_type: enum midi_packet_length_t { UNDEFINED=0, ONE=1, TWO=2, THREE=3 }


decompiled_code:
__int64 __fastcall midi_send_cc(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0xB0u, a3 & 0x7F, a4 & 0x7F);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0xB0u, a3 & 0x7F, a4 & 0x7F);
}

original_code:
void midi_send_cc(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t val){
   device->send_func(device, 3,
         0xB0 | (chan & 0x0F),
         num & 0x7F,
         val & 0x7F);
}

canonical_original_code:
void midi_send_cc(struct _midi_device *device, unsigned char chan, unsigned char num, unsigned char val){
   device->send_func(device, 3,
         0xB0 | (chan & 0x0F),
         num & 0x7F,
         val & 0x7F);
}

variable_types: struct _midi_device { void (*send_func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_cc_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteon_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteoff_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_aftertouch_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_pitchbend_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_songposition_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_progchange_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_chanpressure_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_songselect_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_tc_quarterframe_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_realtime_callback)(struct _midi_device *device, unsigned char byte); void (*input_tunerequest_callback)(struct _midi_device *device, unsigned char byte); void (*input_sysex_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_fallthrough_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_catchall_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*pre_input_process_callback)(struct _midi_device *device); unsigned char input_buffer[3]; enum input_state_t { IDLE=0, ONE_BYTE_MESSAGE=1, TWO_BYTE_MESSAGE=2, THREE_BYTE_MESSAGE=3, SYSEX_MESSAGE=4 } input_state; unsigned short input_count; unsigned char input_queue_data[192]; struct byteQueue_t { unsigned char start; unsigned char end; unsigned char length; unsigned char *data; } input_queue; } *

variable_types:
chan
unsigned char

variable_types:
num
unsigned char

variable_types:
val
unsigned char

user_defined_types: struct _midi_device { void (*send_func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_cc_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteon_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteoff_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_aftertouch_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_pitchbend_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_songposition_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_progchange_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_chanpressure_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_songselect_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_tc_quarterframe_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_realtime_callback)(struct _midi_device *device, unsigned char byte); void (*input_tunerequest_callback)(struct _midi_device *device, unsigned char byte); void (*input_sysex_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_fallthrough_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_catchall_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*pre_input_process_callback)(struct _midi_device *device); unsigned char input_buffer[3]; enum input_state_t input_state; unsigned short input_count; unsigned char input_queue_data[192]; struct byteQueue_t input_queue; }


decompiled_code:
__int64 __fastcall midi_send_noteon(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0x90u, a3 & 0x7F, a4 & 0x7F);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0x90u, a3 & 0x7F, a4 & 0x7F);
}

original_code:
void midi_send_noteon(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t vel){
   device->send_func(device, 3,
         0x90 | (chan & 0x0F),
         num & 0x7F,
         vel & 0x7F);
}

canonical_original_code:
void midi_send_noteon(struct _midi_device *device, unsigned char chan, unsigned char num, unsigned char vel){
   device->send_func(device, 3,
         0x90 | (chan & 0x0F),
         num & 0x7F,
         vel & 0x7F);
}

variable_types:
vel
unsigned char

user_defined_types: enum input_state_t { IDLE=0, ONE_BYTE_MESSAGE=1, TWO_BYTE_MESSAGE=2, THREE_BYTE_MESSAGE=3, SYSEX_MESSAGE=4 }


decompiled_code:
__int64 __fastcall midi_send_noteoff(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0x80u, a3 & 0x7F, a4 & 0x7F);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0x80u, a3 & 0x7F, a4 & 0x7F);
}

original_code:
void midi_send_noteoff(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t vel){
   device->send_func(device, 3,
         0x80 | (chan & 0x0F),
         num & 0x7F,
         vel & 0x7F);
}

canonical_original_code:
void midi_send_noteoff(struct _midi_device *device, unsigned char chan, unsigned char num, unsigned char vel){
   device->send_func(device, 3,
         0x80 | (chan & 0x0F),
         num & 0x7F,
         vel & 0x7F);
}


decompiled_code:
__int64 __fastcall midi_send_aftertouch(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0xA0u, a3 & 0x7F, a4 & 0x7F);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3, char a4)
{
return (*a1)(a1, 3LL, a2 & 0xF | 0xA0u, a3 & 0x7F, a4 & 0x7F);
}

original_code:
void midi_send_aftertouch(MidiDevice * device, uint8_t chan, uint8_t note_num, uint8_t amt){
   device->send_func(device, 3,
         0xA0 | (chan & 0x0F),
         note_num & 0x7F,
         amt & 0x7F);
}

canonical_original_code:
void midi_send_aftertouch(struct _midi_device *device, unsigned char chan, unsigned char note_num, unsigned char amt){
   device->send_func(device, 3,
         0xA0 | (chan & 0x0F),
         note_num & 0x7F,
         amt & 0x7F);
}

variable_types:
amt
unsigned char


decompiled_code:
__int64 __fastcall midi_send_pitchbend(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, __int16 a3)
{
return (*a1)(
a1,
3LL,
a2 & 0xF | 0xE0u,
((a3 + 0x8000) >> 2) & 0x7F,
(unsigned __int8)((unsigned __int16)((a3 + 0x8000) >> 2) >> 7));
}

original_code:
void midi_send_pitchbend(MidiDevice * device, uint8_t chan, int16_t amt){
   uint16_t uAmt;
   uAmt=(amt-(-32767-1))>>2;
   device->send_func(device, 3,
         0xE0 | (chan & 0x0F),
         uAmt & 0x7F,
         (uAmt >> 7) & 0x7F);
}

canonical_original_code:
void midi_send_pitchbend(struct _midi_device *device, unsigned char chan, short amt){
   unsigned short uAmt;
   uAmt=(amt-(-32767-1))>>2;
   device->send_func(device, 3,
         0xE0 | (chan & 0x0F),
         uAmt & 0x7F,
         (uAmt >> 7) & 0x7F);
}

variable_types: amt short

variable_types:
uAmt
unsigned short


decompiled_code:
__int64 __fastcall midi_send_programchange(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3)
{
return (*a1)(a1, 2LL, a2 & 0xF | 0xC0u, a3 & 0x7F, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3)
{
return (*a1)(a1, 2LL, a2 & 0xF | 0xC0u, a3 & 0x7F, 0LL);
}

original_code:
void midi_send_programchange(MidiDevice * device, uint8_t chan, uint8_t num){
   device->send_func(device, 2,
         0xC0 | (chan & 0x0F),
         num & 0x7F,
         0);
}

canonical_original_code:
void midi_send_programchange(struct _midi_device *device, unsigned char chan, unsigned char num){
   device->send_func(device, 2,
         0xC0 | (chan & 0x0F),
         num & 0x7F,
         0);
}


decompiled_code:
__int64 __fastcall midi_send_channelpressure(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3)
{
return (*a1)(a1, 2LL, a2 & 0xF | 0xD0u, a3 & 0x7F, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), char a2, char a3)
{
return (*a1)(a1, 2LL, a2 & 0xF | 0xD0u, a3 & 0x7F, 0LL);
}

original_code:
void midi_send_channelpressure(MidiDevice * device, uint8_t chan, uint8_t amt){
   device->send_func(device, 2,
         0xD0 | (chan & 0x0F),
         amt & 0x7F,
         0);
}

canonical_original_code:
void midi_send_channelpressure(struct _midi_device *device, unsigned char chan, unsigned char amt){
   device->send_func(device, 2,
         0xD0 | (chan & 0x0F),
         amt & 0x7F,
         0);
}


decompiled_code:
__int64 __fastcall midi_send_clock(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 248LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 248LL, 0LL, 0LL);
}

original_code:
void midi_send_clock(MidiDevice * device){
   device->send_func(device, 1, 0xF8, 0, 0);
}

canonical_original_code:
void midi_send_clock(struct _midi_device *device){
   device->send_func(device, 1, 0xF8, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_tick(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 249LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 249LL, 0LL, 0LL);
}

original_code:
void midi_send_tick(MidiDevice * device){
   device->send_func(device, 1, 0xF9, 0, 0);
}

canonical_original_code:
void midi_send_tick(struct _midi_device *device){
   device->send_func(device, 1, 0xF9, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_start(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 250LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 250LL, 0LL, 0LL);
}

original_code:
void midi_send_start(MidiDevice * device){
   device->send_func(device, 1, 0xFA, 0, 0);
}

canonical_original_code:
void midi_send_start(struct _midi_device *device){
   device->send_func(device, 1, 0xFA, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_continue(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 251LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 251LL, 0LL, 0LL);
}

original_code:
void midi_send_continue(MidiDevice * device){
   device->send_func(device, 1, 0xFB, 0, 0);
}

canonical_original_code:
void midi_send_continue(struct _midi_device *device){
   device->send_func(device, 1, 0xFB, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_stop(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 252LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 252LL, 0LL, 0LL);
}

original_code:
void midi_send_stop(MidiDevice * device){
   device->send_func(device, 1, 0xFC, 0, 0);
}

canonical_original_code:
void midi_send_stop(struct _midi_device *device){
   device->send_func(device, 1, 0xFC, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_activesense(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 254LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 254LL, 0LL, 0LL);
}

original_code:
void midi_send_activesense(MidiDevice * device){
   device->send_func(device, 1, 0xFE, 0, 0);
}

canonical_original_code:
void midi_send_activesense(struct _midi_device *device){
   device->send_func(device, 1, 0xFE, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_reset(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 255LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 255LL, 0LL, 0LL);
}

original_code:
void midi_send_reset(MidiDevice * device){
   device->send_func(device, 1, 0xFF, 0, 0);
}

canonical_original_code:
void midi_send_reset(struct _midi_device *device){
   device->send_func(device, 1, 0xFF, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_tcquarterframe(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), char a2)
{
return (*a1)(a1, 2LL, 241LL, a2 & 0x7F, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), char a2)
{
return (*a1)(a1, 2LL, 241LL, a2 & 0x7F, 0LL);
}

original_code:
void midi_send_tcquarterframe(MidiDevice * device, uint8_t time){
   device->send_func(device, 2,
         0xF1,
         time & 0x7F,
         0);
}

canonical_original_code:
void midi_send_tcquarterframe(struct _midi_device *device, unsigned char time){
   device->send_func(device, 2,
         0xF1,
         time & 0x7F,
         0);
}

variable_types:
time
unsigned char


decompiled_code:
__int64 __fastcall midi_send_songposition(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), unsigned __int16 a2)
{
return (*a1)(a1, 3LL, 242LL, a2 & 0x7F, (a2 >> 7) & 0x7F);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), unsigned __int16 a2)
{
return (*a1)(a1, 3LL, 242LL, a2 & 0x7F, (a2 >> 7) & 0x7F);
}

original_code:
void midi_send_songposition(MidiDevice * device, uint16_t pos){
   device->send_func(device, 3,
         0xF2,
         pos & 0x7F,
         (pos >> 7) & 0x7F);
}

canonical_original_code:
void midi_send_songposition(struct _midi_device *device, unsigned short pos){
   device->send_func(device, 3,
         0xF2,
         pos & 0x7F,
         (pos >> 7) & 0x7F);
}

variable_types:
pos
unsigned short


decompiled_code:
__int64 __fastcall midi_send_songselect(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), char a2)
{
return (*a1)(a1, 2LL, 243LL, a2 & 0x7F, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD), char a2)
{
return (*a1)(a1, 2LL, 243LL, a2 & 0x7F, 0LL);
}

original_code:
void midi_send_songselect(MidiDevice * device, uint8_t song){
   device->send_func(device, 2,
         0xF3,
         song & 0x7F,
         0);
}

canonical_original_code:
void midi_send_songselect(struct _midi_device *device, unsigned char song){
   device->send_func(device, 2,
         0xF3,
         song & 0x7F,
         0);
}

variable_types:
song
unsigned char


decompiled_code:
__int64 __fastcall midi_send_tunerequest(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 246LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 (__fastcall **a1)(_QWORD, __int64, __int64, _QWORD, _QWORD))
{
return (*a1)(a1, 1LL, 246LL, 0LL, 0LL);
}

original_code:
void midi_send_tunerequest(MidiDevice * device){
   device->send_func(device, 1, 0xF6, 0, 0);
}

canonical_original_code:
void midi_send_tunerequest(struct _midi_device *device){
   device->send_func(device, 1, 0xF6, 0, 0);
}


decompiled_code:
__int64 __fastcall midi_send_byte(__int64 (__fastcall **a1)(_QWORD, __int64, _QWORD, _QWORD, _QWORD), unsigned __int8 a2)
{
return (*a1)(a1, 1LL, a2, 0LL, 0LL);
}

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

original_code:
void midi_send_byte(MidiDevice * device, uint8_t b){
   device->send_func(device, 1, b, 0, 0);
}

canonical_original_code:
void midi_send_byte(struct _midi_device *device, unsigned char b){
   device->send_func(device, 1, b, 0, 0);
}

variable_types:
b
unsigned char


decompiled_code:
__int64 __fastcall midi_send_data(__int64 (__fastcall **a1)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD), unsigned __int16 a2, unsigned __int8 a3, unsigned __int8 a4, unsigned __int8 a5)
{
return (*a1)(a1, a2, a3, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 (__fastcall **a1)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD), unsigned __int16 a2, unsigned __int8 a3, unsigned __int8 a4, unsigned __int8 a5)
{
return (*a1)(a1, a2, a3, a4, a5);
}

original_code:
void midi_send_data(MidiDevice * device, uint16_t count, uint8_t byte0, uint8_t byte1, uint8_t byte2){
   if (count > 3) {
   }
   device->send_func(device, count, byte0, byte1, byte2);
}

canonical_original_code:
void midi_send_data(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2){
   if (count > 3) {
   }
   device->send_func(device, count, byte0, byte1, byte2);
}

variable_types:
count
unsigned short


decompiled_code:
void __fastcall midi_send_array(__int64 (__fastcall **a1)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD), unsigned __int16 a2, __int64 a3)
{
unsigned __int16 i; // bx
unsigned __int16 v6; // si
unsigned int j; // eax
__int16 v8; // [rsp+1h] [rbp-2Bh]
unsigned __int8 v9; // [rsp+3h] [rbp-29h]

if ( a2 )
{
for ( i = 0; i < a2; i += 3 )
{
v8 = 0;
v9 = 0;
v6 = a2 - i;
if ( (unsigned __int16)(a2 - i) > 3u )
v6 = 3;
if ( v6 )
{
for ( j = 0; j < v6; ++j )
*((_BYTE *)&v8 + j) = *(_BYTE *)(a3 + j);
}
midi_send_data(a1, v6, v8, HIBYTE(v8), v9);
a3 += 3LL;
}
}
}

canonical_decompiled_code:
void __fastcall func23(__int64 (__fastcall **a1)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD), unsigned __int16 a2, __int64 a3)
{
unsigned __int16 i; // bx
unsigned __int16 v6; // si
unsigned int j; // eax
__int16 v8; // [rsp+1h] [rbp-2Bh]
unsigned __int8 v9; // [rsp+3h] [rbp-29h]

if ( a2 )
{
for ( i = 0; i < a2; i += 3 )
{
v8 = 0;
v9 = 0;
v6 = a2 - i;
if ( (unsigned __int16)(a2 - i) > 3u )
v6 = 3;
if ( v6 )
{
for ( j = 0; j < v6; ++j )
*((_BYTE *)&v8 + j) = *(_BYTE *)(a3 + j);
}
func22(a1, v6, v8, HIBYTE(v8), v9);
a3 += 3LL;
}
}
}

original_code:
void midi_send_array(MidiDevice * device, uint16_t count, uint8_t * array) {
  uint16_t i;
  for (i = 0; i < count; i += 3) {
    uint8_t b[3] = { 0, 0, 0 };
    uint16_t to_send = count - i;
    to_send = (to_send > 3) ? 3 : to_send;
    memcpy(b, array + i, to_send);
    midi_send_data(device, to_send, b[0], b[1], b[2]);
  }
}

canonical_original_code:
void midi_send_array(struct _midi_device *device, unsigned short count, unsigned char *array) {
  unsigned short i;
  for (i = 0; i < count; i += 3) {
    unsigned char b[3] = { 0, 0, 0 };
    unsigned short to_send = count - i;
    to_send = (to_send > 3) ? 3 : to_send;
    memcpy(b, array + i, to_send);
    midi_send_data(device, to_send, b[0], b[1], b[2]);
  }
}

variable_types:
array
unsigned char *

variable_types:
i
unsigned short

variable_types:
b
unsigned char [3]


decompiled_code:
void __fastcall midi_register_cc_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void midi_register_cc_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_cc_callback = func;
}

canonical_original_code:
void midi_register_cc_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_cc_callback = func;
}

variable_types: void (*)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)


decompiled_code:
void __fastcall midi_register_noteon_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 16) = a2;
}

original_code:
void midi_register_noteon_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_noteon_callback = func;
}

canonical_original_code:
void midi_register_noteon_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_noteon_callback = func;
}

variable_types: struct _midi_device { void (*send_func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_cc_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteon_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_noteoff_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_aftertouch_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_pitchbend_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_songposition_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_progchange_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_chanpressure_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_songselect_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_tc_quarterframe_callback)(struct _midi_device *device, unsigned char byte0, unsigned char byte1); void (*input_realtime_callback)(struct _midi_device *device, unsigned char byte); void (*input_tunerequest_callback)(struct _midi_device *device, unsigned char byte); void (*input_sysex_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_fallthrough_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*input_catchall_callback)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2); void (*pre_input_process_callback)(struct _midi_device *device); unsigned char input_buffer[3]; enum input_state_t { IDLE=0, ONE_BYTE_MESSAGE=1, TWO_BYTE_MESSAGE=2, THREE_BYTE_MESSAGE=3, SYSEX_MESSAGE=4 } input_state; unsigned short input_count; unsigned char input_queue_data[192]; struct byteQueue_t { unsigned char start; unsigned char end; unsigned char length; unsigned char *data; } input_queue; } *


decompiled_code:
void __fastcall midi_register_noteoff_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 24) = a2;
}

original_code:
void midi_register_noteoff_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_noteoff_callback = func;
}

canonical_original_code:
void midi_register_noteoff_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_noteoff_callback = func;
}


decompiled_code:
void __fastcall midi_register_aftertouch_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 32) = a2;
}

original_code:
void midi_register_aftertouch_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_aftertouch_callback = func;
}

canonical_original_code:
void midi_register_aftertouch_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_aftertouch_callback = func;
}


decompiled_code:
void __fastcall midi_register_pitchbend_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 40) = a2;
}

original_code:
void midi_register_pitchbend_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_pitchbend_callback = func;
}

canonical_original_code:
void midi_register_pitchbend_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_pitchbend_callback = func;
}


decompiled_code:
void __fastcall midi_register_songposition_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 48) = a2;
}

original_code:
void midi_register_songposition_callback(MidiDevice * device, midi_three_byte_func_t func){
   device->input_songposition_callback = func;
}

canonical_original_code:
void midi_register_songposition_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_songposition_callback = func;
}


decompiled_code:
void __fastcall midi_register_progchange_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 56) = a2;
}

original_code:
void midi_register_progchange_callback(MidiDevice * device, midi_two_byte_func_t func) {
   device->input_progchange_callback = func;
}

canonical_original_code:
void midi_register_progchange_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1)) {
   device->input_progchange_callback = func;
}

variable_types: void (*)(struct _midi_device *device, unsigned char byte0, unsigned char byte1)


decompiled_code:
void __fastcall midi_register_chanpressure_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 64) = a2;
}

original_code:
void midi_register_chanpressure_callback(MidiDevice * device, midi_two_byte_func_t func) {
   device->input_chanpressure_callback = func;
}

canonical_original_code:
void midi_register_chanpressure_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1)) {
   device->input_chanpressure_callback = func;
}


decompiled_code:
void __fastcall midi_register_songselect_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 72) = a2;
}

original_code:
void midi_register_songselect_callback(MidiDevice * device, midi_two_byte_func_t func) {
   device->input_songselect_callback = func;
}

canonical_original_code:
void midi_register_songselect_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1)) {
   device->input_songselect_callback = func;
}


decompiled_code:
void __fastcall midi_register_tc_quarterframe_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 80) = a2;
}

original_code:
void midi_register_tc_quarterframe_callback(MidiDevice * device, midi_two_byte_func_t func) {
   device->input_tc_quarterframe_callback = func;
}

canonical_original_code:
void midi_register_tc_quarterframe_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte0, unsigned char byte1)) {
   device->input_tc_quarterframe_callback = func;
}


decompiled_code:
void __fastcall midi_register_realtime_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 88) = a2;
}

original_code:
void midi_register_realtime_callback(MidiDevice * device, midi_one_byte_func_t func){
   device->input_realtime_callback = func;
}

canonical_original_code:
void midi_register_realtime_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte)){
   device->input_realtime_callback = func;
}

variable_types: void (*)(struct _midi_device *device, unsigned char byte)


decompiled_code:
void __fastcall midi_register_tunerequest_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 96) = a2;
}

original_code:
void midi_register_tunerequest_callback(MidiDevice * device, midi_one_byte_func_t func){
   device->input_tunerequest_callback = func;
}

canonical_original_code:
void midi_register_tunerequest_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned char byte)){
   device->input_tunerequest_callback = func;
}


decompiled_code:
void __fastcall midi_register_sysex_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 104) = a2;
}

original_code:
void midi_register_sysex_callback(MidiDevice * device, midi_var_byte_func_t func){
   device->input_sysex_callback = func;
}

canonical_original_code:
void midi_register_sysex_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_sysex_callback = func;
}

variable_types: void (*)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2)


decompiled_code:
void __fastcall midi_register_fallthrough_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 112) = a2;
}

original_code:
void midi_register_fallthrough_callback(MidiDevice * device, midi_var_byte_func_t func){
   device->input_fallthrough_callback = func;
}

canonical_original_code:
void midi_register_fallthrough_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_fallthrough_callback = func;
}


decompiled_code:
void __fastcall midi_register_catchall_callback(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 120) = a2;
}

original_code:
void midi_register_catchall_callback(MidiDevice * device, midi_var_byte_func_t func){
   device->input_catchall_callback = func;
}

canonical_original_code:
void midi_register_catchall_callback(struct _midi_device *device, void (*func)(struct _midi_device *device, unsigned short count, unsigned char byte0, unsigned char byte1, unsigned char byte2)){
   device->input_catchall_callback = func;
}


updatePot

decompiled_code:
__int64 __fastcall updatePot(int a1)
{
int v1; // er15
int v2; // er14
int v3; // ebp
int v4; // ebx
int v5; // er12
char v6; // dl
int v7; // eax
__int16 v8; // bx
__int64 result; // rax

io_write(10LL, (32 >> (a1 >> 4)) | a1 & 0xFu);
v1 = 0xFFFF >> (16 - potBitDepth[a1]) << (16 - potBitDepth[a1]);
v2 = (unsigned __int8)potBitDepth[a1];
v3 = -32768;
v4 = -1;
v5 = 0;
do
{
dac_write((unsigned __int16)v4);
v6 = io_read(9LL);
v7 = v4 + v3;
v4 -= v3;
if ( (v6 & 8) != 0 )
v4 = v7;
LOWORD(v3) = (unsigned __int16)v3 >> 1;
++v5;
}
while ( (char)v5 <= v2 );
io_write(10LL, 255LL);
v8 = v1 & v4;
word_224[a1] = v8;
result = abs32((unsigned __int8)byte_204[a1] - HIBYTE(v8));
if ( (int)result > 4 )
{
byte_204[a1] = HIBYTE(v8);
result = (unsigned int)(1 << a1);
potmux |= result;
dword_268 = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // er15
int v2; // er14
int v3; // ebp
int v4; // ebx
int v5; // er12
char v6; // dl
int v7; // eax
__int16 v8; // bx
__int64 result; // rax

io_write(10LL, (32 >> (a1 >> 4)) | a1 & 0xFu);
v1 = 0xFFFF >> (16 - potBitDepth[a1]) << (16 - potBitDepth[a1]);
v2 = (unsigned __int8)potBitDepth[a1];
v3 = -32768;
v4 = -1;
v5 = 0;
do
{
dac_write((unsigned __int16)v4);
v6 = io_read(9LL);
v7 = v4 + v3;
v4 -= v3;
if ( (v6 & 8) != 0 )
v4 = v7;
LOWORD(v3) = (unsigned __int16)v3 >> 1;
++v5;
}
while ( (char)v5 <= v2 );
io_write(10LL, 255LL);
v8 = v1 & v4;
word_224[a1] = v8;
result = abs32((unsigned __int8)byte_204[a1] - HIBYTE(v8));
if ( (int)result > 4 )
{
byte_204[a1] = HIBYTE(v8);
result = (unsigned int)(1 << a1);
potmux |= result;
dword_268 = a1;
}
return result;
}

original_code:
static void updatePot(p600Pot_t pot)
{
 int8_t i,lower;
 uint8_t mux,bitDepth,cdv;
 uint16_t estimate,badMask;
 uint16_t bit;

 {
  mux=(pot&0x0f)|(0x20>>(pot>>4));
  io_write(0x0a,mux);
  ;
  estimate=(65535);
  bit=0x8000;
  bitDepth=potBitDepth[pot];
  badMask=16-bitDepth;
  badMask=((65535)>>badMask)<<badMask;
  for(i=0;i<=bitDepth;++i)
  {
   dac_write(estimate);
   ;
   lower=(io_read(0x09)&0x08)!=0;
   if (lower)
    estimate+=bit;
   else
    estimate-=bit;
   bit>>=1;
  }
  io_write(0x0a,0xff);
  ;
  estimate&=badMask;
  potmux.pots[pot]=estimate;
  cdv=estimate>>8;
  if(abs(potmux.changeDetect[pot]-cdv)>4)
  {
   potmux.changeDetect[pot]=cdv;
   potmux.potChanged|=(uint32_t)1<<pot;
   potmux.lastChanged=pot;
  }
 }
}

canonical_original_code:
static void updatePot(enum p600Pot_t pot)
{
 char i; char lower;
 unsigned char mux; unsigned char bitDepth; unsigned char cdv;
 unsigned short estimate; unsigned short badMask;
 unsigned short bit;

 {
  mux=(pot&0x0f)|(0x20>>(pot>>4));
  io_write(0x0a,mux);
  ;
  estimate=(65535);
  bit=0x8000;
  bitDepth=potBitDepth[pot];
  badMask=16-bitDepth;
  badMask=((65535)>>badMask)<<badMask;
  for(i=0;i<=bitDepth;++i)
  {
   dac_write(estimate);
   ;
   lower=(io_read(0x09)&0x08)!=0;
   if (lower)
    estimate+=bit;
   else
    estimate-=bit;
   bit>>=1;
  }
  io_write(0x0a,0xff);
  ;
  estimate&=badMask;
  potmux.pots[pot]=estimate;
  cdv=estimate>>8;
  if(abs(potmux.changeDetect[pot]-cdv)>4)
  {
   potmux.changeDetect[pot]=cdv;
   potmux.potChanged|=(unsigned int)1<<pot;
   potmux.lastChanged=pot;
  }
 }
}

variable_types: enum p600Pot_t { ppNone=-1, ppMixer=0, ppCutoff=1, ppResonance=2, ppFilEnvAmt=3, ppFilRel=4, ppFilSus=5, ppFilDec=6, ppFilAtt=7, ppAmpRel=8, ppAmpSus=9, ppAmpDec=10, ppAmpAtt=11, ppGlide=12, ppBPW=13, ppMVol=14, ppMTune=15, ppPitchWheel=16, ppModWheel=22, ppSpeed=23, ppAPW=24, ppPModFilEnv=25, ppLFOFreq=26, ppPModOscB=27, ppLFOAmt=28, ppFreqB=29, ppFreqA=30, ppFreqBFine=31 }

variable_types: i char

variable_types: lower char

variable_types:
mux
unsigned char

variable_types:
bitDepth
unsigned char

variable_types:
cdv
unsigned char

variable_types:
estimate
unsigned short

variable_types:
badMask
unsigned short

variable_types:
bit
unsigned short


decompiled_code:
__int64 __fastcall potmux_getValue(int a1)
{
return (unsigned __int16)word_224[a1];
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return (unsigned __int16)word_224[a1];
}

original_code:
inline __attribute__((always_inline)) uint16_t potmux_getValue(p600Pot_t pot)
{
 return potmux.pots[pot];
}

canonical_original_code:
inline unsigned short potmux_getValue(enum p600Pot_t pot)
{
 return potmux.pots[pot];
}

return_type: unsigned short

user_defined_types: enum p600Pot_t { ppNone=-1, ppMixer=0, ppCutoff=1, ppResonance=2, ppFilEnvAmt=3, ppFilRel=4, ppFilSus=5, ppFilDec=6, ppFilAtt=7, ppAmpRel=8, ppAmpSus=9, ppAmpDec=10, ppAmpAtt=11, ppGlide=12, ppBPW=13, ppMVol=14, ppMTune=15, ppPitchWheel=16, ppModWheel=22, ppSpeed=23, ppAPW=24, ppPModFilEnv=25, ppLFOFreq=26, ppPModOscB=27, ppLFOAmt=28, ppFreqB=29, ppFreqA=30, ppFreqBFine=31 }


decompiled_code:
bool __fastcall potmux_hasChanged(char a1)
{
return (potmux & (1 << a1)) != 0;
}

canonical_decompiled_code:
bool __fastcall func2(char a1)
{
return (potmux & (1 << a1)) != 0;
}

original_code:
inline __attribute__((always_inline)) int8_t potmux_hasChanged(p600Pot_t pot)
{
 return (potmux.potChanged&((uint32_t)1<<pot))!=0;
}

canonical_original_code:
inline char potmux_hasChanged(enum p600Pot_t pot)
{
 return (potmux.potChanged&((unsigned int)1<<pot))!=0;
}

return_type: char


decompiled_code:
__int64 potmux_lastChanged()
{
return (unsigned int)dword_268;
}

canonical_decompiled_code:
__int64 func3()
{
return (unsigned int)dword_268;
}

original_code:
inline __attribute__((always_inline)) p600Pot_t potmux_lastChanged(void)
{
 return potmux.lastChanged;
}

canonical_original_code:
inline enum p600Pot_t potmux_lastChanged()
{
 return potmux.lastChanged;
}

return_type: enum p600Pot_t { ppNone=-1, ppMixer=0, ppCutoff=1, ppResonance=2, ppFilEnvAmt=3, ppFilRel=4, ppFilSus=5, ppFilDec=6, ppFilAtt=7, ppAmpRel=8, ppAmpSus=9, ppAmpDec=10, ppAmpAtt=11, ppGlide=12, ppBPW=13, ppMVol=14, ppMTune=15, ppPitchWheel=16, ppModWheel=22, ppSpeed=23, ppAPW=24, ppPModFilEnv=25, ppLFOFreq=26, ppPModOscB=27, ppLFOAmt=28, ppFreqB=29, ppFreqA=30, ppFreqBFine=31 }


decompiled_code:
void potmux_resetChanged()
{
potmux = 0;
dword_268 = -1;
}

canonical_decompiled_code:
void func4()
{
potmux = 0;
dword_268 = -1;
}

original_code:
inline __attribute__((always_inline)) void potmux_resetChanged(void)
{
 potmux.potChanged=0;
 potmux.lastChanged=ppNone;
}

canonical_original_code:
inline void potmux_resetChanged()
{
 potmux.potChanged=0;
 potmux.lastChanged=ppNone;
}


decompiled_code:
__int64 __fastcall potmux_isPotZeroCentered(unsigned int a1)
{
int v1; // eax

v1 = 1;
if ( a1 <= 0x1F )
v1 = ((unsigned __int8)(0x82018008uLL >> a1) ^ 1) & 1;
return v1 ^ 1u;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
int v1; // eax

v1 = 1;
if ( a1 <= 0x1F )
v1 = ((unsigned __int8)(0x82018008uLL >> a1) ^ 1) & 1;
return v1 ^ 1u;
}

original_code:
int8_t potmux_isPotZeroCentered(p600Pot_t pot)
{
 return pot==ppFilEnvAmt || pot==ppPModFilEnv || pot==ppFreqBFine || pot==ppMTune || pot==ppPitchWheel;
}

canonical_original_code:
char potmux_isPotZeroCentered(enum p600Pot_t pot)
{
 return pot==ppFilEnvAmt || pot==ppPModFilEnv || pot==ppFreqBFine || pot==ppMTune || pot==ppPitchWheel;
}


decompiled_code:
__int64 __fastcall potmux_update(unsigned __int8 a1)
{
int v1; // ebp
char v2; // al
int v3; // edx

if ( a1 )
{
v1 = 0;
do
{
updatePot(*((char *)&potmux + 100));
v2 = *((_BYTE *)&potmux + 100);
LOBYTE(v3) = 22;
if ( v2 != 16 )
v3 = (v2 + 1) % 32;
*((_BYTE *)&potmux + 100) = v3;
++v1;
}
while ( (__int16)v1 < (int)a1 );
}
updatePot(1);
updatePot(16);
updatePot(30);
return updatePot(29);
}

original_code:
inline void potmux_update(uint8_t regularPotCount)
{
 int16_t i;
 for(i=0;i<regularPotCount;++i)
 {
  updatePot(potmux.currentRegularPot);
  if(potmux.currentRegularPot==ppPitchWheel)
   potmux.currentRegularPot=ppModWheel;
  else
   potmux.currentRegularPot=(potmux.currentRegularPot+1)%32;
 }
 for(i=0;i<4;++i)
  updatePot(priorityPots[i]);
}

canonical_original_code:
inline void potmux_update(unsigned char regularPotCount)
{
 short i;
 for(i=0;i<regularPotCount;++i)
 {
  updatePot(potmux.currentRegularPot);
  if(potmux.currentRegularPot==ppPitchWheel)
   potmux.currentRegularPot=ppModWheel;
  else
   potmux.currentRegularPot=(potmux.currentRegularPot+1)%32;
 }
 for(i=0;i<4;++i)
  updatePot(priorityPots[i]);
}

variable_types:
regularPotCount
unsigned char

variable_types: i short


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

result = 0LL;
memset(&potmux, 0, 0x68uLL);
dword_268 = -1;
return result;
}

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

result = 0LL;
memset(&potmux, 0, 0x68uLL);
dword_268 = -1;
return result;
}

original_code:
void potmux_init(void)
{
 memset(&potmux,0,sizeof(potmux));
 potmux.lastChanged=ppNone;
}

canonical_original_code:
void potmux_init()
{
 memset(&potmux,0,sizeof(potmux));
 potmux.lastChanged=ppNone;
}


decompiled_code:
__int64 __fastcall satAddU16U16(int a1, int a2)
{
int v2; // edx
unsigned int v3; // esi
__int64 result; // rax

v2 = (unsigned __int16)a2;
v3 = a1 + a2;
result = 0xFFFFFFFFLL;
if ( v2 <= (unsigned __int16)~(_WORD)a1 )
result = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
int v2; // edx
unsigned int v3; // esi
__int64 result; // rax

v2 = (unsigned __int16)a2;
v3 = a1 + a2;
result = 0xFFFFFFFFLL;
if ( v2 <= (unsigned __int16)~(_WORD)a1 )
result = v3;
return result;
}

original_code:
inline uint16_t satAddU16U16(uint16_t a, uint16_t b)
{
 uint16_t r;
 r = (b > (65535) - a) ? (65535) : b + a;
 return r;
}

canonical_original_code:
inline unsigned short satAddU16U16(unsigned short a, unsigned short b)
{
 unsigned short r;
 r = (b > (65535) - a) ? (65535) : b + a;
 return r;
}

variable_types:
a
unsigned short

variable_types:
b
unsigned short

variable_types:
r
unsigned short


decompiled_code:
__int64 __fastcall satAddU16S32(unsigned __int16 a1, int a2)
{
int v2; // edi
__int64 result; // rax

v2 = a2 + a1;
if ( v2 < 0 )
v2 = 0;
result = 0xFFFFLL;
if ( v2 <= 0xFFFF )
result = (unsigned int)v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int16 a1, int a2)
{
int v2; // edi
__int64 result; // rax

v2 = a2 + a1;
if ( v2 < 0 )
v2 = 0;
result = 0xFFFFLL;
if ( v2 <= 0xFFFF )
result = (unsigned int)v2;
return result;
}

canonical_original_code:
inline unsigned short satAddU16S32(unsigned short a, int b)
{
 int r;
 r=a;
 r+=b;
 r=(((r)>(0))?(r):(0));
 r=(((r)<((65535)))?(r):((65535)));
 return (unsigned short)r;
}

variable_types: b int

variable_types: r int


decompiled_code:
__int64 __fastcall satAddU16S16(unsigned __int16 a1, __int16 a2)
{
bool v2; // sf
unsigned int v3; // esi
__int64 result; // rax

v2 = a1 + a2 < 0;
v3 = a1 + a2;
result = 0LL;
if ( !v2 )
result = v3;
if ( (int)result > 0xFFFF )
result = 0xFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int16 a1, __int16 a2)
{
bool v2; // sf
unsigned int v3; // esi
__int64 result; // rax

v2 = a1 + a2 < 0;
v3 = a1 + a2;
result = 0LL;
if ( !v2 )
result = v3;
if ( (int)result > 0xFFFF )
result = 0xFFFFLL;
return result;
}

canonical_original_code:
inline unsigned short satAddU16S16(unsigned short a, short b)
{
 int r;
 r=a;
 r+=b;
 r=(((r)>(0))?(r):(0));
 r=(((r)<((65535)))?(r):((65535)));
 return r;
}

variable_types: b short


lerp

decompiled_code:
__int64 __fastcall lerp(int a1, unsigned __int16 a2, unsigned __int8 a3)
{
return ((a2 - (unsigned __int16)a1) >> 8) * (unsigned int)a3 + a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, unsigned __int16 a2, unsigned __int8 a3)
{
return ((a2 - (unsigned __int16)a1) >> 8) * (unsigned int)a3 + a1;
}

original_code:
inline uint16_t lerp(uint16_t a,uint16_t b,uint8_t x)
{
 return a+(x*((b-a)>>8));
}

canonical_original_code:
inline unsigned short lerp(unsigned short a, unsigned short b, unsigned char x)
{
 return a+(x*((b-a)>>8));
}

variable_types:
x
unsigned char


computeShape

decompiled_code:
__int64 __fastcall computeShape(unsigned int a1, __int64 a2, char a3)
{
__int64 result; // rax

if ( a3 )
result = lerp(
*(unsigned __int16 *)(a2 + 2LL * BYTE2(a1)),
*(_WORD *)(a2 + 2LL * (unsigned __int8)(BYTE2(a1) + (BYTE2(a1) != 0xFF))),
BYTE1(a1));
else
result = *(unsigned __int16 *)(a2 + 2LL * HIWORD(a1));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, __int64 a2, char a3)
{
__int64 result; // rax

if ( a3 )
result = func3(
*(unsigned __int16 *)(a2 + 2LL * BYTE2(a1)),
*(_WORD *)(a2 + 2LL * (unsigned __int8)(BYTE2(a1) + (BYTE2(a1) != 0xFF))),
BYTE1(a1));
else
result = *(unsigned __int16 *)(a2 + 2LL * HIWORD(a1));
return result;
}

original_code:
inline uint16_t computeShape(uint32_t phase, const uint16_t lookup[], int8_t interpolate)
{
 uint8_t ai,bi,x;
 uint16_t a,b;
 if(interpolate)
 {
  x=phase>>8;
  bi=ai=phase>>16;
  if(ai<(255))
   bi=ai+1;
  a=lookup[ai];
  b=lookup[bi];
  return lerp(a,b,x);
 }
 else
 {
  return lookup[phase>>16];
 }
}

canonical_original_code:
inline unsigned short computeShape(unsigned int phase, unsigned short lookup[], char interpolate)
{
 unsigned char ai; unsigned char bi; unsigned char x;
 unsigned short a; unsigned short b;
 if(interpolate)
 {
  x=phase>>8;
  bi=ai=phase>>16;
  if(ai<(255))
   bi=ai+1;
  a=lookup[ai];
  b=lookup[bi];
  return lerp(a,b,x);
 }
 else
 {
  return lookup[phase>>16];
 }
}

variable_types:
phase
unsigned int

variable_types:
lookup
unsigned short []

variable_types: interpolate char

variable_types:
ai
unsigned char

variable_types:
bi
unsigned char


decompiled_code:
__int64 __fastcall scaleU16U16(unsigned __int16 a1, unsigned __int16 a2)
{
return (a2 * (unsigned int)a1) >> 16;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int16 a1, unsigned __int16 a2)
{
return (a2 * (unsigned int)a1) >> 16;
}

original_code:
inline uint16_t scaleU16U16(uint16_t a, uint16_t b)
{
 uint16_t r;
 r=((uint32_t)a*b)>>16;
 return r;
}

canonical_original_code:
inline unsigned short scaleU16U16(unsigned short a, unsigned short b)
{
 unsigned short r;
 r=((unsigned int)a*b)>>16;
 return r;
}


decompiled_code:
__int64 __fastcall scaleU16S16(unsigned __int16 a1, __int16 a2)
{
return (unsigned int)((a2 * a1) >> 16);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int16 a1, __int16 a2)
{
return (unsigned int)((a2 * a1) >> 16);
}

original_code:
inline int16_t scaleU16S16(uint16_t a, int16_t b)
{
 uint16_t r;
 r=((int32_t)a*b)>>16;
 return r;
}

canonical_original_code:
inline short scaleU16S16(unsigned short a, short b)
{
 unsigned short r;
 r=((int)a*b)>>16;
 return r;
}

return_type: short


lfsr

decompiled_code:
__int64 __fastcall lfsr(unsigned int a1, int a2)
{
__int64 result; // rax
int v3; // ecx

result = a1;
v3 = a2 - 1;
if ( (_BYTE)a2 )
{
do
{
result = (2 * (_DWORD)result) | ((BYTE3(result) >> 1) ^ BYTE3(result) ^ ((int)result < 0) ^ ((unsigned int)result >> 29)) & 1;
--v3;
}
while ( (_BYTE)v3 != 0xFF );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, int a2)
{
__int64 result; // rax
int v3; // ecx

result = a1;
v3 = a2 - 1;
if ( (_BYTE)a2 )
{
do
{
result = (2 * (_DWORD)result) | ((BYTE3(result) >> 1) ^ BYTE3(result) ^ ((int)result < 0) ^ ((unsigned int)result >> 29)) & 1;
--v3;
}
while ( (_BYTE)v3 != 0xFF );
}
return result;
}

canonical_original_code:
inline unsigned int lfsr(unsigned int v, unsigned char taps)
{
 unsigned char b24;
 while(taps--)
 {
  b24=v>>24;
  v<<=1;
  v|=((b24>>7)^(b24>>5)^(b24>>1)^b24)&1;
 }
 return v;
}

variable_types:
v
unsigned int

variable_types:
taps
unsigned char

return_type: unsigned int


exponentialCourse

decompiled_code:
__int64 __fastcall exponentialCourse(unsigned __int16 a1, float a2, float a3)
{
return (unsigned int)(int)(float)(expf(COERCE_FLOAT(COERCE_UNSIGNED_INT((float)a1) ^ LC0) / a2) * a3);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int16 a1, float a2, float a3)
{
return (unsigned int)(int)(float)(expf(COERCE_FLOAT(COERCE_UNSIGNED_INT((float)a1) ^ LC0) / a2) * a3);
}

original_code:
uint16_t exponentialCourse(uint16_t v, float ratio, float range)
{
 return expf(-(float)v/ratio)*range;
}

canonical_original_code:
unsigned short exponentialCourse(unsigned short v, float ratio, float range)
{
 return expf(-(float)v/ratio)*range;
}

variable_types:
v
unsigned short

variable_types: ratio float

variable_types: range float


decompiled_code:
__int64 __fastcall uint16Compare(_WORD *a1, _WORD *a2)
{
__int64 result; // rax

result = 0LL;
if ( *a1 != *a2 )
result = *a1 < *a2 ? -1 : 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_WORD *a1, _WORD *a2)
{
__int64 result; // rax

result = 0LL;
if ( *a1 != *a2 )
result = *a1 < *a2 ? -1 : 1;
return result;
}

original_code:
int uint16Compare(const void * a,const void * b)
{
 if (*(uint16_t*)a==*(uint16_t*)b)
  return 0;
 else if (*(uint16_t*)a < *(uint16_t*)b)
  return -1;
 else
  return 1;
}

canonical_original_code:
int uint16Compare(void *a, void *b)
{
 if (*(unsigned short *)a==*(unsigned short *)b)
  return 0;
 else if (*(unsigned short *)a < *(unsigned short *)b)
  return -1;
 else
  return 1;
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 storageRead32()
{
unsigned int v0; // edx

v0 = *(_DWORD *)qword_C40;
qword_C40 += 4LL;
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // edx

v0 = *(_DWORD *)qword_C40;
qword_C40 += 4LL;
return v0;
}

original_code:
static uint32_t storageRead32(void)
{
 uint32_t v;
 v=*(uint32_t*)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

canonical_original_code:
static unsigned int storageRead32()
{
 unsigned int v;
 v=*(unsigned int *)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}


decompiled_code:
__int64 storageRead16()
{
unsigned int v0; // edx

v0 = *(unsigned __int16 *)qword_C40;
qword_C40 += 2LL;
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // edx

v0 = *(unsigned __int16 *)qword_C40;
qword_C40 += 2LL;
return v0;
}

original_code:
static uint16_t storageRead16(void)
{
 uint16_t v;
 v=*(uint16_t*)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

canonical_original_code:
static unsigned short storageRead16()
{
 unsigned short v;
 v=*(unsigned short *)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}


decompiled_code:
__int64 storageRead8()
{
return *(unsigned __int8 *)qword_C40++;
}

canonical_decompiled_code:
__int64 func2()
{
return *(unsigned __int8 *)qword_C40++;
}

original_code:
static uint8_t storageRead8(void)
{
 uint8_t v;
 v=*(uint8_t*)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

canonical_original_code:
static unsigned char storageRead8()
{
 unsigned char v;
 v=*(unsigned char *)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

variable_types:
v
unsigned char


decompiled_code:
__int64 storageReadS8()
{
return *(unsigned __int8 *)qword_C40++;
}

canonical_decompiled_code:
__int64 func3()
{
return *(unsigned __int8 *)qword_C40++;
}

original_code:
static int8_t storageReadS8(void)
{
 int8_t v;
 v=*(int8_t*)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

canonical_original_code:
static char storageReadS8()
{
 char v;
 v=*(char *)storage.bufPtr;
 storage.bufPtr+=sizeof(v);
 return v;
}

variable_types: v char


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

result = qword_C40;
*(_WORD *)qword_C40 = a1;
qword_C40 += 2LL;
return result;
}

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

result = qword_C40;
*(_WORD *)qword_C40 = a1;
qword_C40 += 2LL;
return result;
}

original_code:
static void storageWrite16(uint16_t v)
{
 *(uint16_t*)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}

canonical_original_code:
static void storageWrite16(unsigned short v)
{
 *(unsigned short *)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}


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

result = qword_C40;
*(_BYTE *)qword_C40++ = a1;
return result;
}

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

result = qword_C40;
*(_BYTE *)qword_C40++ = a1;
return result;
}

original_code:
static void storageWrite8(uint8_t v)
{
 *(uint8_t*)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}

canonical_original_code:
static void storageWrite8(unsigned char v)
{
 *(unsigned char *)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}


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

result = qword_C40;
*(_BYTE *)qword_C40++ = a1;
return result;
}

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

result = qword_C40;
*(_BYTE *)qword_C40++ = a1;
return result;
}

original_code:
static void storageWriteS8(int8_t v)
{
 *(int8_t*)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}

canonical_original_code:
static void storageWriteS8(char v)
{
 *(char *)storage.bufPtr=v;
 storage.bufPtr+=sizeof(v);
}


storagePrepareStore

decompiled_code:
__int64 storagePrepareStore()
{
memset(&storage, 0, 0x200uLL);
qword_C40 = (__int64)&storage;
byte_C48 = 7;
storageWrite32(6362789);
return storageWrite8(byte_C48);
}

canonical_decompiled_code:
__int64 func9()
{
memset(&storage, 0, 0x200uLL);
qword_C40 = (__int64)&storage;
byte_C48 = 7;
func4(6362789);
return func6(byte_C48);
}

original_code:
static void storagePrepareStore(void)
{
 memset(storage.buffer,0,sizeof(storage.buffer));
 storage.bufPtr=storage.buffer;
 storage.version=7;
 storageWrite32(0x006116a5);
 storageWrite8(storage.version);
}

canonical_original_code:
static void storagePrepareStore()
{
 memset(storage.buffer,0,sizeof(storage.buffer));
 storage.bufPtr=storage.buffer;
 storage.version=7;
 storageWrite32(0x006116a5);
 storageWrite8(storage.version);
}


decompiled_code:
__int64 settings_load()
{
__int64 result; // rax
unsigned __int64 v1; // rbp
_WORD *v2; // rbx

result = storageLoad(0xDCu, 2u);
if ( (_BYTE)result )
{
*((_BYTE *)&settings + 295) = 63;
*((_BYTE *)&settings + 297) = 0;
*((_BYTE *)&settings + 298) = 0;
*((_WORD *)&settings + 150) = 0x8000;
result = 1LL;
if ( byte_C48 )
{
v1 = (unsigned int)((_DWORD)&settings + 36);
do
{
v2 = (_WORD *)(v1 - 36);
do
*v2++ = storageRead16();
while ( v2 != (_WORD *)v1 );
v1 += 36LL;
}
while ( v1 != (_DWORD)&settings + 324 );
*((_WORD *)&settings + 145) = storageRead16();
*((_WORD *)&settings + 144) = storageRead16();
*((_BYTE *)&settings + 292) = storageRead8();
*((_BYTE *)&settings + 293) = storageReadS8();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 1u )
{
*((_BYTE *)&settings + 295) = storageRead8();
*((_BYTE *)&settings + 294) = storageReadS8();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 2u )
{
*((_BYTE *)&settings + 296) = storageRead8();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 3u )
{
*((_BYTE *)&settings + 297) = storageReadS8();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 4u )
{
*((_BYTE *)&settings + 298) = storageReadS8();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 5u )
{
*((_WORD *)&settings + 150) = storageRead16();
result = 1LL;
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
unsigned __int64 v1; // rbp
_WORD *v2; // rbx

result = func8(0xDCu, 2u);
if ( (_BYTE)result )
{
*((_BYTE *)&settings + 295) = 63;
*((_BYTE *)&settings + 297) = 0;
*((_BYTE *)&settings + 298) = 0;
*((_WORD *)&settings + 150) = 0x8000;
result = 1LL;
if ( byte_C48 )
{
v1 = (unsigned int)((_DWORD)&settings + 36);
do
{
v2 = (_WORD *)(v1 - 36);
do
*v2++ = func1();
while ( v2 != (_WORD *)v1 );
v1 += 36LL;
}
while ( v1 != (_DWORD)&settings + 324 );
*((_WORD *)&settings + 145) = func1();
*((_WORD *)&settings + 144) = func1();
*((_BYTE *)&settings + 292) = func2();
*((_BYTE *)&settings + 293) = func3();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 1u )
{
*((_BYTE *)&settings + 295) = func2();
*((_BYTE *)&settings + 294) = func3();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 2u )
{
*((_BYTE *)&settings + 296) = func2();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 3u )
{
*((_BYTE *)&settings + 297) = func3();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 4u )
{
*((_BYTE *)&settings + 298) = func3();
result = 1LL;
if ( (unsigned __int8)byte_C48 > 5u )
{
*((_WORD *)&settings + 150) = func1();
result = 1LL;
}
}
}
}
}
}
}
return result;
}

original_code:
int8_t settings_load(void)
{
 int8_t i,j;

 {
  if (!storageLoad(((0xe000UL/256UL)-4),2))
   return 0;
  settings.voiceMask=0x3f;
  settings.spread=0;
  settings.vcfLimit=0;
  settings.seqArpClock=((65535)/2+1);
  if (storage.version<1)
   return 1;
  for(j=0;j<8;++j)
   for(i=0;i<(pcFil6-pcOsc1A+1);++i)
    settings.tunes[j][i]=storageRead16();
  settings.presetNumber=storageRead16();
  settings.benderMiddle=storageRead16();
  settings.presetMode=storageRead8();
  settings.midiReceiveChannel=storageReadS8();
  if (storage.version<2)
   return 1;
  settings.voiceMask=storageRead8();
  settings.midiSendChannel=storageReadS8();
  if (storage.version<3)
   return 1;
  settings.syncMode=storageRead8();
  if (storage.version<4)
   return 1;
  settings.spread=storageReadS8();
  if (storage.version<5)
   return 1;
  settings.vcfLimit=storageReadS8();
  if (storage.version<6)
   return 1;
  settings.seqArpClock=storageRead16();
  if (storage.version<7)
   return 1;
 }
 return 1;
}

canonical_original_code:
char settings_load()
{
 char i; char j;

 {
  if (!storageLoad(((0xe000UL/256UL)-4),2))
   return 0;
  settings.voiceMask=0x3f;
  settings.spread=0;
  settings.vcfLimit=0;
  settings.seqArpClock=((65535)/2+1);
  if (storage.version<1)
   return 1;
  for(j=0;j<8;++j)
   for(i=0;i<(pcFil6-pcOsc1A+1);++i)
    settings.tunes[j][i]=storageRead16();
  settings.presetNumber=storageRead16();
  settings.benderMiddle=storageRead16();
  settings.presetMode=storageRead8();
  settings.midiReceiveChannel=storageReadS8();
  if (storage.version<2)
   return 1;
  settings.voiceMask=storageRead8();
  settings.midiSendChannel=storageReadS8();
  if (storage.version<3)
   return 1;
  settings.syncMode=storageRead8();
  if (storage.version<4)
   return 1;
  settings.spread=storageReadS8();
  if (storage.version<5)
   return 1;
  settings.vcfLimit=storageReadS8();
  if (storage.version<6)
   return 1;
  settings.seqArpClock=storageRead16();
  if (storage.version<7)
   return 1;
 }
 return 1;
}

variable_types: i char

variable_types: j char


decompiled_code:
__int64 settings_save()
{
__int16 *v0; // rbp
__int16 *v1; // rbx
__int16 v2; // ax

storagePrepareStore();
v0 = (__int16 *)(unsigned int)((_DWORD)&settings + 36);
do
{
v1 = v0 - 18;
do
storageWrite16(*v1++);
while ( v1 != v0 );
v0 += 18;
}
while ( v0 != (__int16 *)(unsigned int)((_DWORD)&settings + 324) );
storageWrite16(*((_WORD *)&settings + 145));
storageWrite16(*((_WORD *)&settings + 144));
storageWrite8(*((_BYTE *)&settings + 292));
storageWriteS8(*((_BYTE *)&settings + 293));
storageWrite8(*((_BYTE *)&settings + 295));
storageWriteS8(*((_BYTE *)&settings + 294));
storageWrite8(*((_BYTE *)&settings + 296));
storageWriteS8(*((_BYTE *)&settings + 297));
storageWriteS8(*((_BYTE *)&settings + 298));
v2 = *(&currentPreset + 42);
*((_WORD *)&settings + 150) = v2;
storageWrite16(v2);
return storageFinishStore(0xDCu, 2u);
}

canonical_decompiled_code:
__int64 func12()
{
__int16 *v0; // rbp
__int16 *v1; // rbx
__int16 v2; // ax

func9();
v0 = (__int16 *)(unsigned int)((_DWORD)&settings + 36);
do
{
v1 = v0 - 18;
do
func5(*v1++);
while ( v1 != v0 );
v0 += 18;
}
while ( v0 != (__int16 *)(unsigned int)((_DWORD)&settings + 324) );
func5(*((_WORD *)&settings + 145));
func5(*((_WORD *)&settings + 144));
func6(*((_BYTE *)&settings + 292));
func7(*((_BYTE *)&settings + 293));
func6(*((_BYTE *)&settings + 295));
func7(*((_BYTE *)&settings + 294));
func6(*((_BYTE *)&settings + 296));
func7(*((_BYTE *)&settings + 297));
func7(*((_BYTE *)&settings + 298));
v2 = *(&currentPreset + 42);
*((_WORD *)&settings + 150) = v2;
func5(v2);
return func10(0xDCu, 2u);
}

original_code:
void settings_save(void)
{
 int8_t i,j;

 {
  storagePrepareStore();
  for(j=0;j<8;++j)
   for(i=0;i<(pcFil6-pcOsc1A+1);++i)
    storageWrite16(settings.tunes[j][i]);
  storageWrite16(settings.presetNumber);
  storageWrite16(settings.benderMiddle);
  storageWrite8(settings.presetMode);
  storageWriteS8(settings.midiReceiveChannel);
  storageWrite8(settings.voiceMask);
  storageWriteS8(settings.midiSendChannel);
  storageWrite8(settings.syncMode);
  storageWriteS8(settings.spread);
  storageWriteS8(settings.vcfLimit);
  settings.seqArpClock=currentPreset.continuousParameters[cpSeqArpClock];
  storageWrite16(settings.seqArpClock);
  storageFinishStore(((0xe000UL/256UL)-4),2);
 }
}

canonical_original_code:
void settings_save()
{
 char i; char j;

 {
  storagePrepareStore();
  for(j=0;j<8;++j)
   for(i=0;i<(pcFil6-pcOsc1A+1);++i)
    storageWrite16(settings.tunes[j][i]);
  storageWrite16(settings.presetNumber);
  storageWrite16(settings.benderMiddle);
  storageWrite8(settings.presetMode);
  storageWriteS8(settings.midiReceiveChannel);
  storageWrite8(settings.voiceMask);
  storageWriteS8(settings.midiSendChannel);
  storageWrite8(settings.syncMode);
  storageWriteS8(settings.spread);
  storageWriteS8(settings.vcfLimit);
  settings.seqArpClock=currentPreset.continuousParameters[cpSeqArpClock];
  storageWrite16(settings.seqArpClock);
  storageFinishStore(((0xe000UL/256UL)-4),2);
 }
}


decompiled_code:
__int64 __fastcall preset_saveCurrent(unsigned __int16 a1)
{
__int16 *v1; // rbx
char *v2; // rbx
__int64 i; // rbx
char *v4; // rbx
__int16 *v5; // rbx

storagePrepareStore();
v1 = (__int16 *)(unsigned int)((_DWORD)currentPreset + 26);
do
storageWrite16(*v1++);
while ( v1 != (__int16 *)(unsigned int)((_DWORD)currentPreset + 76) );
LOBYTE(currentPreset[8]) = HIBYTE(currentPreset[12]);
v2 = (char *)currentPreset;
do
storageWrite8(*v2++);
while ( v2 != (char *)(unsigned int)((_DWORD)currentPreset + 23) );
for ( i = 0LL; i != 5; ++i )
storageWrite16(currentPreset[i + 38]);
storageWrite8(HIBYTE(currentPreset[11]));
storageWrite8(currentPreset[12]);
v4 = (char *)(unsigned int)((_DWORD)currentPreset + 86);
do
storageWrite8(*v4++);
while ( v4 != (char *)(unsigned int)((_DWORD)currentPreset + 92) );
settings[150] = currentPreset[42];
v5 = (__int16 *)(unsigned int)((_DWORD)currentPreset + 92);
do
storageWrite16(*v5++);
while ( (__int16 *)(unsigned int)((_DWORD)currentPreset + 116) != v5 );
return storageFinishStore(a1, 1u);
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned __int16 a1)
{
__int16 *v1; // rbx
char *v2; // rbx
__int64 i; // rbx
char *v4; // rbx
__int16 *v5; // rbx

func9();
v1 = (__int16 *)(unsigned int)((_DWORD)currentPreset + 26);
do
func5(*v1++);
while ( v1 != (__int16 *)(unsigned int)((_DWORD)currentPreset + 76) );
LOBYTE(currentPreset[8]) = HIBYTE(currentPreset[12]);
v2 = (char *)currentPreset;
do
func6(*v2++);
while ( v2 != (char *)(unsigned int)((_DWORD)currentPreset + 23) );
for ( i = 0LL; i != 5; ++i )
func5(currentPreset[i + 38]);
func6(HIBYTE(currentPreset[11]));
func6(currentPreset[12]);
v4 = (char *)(unsigned int)((_DWORD)currentPreset + 86);
do
func6(*v4++);
while ( v4 != (char *)(unsigned int)((_DWORD)currentPreset + 92) );
settings[150] = currentPreset[42];
v5 = (__int16 *)(unsigned int)((_DWORD)currentPreset + 92);
do
func5(*v5++);
while ( (__int16 *)(unsigned int)((_DWORD)currentPreset + 116) != v5 );
return func10(a1, 1u);
}

original_code:
void preset_saveCurrent(uint16_t number)
{
 uint8_t i;

 {
  storagePrepareStore();
  continuousParameter_t cp;
  for(cp=cpFreqA;cp<=cpFilVelocity;++cp)
   storageWrite16(currentPreset.continuousParameters[cp]);
  currentPreset.steppedParameters[holdPedal]=currentPreset.steppedParameters[spAmpEnvSlow];
  steppedParameter_t sp;
  for(sp=spASaw;sp<=spChromaticPitch;++sp)
   storageWrite8(currentPreset.steppedParameters[sp]);
  for(cp=cpModDelay;cp<=cpSeqArpClock;++cp)
   storageWrite16(currentPreset.continuousParameters[cp]);
  for(sp=spModwheelTarget;sp<=spVibTarget;++sp)
   storageWrite8(currentPreset.steppedParameters[sp]);
  for(i=0;i<6;++i)
   storageWrite8(currentPreset.voicePattern[i]);
  settings.seqArpClock=currentPreset.continuousParameters[cpSeqArpClock];
  for (i=0; i<12; i++)
   storageWrite16(currentPreset.perNoteTuning[i]);
  storageFinishStore(number,1);
 }
}

canonical_original_code:
void preset_saveCurrent(unsigned short number)
{
 unsigned char i;

 {
  storagePrepareStore();
  enum continuousParameter_t cp;
  for(cp=cpFreqA;cp<=cpFilVelocity;++cp)
   storageWrite16(currentPreset.continuousParameters[cp]);
  currentPreset.steppedParameters[holdPedal]=currentPreset.steppedParameters[spAmpEnvSlow];
  enum steppedParameter_t sp;
  for(sp=spASaw;sp<=spChromaticPitch;++sp)
   storageWrite8(currentPreset.steppedParameters[sp]);
  for(cp=cpModDelay;cp<=cpSeqArpClock;++cp)
   storageWrite16(currentPreset.continuousParameters[cp]);
  for(sp=spModwheelTarget;sp<=spVibTarget;++sp)
   storageWrite8(currentPreset.steppedParameters[sp]);
  for(i=0;i<6;++i)
   storageWrite8(currentPreset.voicePattern[i]);
  settings.seqArpClock=currentPreset.continuousParameters[cpSeqArpClock];
  for (i=0; i<12; i++)
   storageWrite16(currentPreset.perNoteTuning[i]);
  storageFinishStore(number,1);
 }
}

variable_types:
number
unsigned short

variable_types:
i
unsigned char

variable_types: enum continuousParameter_t { cpFreqA=0, cpVolA=1, cpAPW=2, cpFreqB=3, cpVolB=4, cpBPW=5, cpFreqBFine=6, cpCutoff=7, cpResonance=8, cpFilEnvAmt=9, cpFilRel=10, cpFilSus=11, cpFilDec=12, cpFilAtt=13, cpAmpRel=14, cpAmpSus=15, cpAmpDec=16, cpAmpAtt=17, cpPModFilEnv=18, cpPModOscB=19, cpLFOFreq=20, cpLFOAmt=21, cpGlide=22, cpAmpVelocity=23, cpFilVelocity=24, cpModDelay=25, cpVibFreq=26, cpVibAmt=27, cpUnisonDetune=28, cpSeqArpClock=29, cpCount=30 }

variable_types: enum steppedParameter_t { spASaw=0, spATri=1, spASqr=2, spBSaw=3, spBTri=4, spBSqr=5, spSync=6, spPModFA=7, spPModFil=8, spLFOShape=9, spLFOShift=10, spLFOTargets=11, spTrackingShift=12, spFilEnvExpo=13, spFilEnvSlow=14, spAmpEnvExpo=15, holdPedal=16, spUnison=17, spAssignerPriority=18, spBenderSemitones=19, spBenderTarget=20, spModwheelShift=21, spChromaticPitch=22, spModwheelTarget=23, spVibTarget=24, spAmpEnvSlow=25, spCount=26 }


decompiled_code:
__int64 __fastcall storage_loadSequencer(char a1, _BYTE *a2, char a3)
{
_BYTE *v3; // rbx
__int64 result; // rax
__int64 v6; // rbp

v3 = a2;
result = storageLoad(a1 + 200, 1u);
if ( (_BYTE)result )
{
if ( a3 )
{
v6 = (__int64)&a2[(unsigned __int8)(a3 - 1) + 1];
do
*v3++ = storageRead8();
while ( (_BYTE *)v6 != v3 );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(char a1, _BYTE *a2, char a3)
{
_BYTE *v3; // rbx
__int64 result; // rax
__int64 v6; // rbp

v3 = a2;
result = func8(a1 + 200, 1u);
if ( (_BYTE)result )
{
if ( a3 )
{
v6 = (__int64)&a2[(unsigned __int8)(a3 - 1) + 1];
do
*v3++ = func2();
while ( (_BYTE *)v6 != v3 );
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int8_t storage_loadSequencer(int8_t track, uint8_t * data, uint8_t size)
{

 {
  if (!storageLoad(200 +track,1))
   return 0;
  while(size--)
   *data++=storageRead8();
 }
 return 1;
}

canonical_original_code:
char storage_loadSequencer(char track, unsigned char *data, unsigned char size)
{

 {
  if (!storageLoad(200 +track,1))
   return 0;
  while(size--)
   *data++=storageRead8();
 }
 return 1;
}

variable_types: track char

variable_types:
data
unsigned char *

variable_types:
size
unsigned char


decompiled_code:
__int64 __fastcall storage_saveSequencer(char a1, char *a2, char a3)
{
char *v3; // rbx
__int64 v5; // r12

v3 = a2;
storagePrepareStore();
if ( a3 )
{
v5 = (__int64)&a2[(unsigned __int8)(a3 - 1) + 1];
do
storageWrite8(*v3++);
while ( v3 != (char *)v5 );
}
return storageFinishStore(a1 + 200, 1u);
}

original_code:
void storage_saveSequencer(int8_t track, uint8_t * data, uint8_t size)
{

 {
  storagePrepareStore();
  while(size--)
   storageWrite8(*data++);
  storageFinishStore(200 +track,1);
 }
}

canonical_original_code:
void storage_saveSequencer(char track, unsigned char *data, unsigned char size)
{

 {
  storagePrepareStore();
  while(size--)
   storageWrite8(*data++);
  storageFinishStore(200 +track,1);
 }
}


decompiled_code:
__int64 __fastcall storage_import(unsigned __int16 a1, const void *a2, __int16 a3)
{
__int64 v3; // rbx

memset(storage, 0, 0x200uLL);
v3 = a3;
memcpy(storage, a2, a3);
qword_C40 = (__int64)&storage[v3];
return storageFinishStore(a1, 1u);
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned __int16 a1, const void *a2, __int16 a3)
{
__int64 v3; // rbx

memset(storage, 0, 0x200uLL);
v3 = a3;
memcpy(storage, a2, a3);
qword_C40 = (__int64)&storage[v3];
return func10(a1, 1u);
}

original_code:
void storage_import(uint16_t number, uint8_t * buf, int16_t size)
{

 {
  memset(storage.buffer,0,sizeof(storage.buffer));
  memcpy(storage.buffer,buf,size);
  storage.bufPtr=storage.buffer+size;
  storageFinishStore(number,1);
 }
}

canonical_original_code:
void storage_import(unsigned short number, unsigned char *buf, short size)
{

 {
  memset(storage.buffer,0,sizeof(storage.buffer));
  memcpy(storage.buffer,buf,size);
  storage.bufPtr=storage.buffer+size;
  storageFinishStore(number,1);
 }
}

variable_types:
buf
unsigned char *

variable_types: size short


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

result = 0LL;
memset(currentPreset, 0, 0x70uLL);
*(_DWORD *)&currentPreset[56] = 0;
currentPreset[15] = 0x8000;
currentPreset[18] = 0x8000;
currentPreset[20] = -1;
currentPreset[22] = 0x8000;
currentPreset[28] = -1;
currentPreset[14] = -1;
currentPreset[36] = 0x8000;
currentPreset[42] = 0x8000;
currentPreset[39] = 0x8000;
HIBYTE(currentPreset[9]) = 5;
LOBYTE(currentPreset[10]) = 1;
HIBYTE(currentPreset[6]) = 1;
HIBYTE(currentPreset[7]) = 1;
HIBYTE(currentPreset[10]) = 1;
LOBYTE(currentPreset[11]) = 2;
*(_DWORD *)&currentPreset[43] = -1;
currentPreset[45] = -1;
do
{
currentPreset[result + 46] = (int)((double)(int)result * 5461.3333333);
++result;
}
while ( result != 12 );
if ( a1 )
LOBYTE(currentPreset[0]) = 1;
return result;
}

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

result = 0LL;
memset(currentPreset, 0, 0x70uLL);
*(_DWORD *)&currentPreset[56] = 0;
currentPreset[15] = 0x8000;
currentPreset[18] = 0x8000;
currentPreset[20] = -1;
currentPreset[22] = 0x8000;
currentPreset[28] = -1;
currentPreset[14] = -1;
currentPreset[36] = 0x8000;
currentPreset[42] = 0x8000;
currentPreset[39] = 0x8000;
HIBYTE(currentPreset[9]) = 5;
LOBYTE(currentPreset[10]) = 1;
HIBYTE(currentPreset[6]) = 1;
HIBYTE(currentPreset[7]) = 1;
HIBYTE(currentPreset[10]) = 1;
LOBYTE(currentPreset[11]) = 2;
*(_DWORD *)&currentPreset[43] = -1;
currentPreset[45] = -1;
do
{
currentPreset[result + 46] = (int)((double)(int)result * 5461.3333333);
++result;
}
while ( result != 12 );
if ( a1 )
LOBYTE(currentPreset[0]) = 1;
return result;
}

original_code:
void preset_loadDefault(int8_t makeSound)
{
 uint8_t i;

 {
  memset(&currentPreset,0,sizeof(currentPreset));
  currentPreset.continuousParameters[cpAPW]=((65535)/2+1);
  currentPreset.continuousParameters[cpBPW]=((65535)/2+1);
  currentPreset.continuousParameters[cpCutoff]=(65535);
  currentPreset.continuousParameters[cpFilEnvAmt]=((65535)/2+1);
  currentPreset.continuousParameters[cpAmpSus]=(65535);
  currentPreset.continuousParameters[cpVolA]=(65535);
  currentPreset.continuousParameters[cpAmpVelocity]=((65535)/2+1);
  currentPreset.continuousParameters[cpSeqArpClock]=((65535)/2+1);
  currentPreset.continuousParameters[cpVibFreq]=((65535)/2+1);
  currentPreset.steppedParameters[spBenderSemitones]=5;
  currentPreset.steppedParameters[spBenderTarget]=modVCO;
  currentPreset.steppedParameters[spFilEnvExpo]=1;
  currentPreset.steppedParameters[spAmpEnvExpo]=1;
  currentPreset.steppedParameters[spModwheelShift]=1;
  currentPreset.steppedParameters[spChromaticPitch]=2;
  memset(currentPreset.voicePattern,(255),sizeof(currentPreset.voicePattern));
  for (i=0; i<12; i++)
   currentPreset.perNoteTuning[i] = i * 5461.3333333;
  if(makeSound)
   currentPreset.steppedParameters[spASaw]=1;
 }
}

canonical_original_code:
void preset_loadDefault(char makeSound)
{
 unsigned char i;

 {
  memset(&currentPreset,0,sizeof(currentPreset));
  currentPreset.continuousParameters[cpAPW]=((65535)/2+1);
  currentPreset.continuousParameters[cpBPW]=((65535)/2+1);
  currentPreset.continuousParameters[cpCutoff]=(65535);
  currentPreset.continuousParameters[cpFilEnvAmt]=((65535)/2+1);
  currentPreset.continuousParameters[cpAmpSus]=(65535);
  currentPreset.continuousParameters[cpVolA]=(65535);
  currentPreset.continuousParameters[cpAmpVelocity]=((65535)/2+1);
  currentPreset.continuousParameters[cpSeqArpClock]=((65535)/2+1);
  currentPreset.continuousParameters[cpVibFreq]=((65535)/2+1);
  currentPreset.steppedParameters[spBenderSemitones]=5;
  currentPreset.steppedParameters[spBenderTarget]=modVCO;
  currentPreset.steppedParameters[spFilEnvExpo]=1;
  currentPreset.steppedParameters[spAmpEnvExpo]=1;
  currentPreset.steppedParameters[spModwheelShift]=1;
  currentPreset.steppedParameters[spChromaticPitch]=2;
  memset(currentPreset.voicePattern,(255),sizeof(currentPreset.voicePattern));
  for (i=0; i<12; i++)
   currentPreset.perNoteTuning[i] = i * 5461.3333333;
  if(makeSound)
   currentPreset.steppedParameters[spASaw]=1;
 }
}

variable_types: makeSound char


decompiled_code:
__int64 __fastcall preset_loadCurrent(unsigned __int16 a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbx
__int16 *v3; // rbx
__int64 i; // rbx
unsigned __int64 v5; // rbx
unsigned __int64 v6; // rbx

result = storageLoad(a1, 1u);
if ( (_BYTE)result )
{
preset_loadDefault(0);
LOBYTE(currentPreset[43]) = 0;
HIBYTE(currentPreset[43]) = -1;
LOBYTE(currentPreset[44]) = -1;
HIBYTE(currentPreset[44]) = -1;
LOBYTE(currentPreset[45]) = -1;
HIBYTE(currentPreset[45]) = -1;
result = 1LL;
if ( byte_C48 )
{
v2 = (unsigned int)((_DWORD)currentPreset + 26);
do
{
*(_WORD *)v2 = storageRead16();
v2 += 2LL;
}
while ( v2 != (_DWORD)currentPreset + 76 );
v3 = currentPreset;
do
{
*(_BYTE *)v3 = storageRead8();
v3 = (__int16 *)((char *)v3 + 1);
}
while ( v3 != (__int16 *)(unsigned int)((_DWORD)currentPreset + 23) );
HIBYTE(currentPreset[12]) = currentPreset[8];
result = 1LL;
if ( (unsigned __int8)byte_C48 > 1u )
{
for ( i = 0LL; i != 5; ++i )
currentPreset[i + 38] = storageRead16();
HIBYTE(currentPreset[11]) = storageRead8();
LOBYTE(currentPreset[12]) = storageRead8();
v5 = (unsigned int)((_DWORD)currentPreset + 86);
do
*(_BYTE *)v5++ = storageRead8();
while ( (_DWORD)currentPreset + 92 != v5 );
currentPreset[42] = settings[150];
result = 1LL;
if ( (unsigned __int8)byte_C48 > 6u )
{
v6 = (unsigned int)((_DWORD)currentPreset + 92);
do
{
*(_WORD *)v6 = storageRead16();
v6 += 2LL;
}
while ( v6 != (_DWORD)currentPreset + 116 );
result = 1LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned __int16 a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbx
__int16 *v3; // rbx
__int64 i; // rbx
unsigned __int64 v5; // rbx
unsigned __int64 v6; // rbx

result = func8(a1, 1u);
if ( (_BYTE)result )
{
func18(0);
LOBYTE(currentPreset[43]) = 0;
HIBYTE(currentPreset[43]) = -1;
LOBYTE(currentPreset[44]) = -1;
HIBYTE(currentPreset[44]) = -1;
LOBYTE(currentPreset[45]) = -1;
HIBYTE(currentPreset[45]) = -1;
result = 1LL;
if ( byte_C48 )
{
v2 = (unsigned int)((_DWORD)currentPreset + 26);
do
{
*(_WORD *)v2 = func1();
v2 += 2LL;
}
while ( v2 != (_DWORD)currentPreset + 76 );
v3 = currentPreset;
do
{
*(_BYTE *)v3 = func2();
v3 = (__int16 *)((char *)v3 + 1);
}
while ( v3 != (__int16 *)(unsigned int)((_DWORD)currentPreset + 23) );
HIBYTE(currentPreset[12]) = currentPreset[8];
result = 1LL;
if ( (unsigned __int8)byte_C48 > 1u )
{
for ( i = 0LL; i != 5; ++i )
currentPreset[i + 38] = func1();
HIBYTE(currentPreset[11]) = func2();
LOBYTE(currentPreset[12]) = func2();
v5 = (unsigned int)((_DWORD)currentPreset + 86);
do
*(_BYTE *)v5++ = func2();
while ( (_DWORD)currentPreset + 92 != v5 );
currentPreset[42] = settings[150];
result = 1LL;
if ( (unsigned __int8)byte_C48 > 6u )
{
v6 = (unsigned int)((_DWORD)currentPreset + 92);
do
{
*(_WORD *)v6 = func1();
v6 += 2LL;
}
while ( v6 != (_DWORD)currentPreset + 116 );
result = 1LL;
}
}
}
}
return result;
}

original_code:
int8_t preset_loadCurrent(uint16_t number)
{
 uint8_t i;

 {
  if(!storageLoad(number,1))
   return 0;
  preset_loadDefault(0);
  for(i=0;i<6;++i)
   currentPreset.voicePattern[i]=(i==0)?0:(255);
  if (storage.version<1)
   return 1;
  continuousParameter_t cp;
  for(cp=cpFreqA;cp<=cpFilVelocity;++cp)
   currentPreset.continuousParameters[cp]=storageRead16();
  steppedParameter_t sp;
  for(sp=spASaw;sp<=spChromaticPitch;++sp)
   currentPreset.steppedParameters[sp]=storageRead8();
  currentPreset.steppedParameters[spAmpEnvSlow]=currentPreset.steppedParameters[holdPedal];
  if (storage.version<2)
   return 1;
  for(cp=cpModDelay;cp<=cpSeqArpClock;++cp)
   currentPreset.continuousParameters[cp]=storageRead16();
  for(sp=spModwheelTarget;sp<=spVibTarget;++sp)
   currentPreset.steppedParameters[sp]=storageRead8();
  for(i=0;i<6;++i)
   currentPreset.voicePattern[i]=storageRead8();
  currentPreset.continuousParameters[cpSeqArpClock]=settings.seqArpClock;
  if (storage.version<7)
   return 1;
  for (i=0; i<12; i++)
   currentPreset.perNoteTuning[i]=storageRead16();
 }
 return 1;
}

canonical_original_code:
char preset_loadCurrent(unsigned short number)
{
 unsigned char i;

 {
  if(!storageLoad(number,1))
   return 0;
  preset_loadDefault(0);
  for(i=0;i<6;++i)
   currentPreset.voicePattern[i]=(i==0)?0:(255);
  if (storage.version<1)
   return 1;
  enum continuousParameter_t cp;
  for(cp=cpFreqA;cp<=cpFilVelocity;++cp)
   currentPreset.continuousParameters[cp]=storageRead16();
  enum steppedParameter_t sp;
  for(sp=spASaw;sp<=spChromaticPitch;++sp)
   currentPreset.steppedParameters[sp]=storageRead8();
  currentPreset.steppedParameters[spAmpEnvSlow]=currentPreset.steppedParameters[holdPedal];
  if (storage.version<2)
   return 1;
  for(cp=cpModDelay;cp<=cpSeqArpClock;++cp)
   currentPreset.continuousParameters[cp]=storageRead16();
  for(sp=spModwheelTarget;sp<=spVibTarget;++sp)
   currentPreset.steppedParameters[sp]=storageRead8();
  for(i=0;i<6;++i)
   currentPreset.voicePattern[i]=storageRead8();
  currentPreset.continuousParameters[cpSeqArpClock]=settings.seqArpClock;
  if (storage.version<7)
   return 1;
  for (i=0; i<12; i++)
   currentPreset.perNoteTuning[i]=storageRead16();
 }
 return 1;
}

user_defined_types: enum continuousParameter_t { cpFreqA=0, cpVolA=1, cpAPW=2, cpFreqB=3, cpVolB=4, cpBPW=5, cpFreqBFine=6, cpCutoff=7, cpResonance=8, cpFilEnvAmt=9, cpFilRel=10, cpFilSus=11, cpFilDec=12, cpFilAtt=13, cpAmpRel=14, cpAmpSus=15, cpAmpDec=16, cpAmpAtt=17, cpPModFilEnv=18, cpPModOscB=19, cpLFOFreq=20, cpLFOAmt=21, cpGlide=22, cpAmpVelocity=23, cpFilVelocity=24, cpModDelay=25, cpVibFreq=26, cpVibAmt=27, cpUnisonDetune=28, cpSeqArpClock=29, cpCount=30 }

user_defined_types: enum steppedParameter_t { spASaw=0, spATri=1, spASqr=2, spBSaw=3, spBTri=4, spBSqr=5, spSync=6, spPModFA=7, spPModFil=8, spLFOShape=9, spLFOShift=10, spLFOTargets=11, spTrackingShift=12, spFilEnvExpo=13, spFilEnvSlow=14, spAmpEnvExpo=15, holdPedal=16, spUnison=17, spAssignerPriority=18, spBenderSemitones=19, spBenderTarget=20, spModwheelShift=21, spChromaticPitch=22, spModwheelTarget=23, spVibTarget=24, spAmpEnvSlow=25, spCount=26 }