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

if ( (readinputport(2LL) & 1) != 0 )
result = nmi_interrupt();
else
result = interrupt();
return result;
}

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

if ( (readinputport(2LL) & 1) != 0 )
result = nmi_interrupt();
else
result = interrupt();
return result;
}

original_code:
static int spaceint_interrupt(void)
{
 if (readinputport(2) & 1)
  return nmi_interrupt();
 else return interrupt();
}

canonical_original_code:
static int spaceint_interrupt()
{
 if (readinputport(2) & 1)
  return nmi_interrupt();
 else return interrupt();
}


original_code:
void rocnrope_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = *(color_prom++) & 0x0f;
}

canonical_original_code:
void rocnrope_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = *(color_prom++) & 0x0f;
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *

variable_types: i int

return_type: void


decompiled_code:
void *__fastcall rocnrope_flipscreen_w(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = (a2 & 1) == 0;
if ( flipscreen != v2 )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = (a2 & 1) == 0;
if ( flipscreen != v2 )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

original_code:
void rocnrope_flipscreen_w(offs_t offset,data_t data)
{
 if (flipscreen != (~data & 1))
 {
  flipscreen = ~data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
}

canonical_original_code:
void rocnrope_flipscreen_w(unsigned int offset, unsigned int data)
{
 if (flipscreen != (~data & 1))
 {
  flipscreen = ~data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
}

variable_types:
offset
unsigned int

variable_types:
data
unsigned int


decompiled_code:
void *__fastcall rocnrope_vh_screenrefresh(__int64 a1)
{
int v1; // ebx
__int64 v2; // r15
int v3; // ecx
int v4; // esi
char v5; // r10
__int64 v6; // r8
__int64 v7; // r9
void *result; // rax
int v9; // ebx
__int64 v10; // r14
unsigned int v11; // er10
__int64 v12; // r8
unsigned int v13; // er11
__int64 v14; // r9
int v15; // ecx
__int64 v16; // [rsp-28h] [rbp-60h]

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(v2 + dirtybuffer) )
{
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = v1 & 0x1F;
v4 = v1 >> 5;
v5 = *(_BYTE *)(colorram + v2);
v6 = v5 & 0x40;
v7 = v5 & 0x20;
if ( flipscreen )
{
v3 = 31 - v3;
v4 = 31 - v4;
v6 = (_DWORD)v6 == 0;
v7 = (_DWORD)v7 == 0;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v2) + 2 * (v5 & 0x80u),
v5 & 0xF,
v6,
v7,
(unsigned int)(8 * v3),
(unsigned int)(8 * v4),
Machine + 776LL,
0LL,
0LL);
}
--v1;
--v2;
}
while ( v1 != -1 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
result = &spriteram_size;
v9 = spriteram_size - 2;
if ( spriteram_size - 2 >= 0 )
{
v10 = v9 + 1LL;
do
{
v11 = *(unsigned __int8 *)(spriteram + v10);
v12 = *(_BYTE *)(spriteram_2 + v10 - 1) & 0x40;
v13 = *(_BYTE *)(spriteram_2 + v10 - 1) & 0xF;
v14 = (unsigned __int8)~*(_BYTE *)(spriteram_2 + v10 - 1) & 0x80;
v16 = *(unsigned __int8 *)(spriteram_2 + v10);
v15 = *(unsigned __int8 *)(spriteram + v10 - 1);
v10 -= 2LL;
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v11,
v13,
v12,
v14,
(unsigned int)(240 - v15),
v16,
Machine + 776LL,
6LL,
0LL);
v9 -= 2;
}
while ( v9 >= 0 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1)
{
int v1; // ebx
__int64 v2; // r15
int v3; // ecx
int v4; // esi
char v5; // r10
__int64 v6; // r8
__int64 v7; // r9
void *result; // rax
int v9; // ebx
__int64 v10; // r14
unsigned int v11; // er10
__int64 v12; // r8
unsigned int v13; // er11
__int64 v14; // r9
int v15; // ecx
__int64 v16; // [rsp-28h] [rbp-60h]

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(v2 + dirtybuffer) )
{
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = v1 & 0x1F;
v4 = v1 >> 5;
v5 = *(_BYTE *)(colorram + v2);
v6 = v5 & 0x40;
v7 = v5 & 0x20;
if ( flipscreen )
{
v3 = 31 - v3;
v4 = 31 - v4;
v6 = (_DWORD)v6 == 0;
v7 = (_DWORD)v7 == 0;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v2) + 2 * (v5 & 0x80u),
v5 & 0xF,
v6,
v7,
(unsigned int)(8 * v3),
(unsigned int)(8 * v4),
Machine + 776LL,
0LL,
0LL);
}
--v1;
--v2;
}
while ( v1 != -1 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
result = &spriteram_size;
v9 = spriteram_size - 2;
if ( spriteram_size - 2 >= 0 )
{
v10 = v9 + 1LL;
do
{
v11 = *(unsigned __int8 *)(spriteram + v10);
v12 = *(_BYTE *)(spriteram_2 + v10 - 1) & 0x40;
v13 = *(_BYTE *)(spriteram_2 + v10 - 1) & 0xF;
v14 = (unsigned __int8)~*(_BYTE *)(spriteram_2 + v10 - 1) & 0x80;
v16 = *(unsigned __int8 *)(spriteram_2 + v10);
v15 = *(unsigned __int8 *)(spriteram + v10 - 1);
v10 -= 2LL;
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v11,
v13,
v12,
v14,
(unsigned int)(240 - v15),
v16,
Machine + 776LL,
6LL,
0LL);
v9 -= 2;
}
while ( v9 >= 0 );
}
return result;
}

original_code:
void rocnrope_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx,sy,flipx,flipy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   flipx = colorram[offs] & 0x40;
   flipy = colorram[offs] & 0x20;
   if (flipscreen)
   {
    sx = 31 - sx;
    sy = 31 - sy;
    flipx = !flipx;
    flipy = !flipy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + 2 * (colorram[offs] & 0x80),
     colorram[offs] & 0x0f,
     flipx,flipy,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = spriteram_size - 2;offs >= 0;offs -= 2)
 {
  drawgfx(bitmap,Machine->gfx[1],
    spriteram[offs + 1],
    spriteram_2[offs] & 0x0f,
    spriteram_2[offs] & 0x40,~spriteram_2[offs] & 0x80,
    240-spriteram[offs],spriteram_2[offs + 1],
    &Machine->visible_area,TRANSPARENCY_COLOR,0);
 }
}

canonical_original_code:
void rocnrope_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx; int sy; int flipx; int flipy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   flipx = colorram[offs] & 0x40;
   flipy = colorram[offs] & 0x20;
   if (flipscreen)
   {
    sx = 31 - sx;
    sy = 31 - sy;
    flipx = !flipx;
    flipy = !flipy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + 2 * (colorram[offs] & 0x80),
     colorram[offs] & 0x0f,
     flipx,flipy,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = spriteram_size - 2;offs >= 0;offs -= 2)
 {
  drawgfx(bitmap,Machine->gfx[1],
    spriteram[offs + 1],
    spriteram_2[offs] & 0x0f,
    spriteram_2[offs] & 0x40,~spriteram_2[offs] & 0x80,
    240-spriteram[offs],spriteram_2[offs + 1],
    &Machine->visible_area,TRANSPARENCY_COLOR,0);
 }
}

variable_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

variable_types: offs int

variable_types: sx int

variable_types: sy int

variable_types: flipx int

variable_types: flipy int


decompiled_code:
__int64 init_rocnrope()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = memory_region(129LL);
v1 = memory_region_length(129LL);
konami1_decode();
result = v1 / 2 + 28733;
*(_BYTE *)(v0 + result) = -104;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = memory_region(129LL);
v1 = memory_region_length(129LL);
konami1_decode();
result = v1 / 2 + 28733;
*(_BYTE *)(v0 + result) = -104;
return result;
}

original_code:
static void init_rocnrope(void)
{
 unsigned char *rom = memory_region(REGION_CPU1);
 int diff = memory_region_length(REGION_CPU1) / 2;
 konami1_decode();
 rom[0x703d + diff] = 0x98;
}

canonical_original_code:
static void init_rocnrope()
{
 unsigned char *rom = memory_region(REGION_CPU1);
 int diff = memory_region_length(REGION_CPU1) / 2;
 konami1_decode();
 rom[0x703d + diff] = 0x98;
}

variable_types:
rom
unsigned char *

variable_types: diff int


decompiled_code:
// attributes: thunk
__int64 init_rocnropk()
{
return konami1_decode();
}

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

original_code:
static void init_rocnropk(void)
{
 konami1_decode();
}

canonical_original_code:
static void init_rocnropk()
{
 konami1_decode();
}


decompiled_code:
__int64 kncljoe_vh_start()
{
__int64 v0; // rdi
__int64 result; // rax

v0 = tilemap_create(get_bg_tile_info, &tilemap_scan_rows, 0LL, 8LL, 8LL, 64LL, 32LL);
bg_tilemap = v0;
result = 1LL;
if ( v0 )
{
((void (__fastcall *)(__int64, __int64))tilemap_set_scroll_rows)(v0, 4LL);
result = 0LL;
}
return result;
}

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

v0 = tilemap_create(get_bg_tile_info, &tilemap_scan_rows, 0LL, 8LL, 8LL, 64LL, 32LL);
bg_tilemap = v0;
result = 1LL;
if ( v0 )
{
((void (__fastcall *)(__int64, __int64))tilemap_set_scroll_rows)(v0, 4LL);
result = 0LL;
}
return result;
}

original_code:
int kncljoe_vh_start( void )
{
 bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,0x00,8,8,64,32);
 if (!bg_tilemap)
  return 1;
 tilemap_set_scroll_rows(bg_tilemap,4);
 return 0;
}

canonical_original_code:
int kncljoe_vh_start()
{
 bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,0x00,8,8,64,32);
 if (!bg_tilemap)
  return 1;
 tilemap_set_scroll_rows(bg_tilemap,4);
 return 0;
}

return_type: int


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

flipscreen = a2 & 1;
tilemap_set_flip(0LL, (unsigned int)(2 - flipscreen));
coin_counter_w(0LL, a2 & 2);
coin_counter_w(1LL, a2 & 0x20);
result = (a2 >> 4) & 1;
if ( (_DWORD)result != tile_bank )
{
tile_bank = (a2 >> 4) & 1;
result = tilemap_mark_all_tiles_dirty(bg_tilemap);
}
sprite_bank = (a2 >> 2) & 1;
return result;
}

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

flipscreen = a2 & 1;
tilemap_set_flip(0LL, (unsigned int)(2 - flipscreen));
coin_counter_w(0LL, a2 & 2);
coin_counter_w(1LL, a2 & 0x20);
result = (a2 >> 4) & 1;
if ( (_DWORD)result != tile_bank )
{
tile_bank = (a2 >> 4) & 1;
result = tilemap_mark_all_tiles_dirty(bg_tilemap);
}
sprite_bank = (a2 >> 2) & 1;
return result;
}

original_code:
void kncljoe_control_w(offs_t offset,data_t data)
{
 flipscreen = data & 0x01;
 tilemap_set_flip(0,flipscreen ? 0x1 : 0x2);
 coin_counter_w(0,data & 0x02);
 coin_counter_w(1,data & 0x20);
 if (tile_bank != ((data & 0x10) >> 4))
 {
  tile_bank = (data & 0x10) >> 4;
  tilemap_mark_all_tiles_dirty(bg_tilemap);
 }
 sprite_bank = (data & 0x04) >> 2;
}

canonical_original_code:
void kncljoe_control_w(unsigned int offset, unsigned int data)
{
 flipscreen = data & 0x01;
 tilemap_set_flip(0,flipscreen ? 0x1 : 0x2);
 coin_counter_w(0,data & 0x02);
 coin_counter_w(1,data & 0x20);
 if (tile_bank != ((data & 0x10) >> 4))
 {
  tile_bank = (data & 0x10) >> 4;
  tilemap_mark_all_tiles_dirty(bg_tilemap);
 }
 sprite_bank = (data & 0x04) >> 2;
}


decompiled_code:
__int64 __fastcall kncljoe_scroll_w(__int64 a1, unsigned int a2)
{
tilemap_set_scrollx(bg_tilemap, 0LL, a2);
tilemap_set_scrollx(bg_tilemap, 1LL, a2);
tilemap_set_scrollx(bg_tilemap, 2LL, a2);
return tilemap_set_scrollx(bg_tilemap, 3LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int a2)
{
tilemap_set_scrollx(bg_tilemap, 0LL, a2);
tilemap_set_scrollx(bg_tilemap, 1LL, a2);
tilemap_set_scrollx(bg_tilemap, 2LL, a2);
return tilemap_set_scrollx(bg_tilemap, 3LL, 0LL);
}

original_code:
void kncljoe_scroll_w(offs_t offset,data_t data)
{
 tilemap_set_scrollx(bg_tilemap,0,data);
 tilemap_set_scrollx(bg_tilemap,1,data);
 tilemap_set_scrollx(bg_tilemap,2,data);
 tilemap_set_scrollx(bg_tilemap,3,0);
}

canonical_original_code:
void kncljoe_scroll_w(unsigned int offset, unsigned int data)
{
 tilemap_set_scrollx(bg_tilemap,0,data);
 tilemap_set_scrollx(bg_tilemap,1,data);
 tilemap_set_scrollx(bg_tilemap,2,data);
 tilemap_set_scrollx(bg_tilemap,3,0);
}


decompiled_code:
void *__fastcall kncljoe_vh_screenrefresh(__int64 a1)
{
tilemap_update(0LL);
tilemap_render(0LL);
palette_recalc();
tilemap_draw(a1, bg_tilemap, 0LL);
return draw_sprites(a1);
}

canonical_decompiled_code:
void *__fastcall func6(__int64 a1)
{
tilemap_update(0LL);
tilemap_render(0LL);
palette_recalc();
tilemap_draw(a1, bg_tilemap, 0LL);
return func5(a1);
}

original_code:
void kncljoe_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 tilemap_update(0);
        tilemap_render(0);
 palette_recalc();
 tilemap_draw(bitmap,bg_tilemap,0);
 draw_sprites(bitmap);
}

canonical_original_code:
void kncljoe_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 tilemap_update(0);
        tilemap_render(0);
 palette_recalc();
 tilemap_draw(bitmap,bg_tilemap,0);
 draw_sprites(bitmap);
}

user_defined_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; }


original_code:
static void get_bg_tile_info(int tile_index)
{
 int attr = videoram[2*tile_index+1];
 int code = videoram[2*tile_index] + ((attr & 0xc0) << 2) + (tile_bank << 10);
 { const struct GfxElement *gfx = Machine->gfx[(0)]; int _code = (code) % gfx->total_elements; tile_info.pen_data = gfx->gfxdata + _code*gfx->char_modulo; tile_info.pal_data = &gfx->colortable[gfx->color_granularity * (attr & 0xf)]; tile_info.pen_usage = gfx->pen_usage?gfx->pen_usage[_code]:0; }
 tile_info.flags = (((((attr & 0x30) >> 4)>>1)|(((attr & 0x30) >> 4)<<1))&3);
}

canonical_original_code:
static void get_bg_tile_info(int tile_index)
{
 int attr = videoram[2*tile_index+1];
 int code = videoram[2*tile_index] + ((attr & 0xc0) << 2) + (tile_bank << 10);
 { struct GfxElement *gfx = Machine->gfx[(0)]; int _code = (code) % gfx->total_elements; tile_info.pen_data = gfx->gfxdata + _code*gfx->char_modulo; tile_info.pal_data = &gfx->colortable[gfx->color_granularity * (attr & 0xf)]; tile_info.pen_usage = gfx->pen_usage?gfx->pen_usage[_code]:0; }
 tile_info.flags = (((((attr & 0x30) >> 4)>>1)|(((attr & 0x30) >> 4)<<1))&3);
}

variable_types: attr int

variable_types: code int

variable_types: struct GfxElement { int width; unsigned int total_elements; int color_granularity; unsigned short *colortable; int total_colors; unsigned int *pen_usage; unsigned char *gfxdata; int line_modulo; int char_modulo; } *


decompiled_code:
void *__fastcall draw_sprites(__int64 a1)
{
__int64 v1; // rbp
void *result; // rax
__int64 v3; // rcx
__int64 v4; // r15
char v5; // r9
__int64 v6; // rdx
__int64 v7; // [rsp+8h] [rbp-50h]

v1 = *(_QWORD *)(Machine + 8LL * (sprite_bank + 1) + 512);
result = &spriteram_size;
if ( spriteram_size >= 0 )
{
v3 = spriteram_size;
v4 = spriteram_size - 4LL;
v7 = v4 - 4LL * (spriteram_size >> 2);
while ( 1 )
{
v5 = *(_BYTE *)(spriteram + v3 + 1);
v6 = *(unsigned __int8 *)(spriteram + v3 + 2);
if ( (v5 & 0x10) != 0 )
v6 = (unsigned int)(v6 + 512);
if ( (v5 & 0x20) != 0 )
v6 = (unsigned int)(v6 + 256);
result = (void *)drawgfx(a1, v1, v6, v5 & 0xF);
v3 = v4;
if ( v7 == v4 )
break;
v4 -= 4LL;
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func5(__int64 a1)
{
__int64 v1; // rbp
void *result; // rax
__int64 v3; // rcx
__int64 v4; // r15
char v5; // r9
__int64 v6; // rdx
__int64 v7; // [rsp+8h] [rbp-50h]

v1 = *(_QWORD *)(Machine + 8LL * (sprite_bank + 1) + 512);
result = &spriteram_size;
if ( spriteram_size >= 0 )
{
v3 = spriteram_size;
v4 = spriteram_size - 4LL;
v7 = v4 - 4LL * (spriteram_size >> 2);
while ( 1 )
{
v5 = *(_BYTE *)(spriteram + v3 + 1);
v6 = *(unsigned __int8 *)(spriteram + v3 + 2);
if ( (v5 & 0x10) != 0 )
v6 = (unsigned int)(v6 + 512);
if ( (v5 & 0x20) != 0 )
v6 = (unsigned int)(v6 + 256);
result = (void *)drawgfx(a1, v1, v6, v5 & 0xF);
v3 = v4;
if ( v7 == v4 )
break;
v4 -= 4LL;
}
}
return result;
}

original_code:
static void draw_sprites( struct osd_bitmap *bitmap )
{
 struct rectangle clip = Machine->visible_area;
 const struct GfxElement *gfx = Machine->gfx[1 + sprite_bank];
 int offs;
 if (flipscreen)
  clip.max_y -= 64;
 else
  clip.min_y += 64;
 for (offs = spriteram_size;offs >= 0;offs -= 4)
 {
  int sy = spriteram[offs];
  int sx = spriteram[offs+3];
  int code = spriteram[offs+2];
  int attr = spriteram[offs+1];
  int flipx = attr & 0x40;
  int flipy = !(attr & 0x80);
  int color = attr & 0x0f;
  if (attr & 0x10) code += 512;
  if (attr & 0x20) code += 256;
  if (flipscreen)
  {
   flipx = !flipx;
   flipy = !flipy;
   sx = 240 - sx;
   sy = 240 - sy;
  }
  drawgfx(bitmap,gfx,
    code,
    color,
    flipx,flipy,
    sx,sy,
    &clip,TRANSPARENCY_PEN,0);
 }
}

canonical_original_code:
static void draw_sprites(struct osd_bitmap *bitmap)
{
 struct rectangle clip = Machine->visible_area;
 struct GfxElement *gfx = Machine->gfx[1 + sprite_bank];
 int offs;
 if (flipscreen)
  clip.max_y -= 64;
 else
  clip.min_y += 64;
 for (offs = spriteram_size;offs >= 0;offs -= 4)
 {
  int sy = spriteram[offs];
  int sx = spriteram[offs+3];
  int code = spriteram[offs+2];
  int attr = spriteram[offs+1];
  int flipx = attr & 0x40;
  int flipy = !(attr & 0x80);
  int color = attr & 0x0f;
  if (attr & 0x10) code += 512;
  if (attr & 0x20) code += 256;
  if (flipscreen)
  {
   flipx = !flipx;
   flipy = !flipy;
   sx = 240 - sx;
   sy = 240 - sy;
  }
  drawgfx(bitmap,gfx,
    code,
    color,
    flipx,flipy,
    sx,sy,
    &clip,TRANSPARENCY_PEN,0);
 }
}

variable_types: struct rectangle { int min_x; int min_y; }

variable_types: color int

user_defined_types: struct GfxElement { int width; unsigned int total_elements; int color_granularity; unsigned short *colortable; int total_colors; unsigned int *pen_usage; unsigned char *gfxdata; int line_modulo; int char_modulo; }


decompiled_code:
void *get_crc_table()
{
return &crc_table;
}

canonical_decompiled_code:
void *func3()
{
return &crc_table;
}

original_code:
const unsigned long * get_crc_table()
{
    return (const unsigned long *)crc_table;
}

canonical_original_code:
unsigned long *get_crc_table()
{
    return (unsigned long *)crc_table;
}

return_type: unsigned long *


decompiled_code:
__int64 __fastcall dotrikun_videoram_w(unsigned int a1, unsigned int a2)
{
int v2; // ebx
__int64 result; // rax
int v4; // ebp
unsigned int v6; // ebx
int v7; // er8
unsigned int v8; // er14
__int64 v9; // rsi
unsigned int v10; // [rsp+4h] [rbp-44h]
unsigned int v11; // [rsp+8h] [rbp-40h]
int v12; // [rsp+Ch] [rbp-3Ch]

v2 = 16 * (a1 & 0xF);
*(_BYTE *)(videoram + a1) = a2;
result = Machine;
if ( *(_DWORD *)(Machine + 776LL) <= v2 && *(_DWORD *)(Machine + 780LL) >= v2 )
{
v4 = 2 * (a1 >> 4);
if ( *(_DWORD *)(Machine + 784LL) <= v4 && *(_DWORD *)(Machine + 788LL) >= v4 )
{
v6 = v2 + 14;
v10 = v4 + 1;
v7 = 0;
while ( 1 )
{
v12 = v7;
v8 = *(unsigned __int16 *)(*(_QWORD *)(result + 792) + 2LL * ((a2 >> v7) & 1));
plot_pixel(
*(_QWORD *)(result + 768),
v6,
(unsigned int)v4,
*(unsigned __int16 *)(*(_QWORD *)(result + 792) + 2LL * ((a2 >> v7) & 1)));
v11 = v6 + 1;
plot_pixel(*(_QWORD *)(Machine + 768LL), v6 + 1, (unsigned int)v4, v8);
v9 = v6;
v6 -= 2;
plot_pixel(*(_QWORD *)(Machine + 768LL), v9, v10, v8);
result = plot_pixel(*(_QWORD *)(Machine + 768LL), v11, v10, v8);
v7 = v12 + 1;
if ( v12 == 7 )
break;
result = Machine;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2)
{
int v2; // ebx
__int64 result; // rax
int v4; // ebp
unsigned int v6; // ebx
int v7; // er8
unsigned int v8; // er14
__int64 v9; // rsi
unsigned int v10; // [rsp+4h] [rbp-44h]
unsigned int v11; // [rsp+8h] [rbp-40h]
int v12; // [rsp+Ch] [rbp-3Ch]

v2 = 16 * (a1 & 0xF);
*(_BYTE *)(videoram + a1) = a2;
result = Machine;
if ( *(_DWORD *)(Machine + 776LL) <= v2 && *(_DWORD *)(Machine + 780LL) >= v2 )
{
v4 = 2 * (a1 >> 4);
if ( *(_DWORD *)(Machine + 784LL) <= v4 && *(_DWORD *)(Machine + 788LL) >= v4 )
{
v6 = v2 + 14;
v10 = v4 + 1;
v7 = 0;
while ( 1 )
{
v12 = v7;
v8 = *(unsigned __int16 *)(*(_QWORD *)(result + 792) + 2LL * ((a2 >> v7) & 1));
plot_pixel(
*(_QWORD *)(result + 768),
v6,
(unsigned int)v4,
*(unsigned __int16 *)(*(_QWORD *)(result + 792) + 2LL * ((a2 >> v7) & 1)));
v11 = v6 + 1;
plot_pixel(*(_QWORD *)(Machine + 768LL), v6 + 1, (unsigned int)v4, v8);
v9 = v6;
v6 -= 2;
plot_pixel(*(_QWORD *)(Machine + 768LL), v9, v10, v8);
result = plot_pixel(*(_QWORD *)(Machine + 768LL), v11, v10, v8);
v7 = v12 + 1;
if ( v12 == 7 )
break;
result = Machine;
}
}
}
return result;
}

original_code:
void dotrikun_videoram_w(offs_t offset,data_t data)
{
 int i;
 int x, y;
 int color;
 videoram[offset] = data;
 x = 2 * (((offset % 16) * 8));
 y = 2 * ((offset / 16));
 if (x >= Machine->visible_area.min_x &&
   x <= Machine->visible_area.max_x &&
   y >= Machine->visible_area.min_y &&
   y <= Machine->visible_area.max_y)
 {
  for (i = 0; i < 8; i++)
  {
   color = Machine->pens[((data >> i) & 0x01)];
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i), y, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i)+1, y, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i), y+1, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i)+1, y+1, color);
  }
 }
}

canonical_original_code:
void dotrikun_videoram_w(unsigned int offset, unsigned int data)
{
 int i;
 int x; int y;
 int color;
 videoram[offset] = data;
 x = 2 * (((offset % 16) * 8));
 y = 2 * ((offset / 16));
 if (x >= Machine->visible_area.min_x &&
   x <= Machine->visible_area.max_x &&
   y >= Machine->visible_area.min_y &&
   y <= Machine->visible_area.max_y)
 {
  for (i = 0; i < 8; i++)
  {
   color = Machine->pens[((data >> i) & 0x01)];
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i), y, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i)+1, y, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i), y+1, color);
   plot_pixel(Machine->scrbitmap, x + 2*(7 - i)+1, y+1, color);
  }
 }
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 __fastcall dotrikun_color_w(__int64 a1, int a2)
{
palette_change_color(
0LL,
(unsigned __int8)(a2 << 28 >> 31),
(unsigned __int8)(a2 << 27 >> 31),
(unsigned __int8)(a2 << 26 >> 31));
return palette_change_color(
1LL,
(unsigned __int8)-(a2 & 1),
(unsigned __int8)(a2 << 30 >> 31),
(unsigned __int8)(a2 << 29 >> 31));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
palette_change_color(
0LL,
(unsigned __int8)(a2 << 28 >> 31),
(unsigned __int8)(a2 << 27 >> 31),
(unsigned __int8)(a2 << 26 >> 31));
return palette_change_color(
1LL,
(unsigned __int8)-(a2 & 1),
(unsigned __int8)(a2 << 30 >> 31),
(unsigned __int8)(a2 << 29 >> 31));
}

original_code:
void dotrikun_color_w(offs_t offset,data_t data)
{
 int r, g, b;
 r = ((data & 0x08) ? 0xff : 0x00);
 g = ((data & 0x10) ? 0xff : 0x00);
 b = ((data & 0x20) ? 0xff : 0x00);
 palette_change_color(0, r, g, b);
 r = ((data & 0x01) ? 0xff : 0x00);
 g = ((data & 0x02) ? 0xff : 0x00);
 b = ((data & 0x04) ? 0xff : 0x00);
 palette_change_color(1, r, g, b);
}

canonical_original_code:
void dotrikun_color_w(unsigned int offset, unsigned int data)
{
 int r; int g; int b;
 r = ((data & 0x08) ? 0xff : 0x00);
 g = ((data & 0x10) ? 0xff : 0x00);
 b = ((data & 0x20) ? 0xff : 0x00);
 palette_change_color(0, r, g, b);
 r = ((data & 0x01) ? 0xff : 0x00);
 g = ((data & 0x02) ? 0xff : 0x00);
 b = ((data & 0x04) ? 0xff : 0x00);
 palette_change_color(1, r, g, b);
}

variable_types:
offset
unsigned int

variable_types: r int

variable_types: g int

variable_types: b int


original_code:
void higemaru_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = *(color_prom++) & 0x0f;
 color_prom += 128;
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = (*(color_prom++) & 0x0f) + 0x10;
}

canonical_original_code:
void higemaru_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = *(color_prom++) & 0x0f;
 color_prom += 128;
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = (*(color_prom++) & 0x0f) + 0x10;
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *

variable_types: i int


decompiled_code:
void *__fastcall higemaru_c800_w(__int64 a1, char a2)
{
void *result; // rax

coin_counter_w(0LL, a2 & 2);
result = (void *)coin_counter_w(1LL, a2 & 1);
if ( (a2 & 0x80) != flipscreen )
{
flipscreen = a2 & 0x80;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, char a2)
{
void *result; // rax

coin_counter_w(0LL, a2 & 2);
result = (void *)coin_counter_w(1LL, a2 & 1);
if ( (a2 & 0x80) != flipscreen )
{
flipscreen = a2 & 0x80;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

original_code:
void higemaru_c800_w(offs_t offset,data_t data)
{
 coin_counter_w(0,data & 2);
 coin_counter_w(1,data & 1);
 if (flipscreen != (data & 0x80))
 {
  flipscreen = data & 0x80;
  memset(dirtybuffer,1,videoram_size);
 }
}

canonical_original_code:
void higemaru_c800_w(unsigned int offset, unsigned int data)
{
 coin_counter_w(0,data & 2);
 coin_counter_w(1,data & 1);
 if (flipscreen != (data & 0x80))
 {
  flipscreen = data & 0x80;
  memset(dirtybuffer,1,videoram_size);
 }
}

variable_types:
data
unsigned int


decompiled_code:
__int64 __fastcall higemaru_vh_screenrefresh(__int64 a1)
{
int v2; // ebx
__int64 v3; // r15
__int64 v4; // r8
int v5; // eax
int v6; // edi
__int64 result; // rax
__int64 v8; // rbp
__int64 v9; // r15
__int64 v10; // r10
unsigned int v11; // ebx
unsigned __int8 v12; // cl
__int64 v13; // r8
unsigned __int8 v14; // r12
unsigned int v15; // [rsp+0h] [rbp-48h]
unsigned int v16; // [rsp+4h] [rbp-44h]
unsigned int v17; // [rsp+8h] [rbp-40h]
int v18; // [rsp+Ch] [rbp-3Ch]

v2 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
v4 = (unsigned int)flipscreen;
*(_BYTE *)(v3 + dirtybuffer) = 0;
v5 = v2 & 0x1F;
v6 = v2 >> 5;
if ( (_DWORD)v4 )
{
v5 = 31 - v5;
v6 = 31 - v6;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v3) + ((2 * *(unsigned __int8 *)(colorram + v3)) & 0x100u),
*(_BYTE *)(colorram + v3) & 0x1F,
v4,
(unsigned int)v4,
(unsigned int)(8 * v5),
(unsigned int)(8 * v6),
0LL,
0LL,
0LL);
}
--v2;
--v3;
}
while ( v2 != -1 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
result = (unsigned int)(spriteram_size - 16);
v18 = spriteram_size - 16;
if ( spriteram_size - 16 >= 0 )
{
v8 = (int)result;
do
{
v9 = *(unsigned __int8 *)(spriteram + v8 + 12);
v10 = *(unsigned __int8 *)(spriteram + v8 + 8);
v11 = *(_BYTE *)(spriteram + v8 + 4) & 0x20;
v12 = *(_BYTE *)(spriteram + v8 + 4) & 0xF;
v13 = *(_BYTE *)(spriteram + v8 + 4) & 0x10;
if ( flipscreen )
{
v9 = (unsigned int)(240 - v9);
v10 = (unsigned int)(240 - v10);
v13 = (_DWORD)v13 == 0;
v11 = v11 == 0;
}
v14 = *(_BYTE *)(spriteram + v8) & 0x7F;
v8 -= 16LL;
v17 = v10;
v16 = v13;
v15 = v12;
drawgfx(a1, *(_QWORD *)(Machine + 520LL), v14, v12, v13, v11, v9, v10, Machine + 776LL, 2LL, 15LL);
result = drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v14,
v15,
v16,
v11,
(unsigned int)(v9 - 256),
v17,
Machine + 776LL,
2LL,
15LL);
v18 -= 16;
}
while ( v18 >= 0 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v2; // ebx
__int64 v3; // r15
__int64 v4; // r8
int v5; // eax
int v6; // edi
__int64 result; // rax
__int64 v8; // rbp
__int64 v9; // r15
__int64 v10; // r10
unsigned int v11; // ebx
unsigned __int8 v12; // cl
__int64 v13; // r8
unsigned __int8 v14; // r12
unsigned int v15; // [rsp+0h] [rbp-48h]
unsigned int v16; // [rsp+4h] [rbp-44h]
unsigned int v17; // [rsp+8h] [rbp-40h]
int v18; // [rsp+Ch] [rbp-3Ch]

v2 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
v4 = (unsigned int)flipscreen;
*(_BYTE *)(v3 + dirtybuffer) = 0;
v5 = v2 & 0x1F;
v6 = v2 >> 5;
if ( (_DWORD)v4 )
{
v5 = 31 - v5;
v6 = 31 - v6;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v3) + ((2 * *(unsigned __int8 *)(colorram + v3)) & 0x100u),
*(_BYTE *)(colorram + v3) & 0x1F,
v4,
(unsigned int)v4,
(unsigned int)(8 * v5),
(unsigned int)(8 * v6),
0LL,
0LL,
0LL);
}
--v2;
--v3;
}
while ( v2 != -1 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
result = (unsigned int)(spriteram_size - 16);
v18 = spriteram_size - 16;
if ( spriteram_size - 16 >= 0 )
{
v8 = (int)result;
do
{
v9 = *(unsigned __int8 *)(spriteram + v8 + 12);
v10 = *(unsigned __int8 *)(spriteram + v8 + 8);
v11 = *(_BYTE *)(spriteram + v8 + 4) & 0x20;
v12 = *(_BYTE *)(spriteram + v8 + 4) & 0xF;
v13 = *(_BYTE *)(spriteram + v8 + 4) & 0x10;
if ( flipscreen )
{
v9 = (unsigned int)(240 - v9);
v10 = (unsigned int)(240 - v10);
v13 = (_DWORD)v13 == 0;
v11 = v11 == 0;
}
v14 = *(_BYTE *)(spriteram + v8) & 0x7F;
v8 -= 16LL;
v17 = v10;
v16 = v13;
v15 = v12;
drawgfx(a1, *(_QWORD *)(Machine + 520LL), v14, v12, v13, v11, v9, v10, Machine + 776LL, 2LL, 15LL);
result = drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v14,
v15,
v16,
v11,
(unsigned int)(v9 - 256),
v17,
Machine + 776LL,
2LL,
15LL);
v18 -= 16;
}
while ( v18 >= 0 );
}
return result;
}

original_code:
void higemaru_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx,sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen)
   {
    sx = 31 - sx;
    sy = 31 - sy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x80) << 1),
     colorram[offs] & 0x1f,
     flipscreen,flipscreen,
     8*sx,8*sy,
     0,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = spriteram_size - 16;offs >= 0;offs -= 16)
 {
  int code,col,sx,sy,flipx,flipy;
  code = spriteram[offs] & 0x7f;
  col = spriteram[offs + 4] & 0x0f;
  sx = spriteram[offs + 12];
  sy = spriteram[offs + 8];
  flipx = spriteram[offs + 4] & 0x10;
  flipy = spriteram[offs + 4] & 0x20;
  if (flipscreen)
  {
   sx = 240 - sx;
   sy = 240 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    code,
    col,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,15);
  drawgfx(bitmap,Machine->gfx[1],
    code,
    col,
    flipx,flipy,
    sx - 256,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,15);
 }
}

canonical_original_code:
void higemaru_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx; int sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen)
   {
    sx = 31 - sx;
    sy = 31 - sy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x80) << 1),
     colorram[offs] & 0x1f,
     flipscreen,flipscreen,
     8*sx,8*sy,
     0,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = spriteram_size - 16;offs >= 0;offs -= 16)
 {
  int code; int col; int sx; int sy; int flipx; int flipy;
  code = spriteram[offs] & 0x7f;
  col = spriteram[offs + 4] & 0x0f;
  sx = spriteram[offs + 12];
  sy = spriteram[offs + 8];
  flipx = spriteram[offs + 4] & 0x10;
  flipy = spriteram[offs + 4] & 0x20;
  if (flipscreen)
  {
   sx = 240 - sx;
   sy = 240 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    code,
    col,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,15);
  drawgfx(bitmap,Machine->gfx[1],
    code,
    col,
    flipx,flipy,
    sx - 256,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,15);
 }
}

variable_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

variable_types: offs int

variable_types: sx int

variable_types: sy int

variable_types: col int

variable_types: flipx int

variable_types: flipy int


decompiled_code:
__int64 higemaru_interrupt()
{
return (unsigned int)cpu_getiloops() == 0 ? 207 : 215;
}

canonical_decompiled_code:
__int64 func3()
{
return (unsigned int)cpu_getiloops() == 0 ? 207 : 215;
}

original_code:
int higemaru_interrupt(void)
{
 if (cpu_getiloops() == 0) return 0x00cf;
 else return 0x00d7;
}

canonical_original_code:
int higemaru_interrupt()
{
 if (cpu_getiloops() == 0) return 0x00cf;
 else return 0x00d7;
}


decompiled_code:
__int64 __fastcall uistring_init(__int64 a1)
{
__int64 v1; // r14
size_t v2; // r13
_DWORD *v3; // rax
char *v4; // rax
char *v5; // rax
char *v7; // rax
char *v8; // rax
char *v9; // rax
char *v10; // rax
char s; // [rsp+8h] [rbp-338h] BYREF
char v12[255]; // [rsp+9h] [rbp-337h] BYREF
char dest[16]; // [rsp+108h] [rbp-238h] BYREF
char v14[232]; // [rsp+118h] [rbp-228h] BYREF
int v15; // [rsp+200h] [rbp-140h]
__int16 v16; // [rsp+204h] [rbp-13Ch]
char v17[2]; // [rsp+206h] [rbp-13Ah]
_DWORD v18[78]; // [rsp+208h] [rbp-138h] BYREF

*(_OWORD *)dest = 0LL;
memset(v14, 0, sizeof(v14));
v15 = 0;
v16 = 0;
v17[0] = 0;
memset(trans_text, 0, 0x370uLL);
memset(lang, 0, sizeof(lang));
if ( a1 )
{
LABEL_2:
while ( osd_fgets(&s, 255LL, a1) )
{
if ( s != 10 && s != 59 )
{
if ( s == 91 )
{
v7 = strtok(v12, "]");
strcpy(dest, v7);
}
else
{
if ( !strcmp(dest, "LangInfo") )
{
v4 = strtok(&s, "=");
if ( !strcmp(v4, "Version") )
{
v8 = strtok(0LL, "\n");
_isoc99_sscanf(v8, "%d", lang);
}
else if ( !strcmp(v4, "Language") )
{
v9 = strtok(0LL, "\n");
strcpy(&lang[18], v9);
}
else if ( !strcmp(v4, "Author") )
{
v10 = strtok(0LL, "\n");
strcpy(&lang[528], v10);
}
else if ( !strcmp(v4, "Font") )
{
v5 = strtok(0LL, "\n");
strcpy(&lang[273], v5);
}
}
if ( !strcmp(dest, "Strings") )
{
v1 = 0LL;
strtok(&s, "\n");
while ( strcmp(&s, default_text[v1]) )
{
if ( ++v1 == 109 )
goto LABEL_2;
}
osd_fgets(v18, 255LL, a1);
strtok((char *)v18, "\n");
v2 = strlen((const char *)v18) + 1;
v3 = malloc(v2);
trans_text[(int)v1] = v3;
if ( (unsigned int)v2 >= 8 )
{
*(_QWORD *)((char *)v3 + (unsigned int)v2 - 8) = *(_QWORD *)((char *)&v15 + (unsigned int)v2);
qmemcpy(v3, v18, 8LL * ((unsigned int)(v2 - 1) >> 3));
}
else if ( (v2 & 4) != 0 )
{
*v3 = v18[0];
*(_DWORD *)((char *)v3 + (unsigned int)v2 - 4) = *(_DWORD *)((char *)&v16 + (unsigned int)v2);
}
else if ( (_DWORD)v2 )
{
*(_BYTE *)v3 = v18[0];
if ( (v2 & 2) != 0 )
*(_WORD *)((char *)v3 + (unsigned int)v2 - 2) = *(_WORD *)&v17[(unsigned int)v2];
}
}
}
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // r14
size_t v2; // r13
_DWORD *v3; // rax
char *v4; // rax
char *v5; // rax
char *v7; // rax
char *v8; // rax
char *v9; // rax
char *v10; // rax
char s; // [rsp+8h] [rbp-338h] BYREF
char v12[255]; // [rsp+9h] [rbp-337h] BYREF
char dest[16]; // [rsp+108h] [rbp-238h] BYREF
char v14[232]; // [rsp+118h] [rbp-228h] BYREF
int v15; // [rsp+200h] [rbp-140h]
__int16 v16; // [rsp+204h] [rbp-13Ch]
char v17[2]; // [rsp+206h] [rbp-13Ah]
_DWORD v18[78]; // [rsp+208h] [rbp-138h] BYREF

*(_OWORD *)dest = 0LL;
memset(v14, 0, sizeof(v14));
v15 = 0;
v16 = 0;
v17[0] = 0;
memset(trans_text, 0, 0x370uLL);
memset(lang, 0, sizeof(lang));
if ( a1 )
{
LABEL_2:
while ( osd_fgets(&s, 255LL, a1) )
{
if ( s != 10 && s != 59 )
{
if ( s == 91 )
{
v7 = strtok(v12, "]");
strcpy(dest, v7);
}
else
{
if ( !strcmp(dest, "LangInfo") )
{
v4 = strtok(&s, "=");
if ( !strcmp(v4, "Version") )
{
v8 = strtok(0LL, "\n");
_isoc99_sscanf(v8, "%d", lang);
}
else if ( !strcmp(v4, "Language") )
{
v9 = strtok(0LL, "\n");
strcpy(&lang[18], v9);
}
else if ( !strcmp(v4, "Author") )
{
v10 = strtok(0LL, "\n");
strcpy(&lang[528], v10);
}
else if ( !strcmp(v4, "Font") )
{
v5 = strtok(0LL, "\n");
strcpy(&lang[273], v5);
}
}
if ( !strcmp(dest, "Strings") )
{
v1 = 0LL;
strtok(&s, "\n");
while ( strcmp(&s, default_text[v1]) )
{
if ( ++v1 == 109 )
goto LABEL_2;
}
osd_fgets(v18, 255LL, a1);
strtok((char *)v18, "\n");
v2 = strlen((const char *)v18) + 1;
v3 = malloc(v2);
trans_text[(int)v1] = v3;
if ( (unsigned int)v2 >= 8 )
{
*(_QWORD *)((char *)v3 + (unsigned int)v2 - 8) = *(_QWORD *)((char *)&v15 + (unsigned int)v2);
qmemcpy(v3, v18, 8LL * ((unsigned int)(v2 - 1) >> 3));
}
else if ( (v2 & 4) != 0 )
{
*v3 = v18[0];
*(_DWORD *)((char *)v3 + (unsigned int)v2 - 4) = *(_DWORD *)((char *)&v16 + (unsigned int)v2);
}
else if ( (_DWORD)v2 )
{
*(_BYTE *)v3 = v18[0];
if ( (v2 & 2) != 0 )
*(_WORD *)((char *)v3 + (unsigned int)v2 - 2) = *(_WORD *)&v17[(unsigned int)v2];
}
}
}
}
}
}
return 0LL;
}

original_code:
int uistring_init (void *langfile)
{
 int i;
 char curline[255];
 char section[255] = "\0";
 char *ptr;
 for (i = 0; i <= UI_last_entry; i ++)
 {
  trans_text[i] = ((void *)0);
 }
 memset(&lang, 0, sizeof(lang));
 if (!langfile) return 0;
 while (osd_fgets (curline, 255, langfile) != ((void *)0))
 {
  if (curline[0] == ';') continue;
  if (curline[0] == '\n') continue;
  if (curline[0] == '[')
  {
   ptr = strtok (&curline[1], "]");
   strcpy (section, ptr);
   continue;
  }
  if (strcmp (section, "LangInfo") == 0)
  {
   ptr = strtok (curline, "=");
   if (strcmp (ptr, "Version") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    sscanf (ptr, "%d", &lang.version);
   }
   else if (strcmp (ptr, "Language") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.langname, ptr);
   }
   else if (strcmp (ptr, "Author") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.author, ptr);
   }
   else if (strcmp (ptr, "Font") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.fontname, ptr);
   }
  }
  if (strcmp (section, "Strings") == 0)
  {
   ptr = strtok (curline, "\n");
   for (i = 0; i < UI_last_entry; i ++)
   {
    if (strcmp (curline, default_text[i]) == 0)
    {
     char transline[255];
     osd_fgets (transline, 255, langfile);
     ptr = strtok (transline, "\n");
     trans_text[i] = (char*) malloc(strlen(transline)+1);
     strcpy (trans_text[i], transline);
     break;
    }
   }
  }
 }
 return 0;
}

canonical_original_code:
int uistring_init(void *langfile)
{
 int i;
 char curline[255];
 char section[255] = "\0";
 char *ptr;
 for (i = 0; i <= UI_last_entry; i ++)
 {
  trans_text[i] = ((void *)0);
 }
 memset(&lang, 0, sizeof(lang));
 if (!langfile) return 0;
 while (osd_fgets (curline, 255, langfile) != ((void *)0))
 {
  if (curline[0] == ';') continue;
  if (curline[0] == '\n') continue;
  if (curline[0] == '[')
  {
   ptr = strtok (&curline[1], "]");
   strcpy (section, ptr);
   continue;
  }
  if (strcmp (section, "LangInfo") == 0)
  {
   ptr = strtok (curline, "=");
   if (strcmp (ptr, "Version") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    sscanf (ptr, "%d", &lang.version);
   }
   else if (strcmp (ptr, "Language") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.langname, ptr);
   }
   else if (strcmp (ptr, "Author") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.author, ptr);
   }
   else if (strcmp (ptr, "Font") == 0)
   {
    ptr = strtok (((void *)0), "\n");
    strcpy (lang.fontname, ptr);
   }
  }
  if (strcmp (section, "Strings") == 0)
  {
   ptr = strtok (curline, "\n");
   for (i = 0; i < UI_last_entry; i ++)
   {
    if (strcmp (curline, default_text[i]) == 0)
    {
     char transline[255];
     osd_fgets (transline, 255, langfile);
     ptr = strtok (transline, "\n");
     trans_text[i] = (char *) malloc(strlen(transline)+1);
     strcpy (trans_text[i], transline);
     break;
    }
   }
  }
 }
 return 0;
}

variable_types:
langfile
void *

variable_types:
curline
char [255]

variable_types:
section
char [255]

variable_types:
ptr
char *

variable_types:
transline
char [255]


decompiled_code:
void uistring_shutdown()
{
void **v0; // rbx

v0 = (void **)trans_text;
do
{
if ( *v0 )
{
free(*v0);
*v0 = 0LL;
}
++v0;
}
while ( v0 != &trans_text[110] );
}

canonical_decompiled_code:
void func1()
{
void **v0; // rbx

v0 = (void **)trans_text;
do
{
if ( *v0 )
{
free(*v0);
*v0 = 0LL;
}
++v0;
}
while ( v0 != &trans_text[110] );
}

original_code:
void uistring_shutdown (void)
{
 int i;
 for (i = 0; i <= UI_last_entry; i ++)
 {
  if (trans_text[i])
  {
   free(trans_text[i]);
   trans_text[i] = ((void *)0);
  }
 }
}

canonical_original_code:
void uistring_shutdown()
{
 int i;
 for (i = 0; i <= UI_last_entry; i ++)
 {
  if (trans_text[i])
  {
   free(trans_text[i]);
   trans_text[i] = ((void *)0);
  }
 }
}


decompiled_code:
char *__fastcall ui_getstring(int a1)
{
char *result; // rax

result = (char *)trans_text[a1];
if ( !result )
result = default_text[a1];
return result;
}

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

result = (char *)trans_text[a1];
if ( !result )
result = default_text[a1];
return result;
}

original_code:
const char * ui_getstring (int string_num)
{
 if (trans_text[string_num] != ((void *)0))
  return trans_text[string_num];
 else
  return default_text[string_num];
}

canonical_original_code:
char *ui_getstring(int string_num)
{
 if (trans_text[string_num] != ((void *)0))
  return trans_text[string_num];
 else
  return default_text[string_num];
}

return_type: char *


decompiled_code:
void *__fastcall pkunwar_flipscreen_w(__int64 a1, char a2)
{
void *result; // rax

result = (void *)(a2 & 1);
if ( flipscreen != (_DWORD)result )
{
flipscreen = a2 & 1;
result = memset(dirtybuffer, 1, videoram_size);
}
if ( dword_834 != (a2 & 2) )
{
dword_834 = a2 & 2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(__int64 a1, char a2)
{
void *result; // rax

result = (void *)(a2 & 1);
if ( flipscreen != (_DWORD)result )
{
flipscreen = a2 & 1;
result = memset(dirtybuffer, 1, videoram_size);
}
if ( dword_834 != (a2 & 2) )
{
dword_834 = a2 & 2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

original_code:
void pkunwar_flipscreen_w(offs_t offset,data_t data)
{
 if (flipscreen[0] != (data & 1))
 {
  flipscreen[0] = data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
 if (flipscreen[1] != (data & 2))
 {
  flipscreen[1] = data & 2;
  memset(dirtybuffer,1,videoram_size);
 }
}

canonical_original_code:
void pkunwar_flipscreen_w(unsigned int offset, unsigned int data)
{
 if (flipscreen[0] != (data & 1))
 {
  flipscreen[0] = data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
 if (flipscreen[1] != (data & 2))
 {
  flipscreen[1] = data & 2;
  memset(dirtybuffer,1,videoram_size);
 }
}

variable_types:
offset
unsigned int


decompiled_code:
void *__fastcall pkunwar_vh_screenrefresh(__int64 a1)
{
__int64 v1; // r12
int v2; // ebx
__int64 v3; // r12
unsigned __int64 v4; // r14
__int16 v5; // dx
unsigned __int8 v6; // cl
void *result; // rax
int v8; // ebx
__int64 v9; // r13
__int16 v10; // dx

v1 = a1;
v2 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
*(_BYTE *)(v3 + dirtybuffer) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
((*(unsigned __int8 *)(colorram + v3) << 8) & 0x700) + (unsigned int)*(unsigned __int8 *)(videoram + v3),
*(_BYTE *)(colorram + v3) >> 4);
}
--v2;
--v3;
}
while ( v2 != -1 );
v1 = a1;
}
copybitmap(v1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
if ( spriteram_size )
{
v4 = 0LL;
do
{
v6 = *(_BYTE *)(spriteram + v4);
v5 = *(unsigned __int8 *)(spriteram + v4 + 3);
v4 += 32LL;
drawgfx(v1, *(_QWORD *)(Machine + 520LL), (v6 >> 2) + ((v5 << 6) & 0x1C0u), (unsigned __int8)v5 >> 4);
}
while ( spriteram_size > v4 );
}
result = &videoram_size;
v8 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v9 = v8;
do
{
result = (void *)colorram;
v10 = *(unsigned __int8 *)(colorram + v9);
if ( (v10 & 8) != 0 )
result = (void *)drawgfx(
v1,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v9) + ((v10 << 8) & 0x700u),
(unsigned __int8)v10 >> 4);
--v8;
--v9;
}
while ( v8 != -1 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1)
{
__int64 v1; // r12
int v2; // ebx
__int64 v3; // r12
unsigned __int64 v4; // r14
__int16 v5; // dx
unsigned __int8 v6; // cl
void *result; // rax
int v8; // ebx
__int64 v9; // r13
__int16 v10; // dx

v1 = a1;
v2 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
*(_BYTE *)(v3 + dirtybuffer) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
((*(unsigned __int8 *)(colorram + v3) << 8) & 0x700) + (unsigned int)*(unsigned __int8 *)(videoram + v3),
*(_BYTE *)(colorram + v3) >> 4);
}
--v2;
--v3;
}
while ( v2 != -1 );
v1 = a1;
}
copybitmap(v1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
if ( spriteram_size )
{
v4 = 0LL;
do
{
v6 = *(_BYTE *)(spriteram + v4);
v5 = *(unsigned __int8 *)(spriteram + v4 + 3);
v4 += 32LL;
drawgfx(v1, *(_QWORD *)(Machine + 520LL), (v6 >> 2) + ((v5 << 6) & 0x1C0u), (unsigned __int8)v5 >> 4);
}
while ( spriteram_size > v4 );
}
result = &videoram_size;
v8 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v9 = v8;
do
{
result = (void *)colorram;
v10 = *(unsigned __int8 *)(colorram + v9);
if ( (v10 & 8) != 0 )
result = (void *)drawgfx(
v1,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v9) + ((v10 << 8) & 0x700u),
(unsigned __int8)v10 >> 4);
--v8;
--v9;
}
while ( v8 != -1 );
}
return result;
}

original_code:
void pkunwar_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx,sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen[0]) sx = 31 - sx;
   if (flipscreen[1]) sy = 31 - sy;
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x07) << 8),
     (colorram[offs] & 0xf0) >> 4,
     flipscreen[0],flipscreen[1],
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0;offs < spriteram_size;offs += 32)
 {
  int sx,sy,flipx,flipy;
  sx = ((spriteram[offs + 1] + 8) & 0xff) - 8;
  sy = spriteram[offs + 2];
  flipx = spriteram[offs] & 0x01;
  flipy = spriteram[offs] & 0x02;
  if (flipscreen[0])
  {
   sx = 240 - sx;
   flipx = !flipx;
  }
  if (flipscreen[1])
  {
   sy = 240 - sy;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    ((spriteram[offs] & 0xfc) >> 2) + ((spriteram[offs + 3] & 0x07) << 6),
    (spriteram[offs + 3] & 0xf0) >> 4,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (colorram[offs] & 0x08)
  {
   int sx,sy;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen[0]) sx = 31 - sx;
   if (flipscreen[1]) sy = 31 - sy;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x07) << 8),
     (colorram[offs] & 0xf0) >> 4,
     flipscreen[0],flipscreen[1],
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_PEN,0);
  }
 }
}

canonical_original_code:
void pkunwar_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx; int sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen[0]) sx = 31 - sx;
   if (flipscreen[1]) sy = 31 - sy;
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x07) << 8),
     (colorram[offs] & 0xf0) >> 4,
     flipscreen[0],flipscreen[1],
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0;offs < spriteram_size;offs += 32)
 {
  int sx; int sy; int flipx; int flipy;
  sx = ((spriteram[offs + 1] + 8) & 0xff) - 8;
  sy = spriteram[offs + 2];
  flipx = spriteram[offs] & 0x01;
  flipy = spriteram[offs] & 0x02;
  if (flipscreen[0])
  {
   sx = 240 - sx;
   flipx = !flipx;
  }
  if (flipscreen[1])
  {
   sy = 240 - sy;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    ((spriteram[offs] & 0xfc) >> 2) + ((spriteram[offs + 3] & 0x07) << 6),
    (spriteram[offs + 3] & 0xf0) >> 4,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (colorram[offs] & 0x08)
  {
   int sx; int sy;
   sx = offs % 32;
   sy = offs / 32;
   if (flipscreen[0]) sx = 31 - sx;
   if (flipscreen[1]) sy = 31 - sy;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x07) << 8),
     (colorram[offs] & 0xf0) >> 4,
     flipscreen[0],flipscreen[1],
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_PEN,0);
  }
 }
}


decompiled_code:
__int64 __fastcall invinco_sh_port2_w(__int64 a1, int a2)
{
char v2; // bl
char v3; // bl
__int64 result; // rax

v2 = port2State_0;
port2State_0 = a2;
v3 = a2 ^ (a2 | v2);
if ( (v3 & 4) != 0 )
{
result = sample_start(0LL, 0LL, 0LL);
if ( (v3 & 8) == 0 )
{
LABEL_3:
if ( (v3 & 0x10) == 0 )
goto LABEL_4;
goto LABEL_10;
}
}
else if ( (v3 & 8) == 0 )
{
goto LABEL_3;
}
result = sample_start(1LL, 1LL, 0LL);
if ( (v3 & 0x10) == 0 )
{
LABEL_4:
if ( (v3 & 0x20) == 0 )
goto LABEL_5;
goto LABEL_11;
}
LABEL_10:
result = sample_start(2LL, 2LL, 0LL);
if ( (v3 & 0x20) == 0 )
{
LABEL_5:
if ( (v3 & 0x40) == 0 )
goto LABEL_6;
goto LABEL_12;
}
LABEL_11:
result = sample_start(3LL, 3LL, 0LL);
if ( (v3 & 0x40) == 0 )
{
LABEL_6:
if ( (v3 & 0x80) == 0 )
return result;
return sample_start(5LL, 5LL, 0LL);
}
LABEL_12:
result = sample_start(4LL, 4LL, 0LL);
if ( (v3 & 0x80) != 0 )
return sample_start(5LL, 5LL, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
char v2; // bl
char v3; // bl
__int64 result; // rax

v2 = port2State_0;
port2State_0 = a2;
v3 = a2 ^ (a2 | v2);
if ( (v3 & 4) != 0 )
{
result = sample_start(0LL, 0LL, 0LL);
if ( (v3 & 8) == 0 )
{
LABEL_3:
if ( (v3 & 0x10) == 0 )
goto LABEL_4;
goto LABEL_10;
}
}
else if ( (v3 & 8) == 0 )
{
goto LABEL_3;
}
result = sample_start(1LL, 1LL, 0LL);
if ( (v3 & 0x10) == 0 )
{
LABEL_4:
if ( (v3 & 0x20) == 0 )
goto LABEL_5;
goto LABEL_11;
}
LABEL_10:
result = sample_start(2LL, 2LL, 0LL);
if ( (v3 & 0x20) == 0 )
{
LABEL_5:
if ( (v3 & 0x40) == 0 )
goto LABEL_6;
goto LABEL_12;
}
LABEL_11:
result = sample_start(3LL, 3LL, 0LL);
if ( (v3 & 0x40) == 0 )
{
LABEL_6:
if ( (v3 & 0x80) == 0 )
return result;
return sample_start(5LL, 5LL, 0LL);
}
LABEL_12:
result = sample_start(4LL, 4LL, 0LL);
if ( (v3 & 0x80) != 0 )
return sample_start(5LL, 5LL, 0LL);
return result;
}

original_code:
void invinco_sh_port2_w(offs_t offset,data_t data)
{
 static int port2State = 0;
 int bitsChanged;
 int bitsGoneHigh;
 int bitsGoneLow;
 bitsChanged = port2State ^ data;
 bitsGoneHigh = bitsChanged & data;
 bitsGoneLow = bitsChanged & ~data;
 port2State = data;
 if ( bitsGoneLow & 0x04 )
 {
  sample_start( SND_SAUCER, SND_SAUCER, 0 );
 }
 if ( bitsGoneLow & 0x08 )
 {
  sample_start( SND_MOVE1, SND_MOVE1, 0 );
 }
 if ( bitsGoneLow & 0x10 )
 {
  sample_start( SND_MOVE2, SND_MOVE2, 0 );
 }
 if ( bitsGoneLow & 0x20 )
 {
  sample_start( SND_FIRE, SND_FIRE, 0 );
 }
 if ( bitsGoneLow & 0x40 )
 {
  sample_start( SND_INVHIT, SND_INVHIT, 0 );
 }
 if ( bitsGoneLow & 0x80 )
 {
  sample_start( SND_SHIPHIT, SND_SHIPHIT, 0 );
 }
}

canonical_original_code:
void invinco_sh_port2_w(unsigned int offset, unsigned int data)
{
 static int port2State = 0;
 int bitsChanged;
 int bitsGoneHigh;
 int bitsGoneLow;
 bitsChanged = port2State ^ data;
 bitsGoneHigh = bitsChanged & data;
 bitsGoneLow = bitsChanged & ~data;
 port2State = data;
 if ( bitsGoneLow & 0x04 )
 {
  sample_start( SND_SAUCER, SND_SAUCER, 0 );
 }
 if ( bitsGoneLow & 0x08 )
 {
  sample_start( SND_MOVE1, SND_MOVE1, 0 );
 }
 if ( bitsGoneLow & 0x10 )
 {
  sample_start( SND_MOVE2, SND_MOVE2, 0 );
 }
 if ( bitsGoneLow & 0x20 )
 {
  sample_start( SND_FIRE, SND_FIRE, 0 );
 }
 if ( bitsGoneLow & 0x40 )
 {
  sample_start( SND_INVHIT, SND_INVHIT, 0 );
 }
 if ( bitsGoneLow & 0x80 )
 {
  sample_start( SND_SHIPHIT, SND_SHIPHIT, 0 );
 }
}

variable_types: bitsChanged int

variable_types: bitsGoneHigh int

variable_types: bitsGoneLow int


original_code:
void pooyan_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = (*(color_prom++) & 0x0f) + 0x10;
}

canonical_original_code:
void pooyan_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + i]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + i]) = (*(color_prom++) & 0x0f) + 0x10;
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *

variable_types: i int


decompiled_code:
void *__fastcall pooyan_flipscreen_w(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = a2 & 1;
if ( v2 != flipscreen )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = a2 & 1;
if ( v2 != flipscreen )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

original_code:
void pooyan_flipscreen_w(offs_t offset,data_t data)
{
 if (flipscreen != (data & 1))
 {
  flipscreen = data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
}

canonical_original_code:
void pooyan_flipscreen_w(unsigned int offset, unsigned int data)
{
 if (flipscreen != (data & 1))
 {
  flipscreen = data & 1;
  memset(dirtybuffer,1,videoram_size);
 }
}

variable_types:
data
unsigned int


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

if ( lastdata_0 != a2 )
{
osd_led_w(0LL, ~((a2 >> 4) & 1));
osd_led_w(1LL, ~((a2 >> 5) & 1));
coin_counter_w(0LL, a2 & 1);
result = coin_counter_w(1LL, a2 & 2);
lastdata_0 = a2;
}
return result;
}

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

if ( lastdata_0 != a2 )
{
osd_led_w(0LL, ~((a2 >> 4) & 1));
osd_led_w(1LL, ~((a2 >> 5) & 1));
coin_counter_w(0LL, a2 & 1);
result = coin_counter_w(1LL, a2 & 2);
lastdata_0 = a2;
}
return result;
}

original_code:
void bwidow_misc_w(offs_t offset,data_t data)
{
 static int lastdata;
 if (data == lastdata) return;
 osd_led_w (0, ~((data & 0x10) >> 4));
 osd_led_w (1, ~((data & 0x20) >> 5));
 coin_counter_w (0, data & 0x01);
 coin_counter_w (1, data & 0x02);
 lastdata = data;
}

canonical_original_code:
void bwidow_misc_w(unsigned int offset, unsigned int data)
{
 static int lastdata;
 if (data == lastdata) return;
 osd_led_w (0, ~((data & 0x10) >> 4));
 osd_led_w (1, ~((data & 0x20) >> 5));
 coin_counter_w (0, data & 0x01);
 coin_counter_w (1, data & 0x02);
 lastdata = data;
}

variable_types: lastdata int


decompiled_code:
__int64 __fastcall spacduel_IN3_r(char a1)
{
char v1; // bp
char v2; // al
__int64 result; // rax
unsigned int v4; // ecx
bool v5; // zf
unsigned int v6; // ecx

v1 = readinputport(3LL);
v2 = readinputport(4LL);
switch ( a1 & 7 )
{
case 0:
result = v1 & 8;
if ( (v1 & 8) != 0 )
result = 128LL;
if ( (v1 & 4) != 0 )
result = (unsigned int)result | 0x40;
break;
case 1:
v4 = v2 & 8;
if ( (v2 & 8) != 0 )
v4 = 128;
v5 = (v2 & 4) == 0;
result = v4;
if ( !v5 )
result = v4 | 0x40;
break;
case 2:
result = v1 & 1;
if ( (v1 & 1) != 0 )
result = 128LL;
if ( (v1 & 2) != 0 )
result = (unsigned int)result | 0x40;
break;
case 3:
v6 = v2 & 1;
if ( (v2 & 1) != 0 )
v6 = 128;
v5 = (v2 & 2) == 0;
result = v6;
if ( !v5 )
result = v6 | 0x40;
break;
case 4:
result = v1 & 0x10;
if ( (v1 & 0x10) != 0 )
result = 128LL;
if ( (v1 & 0x20) != 0 )
result = (unsigned int)result | 0x40;
break;
case 5:
result = (unsigned __int8)(8 * v2) & 0x80;
break;
case 6:
result = (unsigned __int8)(2 * v1) & 0x80;
break;
default:
JUMPOUT(0x164LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
char v1; // bp
char v2; // al
__int64 result; // rax
unsigned int v4; // ecx
bool v5; // zf
unsigned int v6; // ecx

v1 = readinputport(3LL);
v2 = readinputport(4LL);
switch ( a1 & 7 )
{
case 0:
result = v1 & 8;
if ( (v1 & 8) != 0 )
result = 128LL;
if ( (v1 & 4) != 0 )
result = (unsigned int)result | 0x40;
break;
case 1:
v4 = v2 & 8;
if ( (v2 & 8) != 0 )
v4 = 128;
v5 = (v2 & 4) == 0;
result = v4;
if ( !v5 )
result = v4 | 0x40;
break;
case 2:
result = v1 & 1;
if ( (v1 & 1) != 0 )
result = 128LL;
if ( (v1 & 2) != 0 )
result = (unsigned int)result | 0x40;
break;
case 3:
v6 = v2 & 1;
if ( (v2 & 1) != 0 )
v6 = 128;
v5 = (v2 & 2) == 0;
result = v6;
if ( !v5 )
result = v6 | 0x40;
break;
case 4:
result = v1 & 0x10;
if ( (v1 & 0x10) != 0 )
result = 128LL;
if ( (v1 & 0x20) != 0 )
result = (unsigned int)result | 0x40;
break;
case 5:
result = (unsigned __int8)(8 * v2) & 0x80;
break;
case 6:
result = (unsigned __int8)(2 * v1) & 0x80;
break;
default:
JUMPOUT(0x164LL);
}
return result;
}

original_code:
static data_t spacduel_IN3_r(offs_t offset) {
 int res;
 int res1;
 int res2;
 res1 = readinputport(3);
 res2 = readinputport(4);
 res = 0x00;
 switch (offset & 0x07) {
  case 0:
   if (res1 & (1 << 3)) res |= 0x80;
   if (res1 & (1 << 2)) res |= 0x40;
   break;
  case 1:
   if (res2 & (1 << 3)) res |= 0x80;
   if (res2 & (1 << 2)) res |= 0x40;
   break;
  case 2:
   if (res1 & (1 << 0)) res |= 0x80;
   if (res1 & (1 << 1)) res |= 0x40;
   break;
  case 3:
   if (res2 & (1 << 0)) res |= 0x80;
   if (res2 & (1 << 1)) res |= 0x40;
   break;
  case 4:
   if (res1 & (1 << 4)) res |= 0x80;
   if (res1 & (1 << 5)) res |= 0x40;
   break;
  case 5:
   if (res2 & (1 << 4)) res |= 0x80;
   break;
  case 6:
   if (res1 & (1 << 6)) res |= 0x80;
   break;
  case 7:
   res = (0x00 | (0 & 0x40));
   break;
  }
 return res;
 }

canonical_original_code:
static unsigned int spacduel_IN3_r(unsigned int offset) {
 int res;
 int res1;
 int res2;
 res1 = readinputport(3);
 res2 = readinputport(4);
 res = 0x00;
 switch (offset & 0x07) {
  case 0:
   if (res1 & (1 << 3)) res |= 0x80;
   if (res1 & (1 << 2)) res |= 0x40;
   break;
  case 1:
   if (res2 & (1 << 3)) res |= 0x80;
   if (res2 & (1 << 2)) res |= 0x40;
   break;
  case 2:
   if (res1 & (1 << 0)) res |= 0x80;
   if (res1 & (1 << 1)) res |= 0x40;
   break;
  case 3:
   if (res2 & (1 << 0)) res |= 0x80;
   if (res2 & (1 << 1)) res |= 0x40;
   break;
  case 4:
   if (res1 & (1 << 4)) res |= 0x80;
   if (res1 & (1 << 5)) res |= 0x40;
   break;
  case 5:
   if (res2 & (1 << 4)) res |= 0x80;
   break;
  case 6:
   if (res1 & (1 << 6)) res |= 0x80;
   break;
  case 7:
   res = (0x00 | (0 & 0x40));
   break;
  }
 return res;
 }

variable_types: res int

return_type: unsigned int


decompiled_code:
__int64 __fastcall coin_2_w(__int64 a1, char a2)
{
return coin_counter_w(1LL, a2 & 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char a2)
{
return coin_counter_w(1LL, a2 & 1);
}

original_code:
static void coin_2_w(offs_t offset,data_t data)
{
 coin_counter_w(1,data & 1);
}

canonical_original_code:
static void coin_2_w(unsigned int offset, unsigned int data)
{
 coin_counter_w(1,data & 1);
}


decompiled_code:
__int64 __fastcall coin_1_w(__int64 a1, char a2)
{
return coin_counter_w(0LL, a2 & 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char a2)
{
return coin_counter_w(0LL, a2 & 1);
}

original_code:
static void coin_1_w(offs_t offset,data_t data)
{
 coin_counter_w(0,data & 1);
}

canonical_original_code:
static void coin_1_w(unsigned int offset, unsigned int data)
{
 coin_counter_w(0,data & 1);
}


repo: libtrading/libtrading

original_code:
static unsigned long fix_new_order_single_const_fields(struct fix_field *fields)
{
 unsigned long nr = 0;
 fields[nr++] = (struct fix_field) { .tag = 50, .type = FIX_TYPE_STRING, { .string_value = "AAA" }, };
 fields[nr++] = (struct fix_field) { .tag = 57, .type = FIX_TYPE_STRING, { .string_value = "CME" }, };
 fields[nr++] = (struct fix_field) { .tag = 142, .type = FIX_TYPE_STRING, { .string_value = "CH" }, };
 fields[nr++] = (struct fix_field) { .tag = Account, .type = FIX_TYPE_STRING, { .string_value = "1234567" }, };
 fields[nr++] = (struct fix_field) { .tag = 21, .type = FIX_TYPE_CHAR, { .char_value = 'Y' }, };
 fields[nr++] = (struct fix_field) { .tag = OrdType, .type = FIX_TYPE_CHAR, { .char_value = '2' }, };
 fields[nr++] = (struct fix_field) { .tag = 1028, .type = FIX_TYPE_CHAR, { .char_value = 'Y' }, };
 fields[nr++] = (struct fix_field) { .tag = 1091, .type = FIX_TYPE_CHAR, { .char_value = 'N' }, };
 fields[nr++] = (struct fix_field) { .tag = 167, .type = FIX_TYPE_STRING, { .string_value = "FUT" }, };
 fields[nr++] = (struct fix_field) { .tag = 204, .type = FIX_TYPE_CHAR, { .char_value = '0' }, };
 fields[nr++] = (struct fix_field) { .tag = 9702, .type = FIX_TYPE_CHAR, { .char_value = '4' }, };
 return nr;
}

variable_types: struct fix_field { int tag; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; } *

variable_types:
nr
unsigned long

return_type: unsigned long

user_defined_types: struct fix_field { int tag; enum fix_type type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; }


original_code:
static unsigned long fix_new_order_single_variable_fields(struct fix_field *fields)
{
 unsigned long nr = 0;
 fields[nr++] = (struct fix_field) { .tag = Side, .type = FIX_TYPE_CHAR, { .char_value = '1' }, };
 fields[nr++] = (struct fix_field) { .tag = Symbol, .type = FIX_TYPE_STRING, { .string_value = "ES" }, };
 fields[nr++] = (struct fix_field) { .tag = 107, .type = FIX_TYPE_STRING, { .string_value = "ESM5" }, };
 fields[nr++] = (struct fix_field) { .tag = ClOrdID, .type = FIX_TYPE_STRING, { .string_value = "ClOrdID" }, };
 fields[nr++] = (struct fix_field) { .tag = 9717, .type = FIX_TYPE_STRING, { .string_value = "ClOrdID" }, };
 fields[nr++] = (struct fix_field) { .tag = OrderQty, .type = FIX_TYPE_FLOAT, { .float_value = 1 }, };
 fields[nr++] = (struct fix_field) { .tag = Price, .type = FIX_TYPE_FLOAT, { .float_value = 10000 }, };
 return nr;
}

user_defined_types: enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 }


decompiled_code:
_QWORD *new_order_single_message()
{
_QWORD *v0; // rbx
__int64 v1; // rbp
_QWORD *result; // rax
__m128i v3; // [rsp+0h] [rbp-58h] BYREF
char v4[8]; // [rsp+10h] [rbp-48h] BYREF

strcpy(v4, "3.000");
v3 = _mm_load_si128((const __m128i *)&LC13);
v0 = calloc(0x30uLL, 0x10uLL);
v1 = fix_new_order_single_fields(v0, (__int64)&v3);
result = (_QWORD *)fix_message_new();
result[1] = "FIX.4.2";
*result = 8LL;
result[4] = "DLD_TEX";
result[5] = "TEX_DLD";
result[6] = 499650LL;
result[8] = &v3;
result[12] = v0;
result[11] = v1;
return result;
}

canonical_decompiled_code:
_QWORD *func4()
{
_QWORD *v0; // rbx
__int64 v1; // rbp
_QWORD *result; // rax
__m128i v3; // [rsp+0h] [rbp-58h] BYREF
char v4[8]; // [rsp+10h] [rbp-48h] BYREF

strcpy(v4, "3.000");
v3 = _mm_load_si128((const __m128i *)&LC13);
v0 = calloc(0x30uLL, 0x10uLL);
v1 = func1(v0, (__int64)&v3);
result = (_QWORD *)fix_message_new();
result[1] = "FIX.4.2";
*result = 8LL;
result[4] = "DLD_TEX";
result[5] = "TEX_DLD";
result[6] = 499650LL;
result[8] = &v3;
result[12] = v0;
result[11] = v1;
return result;
}

original_code:
static struct fix_message *new_order_single_message(void)
{
 struct fix_field *fields = ((void *)0);
 struct fix_message *msg;
 char now[64];
 size_t nr;
 snprintf(now, 64, "20121227-11:20:43.000");
 fields = calloc(48, sizeof(struct fix_field));
 nr = fix_new_order_single_fields(fields, now);
 msg = fix_message_new();
 msg->begin_string = "FIX.4.2";
 msg->type = FIX_MSG_TYPE_NEW_ORDER_SINGLE;
 msg->sender_comp_id = "DLD_TEX";
 msg->target_comp_id = "TEX_DLD";
 msg->msg_seq_num = 499650;
 msg->str_now = now;
 msg->fields = fields;
 msg->nr_fields = nr;
 return msg;
}

canonical_original_code:
static struct fix_message *new_order_single_message()
{
 struct fix_field *fields = ((void *)0);
 struct fix_message *msg;
 char now[64];
 unsigned long nr;
 snprintf(now, 64, "20121227-11:20:43.000");
 fields = calloc(48, sizeof(struct fix_field));
 nr = fix_new_order_single_fields(fields, now);
 msg = fix_message_new();
 msg->begin_string = "FIX.4.2";
 msg->type = FIX_MSG_TYPE_NEW_ORDER_SINGLE;
 msg->sender_comp_id = "DLD_TEX";
 msg->target_comp_id = "TEX_DLD";
 msg->msg_seq_num = 499650;
 msg->str_now = now;
 msg->fields = fields;
 msg->nr_fields = nr;
 return msg;
}

variable_types: struct fix_message { enum fix_msg_type { FIX_MSG_TYPE_HEARTBEAT=0, FIX_MSG_TYPE_TEST_REQUEST=1, FIX_MSG_TYPE_RESEND_REQUEST=2, FIX_MSG_TYPE_REJECT=3, FIX_MSG_TYPE_SEQUENCE_RESET=4, FIX_MSG_TYPE_LOGOUT=5, FIX_MSG_TYPE_EXECUTION_REPORT=6, FIX_MSG_TYPE_LOGON=7, FIX_MSG_TYPE_NEW_ORDER_SINGLE=8, FIX_MSG_TYPE_SNAPSHOT_REFRESH=9, FIX_MSG_TYPE_INCREMENT_REFRESH=10, FIX_MSG_TYPE_SESSION_STATUS=11, FIX_MSG_TYPE_SECURITY_STATUS=12, FIX_MSG_ORDER_CANCEL_REPLACE=13, FIX_MSG_ORDER_CANCEL_REJECT=14, FIX_MSG_ORDER_CANCEL_REQUEST=15, FIX_MSG_ORDER_MASS_CANCEL_REQUEST=16, FIX_MSG_ORDER_MASS_CANCEL_REPORT=17, FIX_MSG_QUOTE_REQUEST=18, FIX_MSG_SECURITY_DEFINITION_REQUEST=19, FIX_MSG_NEW_ORDER_CROSS=20, FIX_MSG_MASS_QUOTE=21, FIX_MSG_QUOTE_CANCEL=22, FIX_MSG_SECURITY_DEFINITION=23, FIX_MSG_QUOTE_ACKNOWLEDGEMENT=24, FIX_MSG_ORDER_MASS_STATUS_REQUEST=25, FIX_MSG_ORDER_MASS_ACTION_REQUEST=26, FIX_MSG_ORDER_MASS_ACTION_REPORT=27, FIX_MSG_TYPE_MAX=28, FIX_MSG_TYPE_UNKNOWN=expr } type; char *begin_string; unsigned long body_length; char *msg_type; char *sender_comp_id; char *target_comp_id; unsigned long msg_seq_num; char *check_sum; char *str_now; struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; } *head_buf; struct buffer *body_buf; unsigned long nr_fields; struct fix_field { int tag; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; } *fields; struct iovec { void *iov_base; unsigned long iov_len; } iov[2]; } *

variable_types:
now
char [64]

user_defined_types: struct fix_message { enum fix_msg_type type; char *begin_string; unsigned long body_length; char *msg_type; char *sender_comp_id; char *target_comp_id; unsigned long msg_seq_num; char *check_sum; char *str_now; struct buffer *head_buf; struct buffer *body_buf; unsigned long nr_fields; struct fix_field *fields; struct iovec iov[2]; }


decompiled_code:
int __fastcall fix_message_parse_benchmark(int a1, _QWORD *a2, __int64 a3, int a4)
{
int i; // ebx
__int64 v6; // rax
double v7; // xmm0_8
const char *v8; // rsi
struct timespec tp; // [rsp+10h] [rbp-58h] BYREF
struct timespec v12; // [rsp+20h] [rbp-48h] BYREF

*a2 = 0LL;
clock_gettime(1, &tp);
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
*a2 = 0LL;
fix_message_parse(a3, (char *)&fix_dialects + 32, a2, a4);
}
}
clock_gettime(1, &v12);
v6 = timespec_delta_isra_0(tp.tv_sec, tp.tv_nsec, v12.tv_sec, v12.tv_nsec);
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
v8 = "parse/fast ";
if ( !a4 )
v8 = "parse ";
return printf(LC17, v8, (unsigned int)a1, v7 / (double)a1 / 1000.0);
}

canonical_decompiled_code:
int __fastcall func7(int a1, _QWORD *a2, __int64 a3, int a4)
{
int i; // ebx
__int64 v6; // rax
double v7; // xmm0_8
const char *v8; // rsi
struct timespec tp; // [rsp+10h] [rbp-58h] BYREF
struct timespec v12; // [rsp+20h] [rbp-48h] BYREF

*a2 = 0LL;
clock_gettime(1, &tp);
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
*a2 = 0LL;
fix_message_parse(a3, (char *)&fix_dialects + 32, a2, a4);
}
}
clock_gettime(1, &v12);
v6 = func6(tp.tv_sec, tp.tv_nsec, v12.tv_sec, v12.tv_nsec);
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
v8 = "parse/fast ";
if ( !a4 )
v8 = "parse ";
return printf(LC17, v8, (unsigned int)a1, v7 / (double)a1 / 1000.0);
}

original_code:
static void fix_message_parse_benchmark(const int count, struct buffer *rx_buf, struct fix_message *rx_msg, int flags)
{
 struct timespec start, end;
 uint64_t elapsed_nsec;
 int i;
 rx_buf->start = 0;
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  rx_buf->start = 0;
  fix_message_parse(rx_msg, &fix_dialects[FIX_4_2], rx_buf, flags);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", (flags & FIX_PARSE_FLAG_NO_CSUM ? "parse/fast  " : "parse       "), count, (double)elapsed_nsec/(double)count/1000.0);
}

canonical_original_code:
static void fix_message_parse_benchmark(int count, struct buffer *rx_buf, struct fix_message *rx_msg, int flags)
{
 struct timespec start; struct timespec end;
 unsigned long elapsed_nsec;
 int i;
 rx_buf->start = 0;
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  rx_buf->start = 0;
  fix_message_parse(rx_msg, &fix_dialects[FIX_4_2], rx_buf, flags);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", (flags & FIX_PARSE_FLAG_NO_CSUM ? "parse/fast  " : "parse       "), count, (double)elapsed_nsec/(double)count/1000.0);
}

variable_types: count int

variable_types: struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; } *

variable_types: struct fix_message { enum fix_msg_type { FIX_MSG_TYPE_HEARTBEAT=0, FIX_MSG_TYPE_TEST_REQUEST=1, FIX_MSG_TYPE_RESEND_REQUEST=2, FIX_MSG_TYPE_REJECT=3, FIX_MSG_TYPE_SEQUENCE_RESET=4, FIX_MSG_TYPE_LOGOUT=5, FIX_MSG_TYPE_EXECUTION_REPORT=6, FIX_MSG_TYPE_LOGON=7, FIX_MSG_TYPE_NEW_ORDER_SINGLE=8, FIX_MSG_TYPE_SNAPSHOT_REFRESH=9, FIX_MSG_TYPE_INCREMENT_REFRESH=10, FIX_MSG_TYPE_SESSION_STATUS=11, FIX_MSG_TYPE_SECURITY_STATUS=12, FIX_MSG_ORDER_CANCEL_REPLACE=13, FIX_MSG_ORDER_CANCEL_REJECT=14, FIX_MSG_ORDER_CANCEL_REQUEST=15, FIX_MSG_ORDER_MASS_CANCEL_REQUEST=16, FIX_MSG_ORDER_MASS_CANCEL_REPORT=17, FIX_MSG_QUOTE_REQUEST=18, FIX_MSG_SECURITY_DEFINITION_REQUEST=19, FIX_MSG_NEW_ORDER_CROSS=20, FIX_MSG_MASS_QUOTE=21, FIX_MSG_QUOTE_CANCEL=22, FIX_MSG_SECURITY_DEFINITION=23, FIX_MSG_QUOTE_ACKNOWLEDGEMENT=24, FIX_MSG_ORDER_MASS_STATUS_REQUEST=25, FIX_MSG_ORDER_MASS_ACTION_REQUEST=26, FIX_MSG_ORDER_MASS_ACTION_REPORT=27, FIX_MSG_TYPE_MAX=28, FIX_MSG_TYPE_UNKNOWN=expr } type; char *begin_string; unsigned long body_length; char *msg_type; char *sender_comp_id; char *target_comp_id; unsigned long msg_seq_num; char *check_sum; char *str_now; struct buffer *head_buf; struct buffer *body_buf; unsigned long nr_fields; struct fix_field { int tag; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; } *fields; struct iovec { void *iov_base; unsigned long iov_len; } iov[2]; } *

variable_types: flags int

variable_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__int64 __fastcall fix_message_unparse_benchmark(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rbp
int v6; // ebx
__int64 v7; // rax
double v8; // xmm0_8
struct timespec v10; // [rsp+0h] [rbp-48h] BYREF
struct timespec tp; // [rsp+10h] [rbp-38h] BYREF

v4 = new_order_single_message();
v4[9] = a2;
v5 = v4;
v4[10] = a3;
clock_gettime(1, &v10);
if ( a1 > 0 )
{
v6 = 0;
do
{
++v6;
buffer_reset((_QWORD *)v5[9]);
buffer_reset((_QWORD *)v5[10]);
fix_message_unparse(v5);
}
while ( a1 != v6 );
}
clock_gettime(1, &tp);
v7 = timespec_delta_isra_0(v10.tv_sec, v10.tv_nsec, tp.tv_sec, tp.tv_nsec);
if ( v7 < 0 )
v8 = (double)(int)(v7 & 1 | ((unsigned __int64)v7 >> 1)) + (double)(int)(v7 & 1 | ((unsigned __int64)v7 >> 1));
else
v8 = (double)(int)v7;
printf(LC17, "format ", (unsigned int)a1, v8 / (double)a1 / 1000.0);
return fix_message_free(v5);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rbp
int v6; // ebx
__int64 v7; // rax
double v8; // xmm0_8
struct timespec v10; // [rsp+0h] [rbp-48h] BYREF
struct timespec tp; // [rsp+10h] [rbp-38h] BYREF

v4 = func4();
v4[9] = a2;
v5 = v4;
v4[10] = a3;
clock_gettime(1, &v10);
if ( a1 > 0 )
{
v6 = 0;
do
{
++v6;
func0((_QWORD *)v5[9]);
func0((_QWORD *)v5[10]);
fix_message_unparse(v5);
}
while ( a1 != v6 );
}
clock_gettime(1, &tp);
v7 = func6(v10.tv_sec, v10.tv_nsec, tp.tv_sec, tp.tv_nsec);
if ( v7 < 0 )
v8 = (double)(int)(v7 & 1 | ((unsigned __int64)v7 >> 1)) + (double)(int)(v7 & 1 | ((unsigned __int64)v7 >> 1));
else
v8 = (double)(int)v7;
printf(LC17, "format ", (unsigned int)a1, v8 / (double)a1 / 1000.0);
return fix_message_free(v5);
}

original_code:
static void fix_message_unparse_benchmark(const int count, struct buffer *head_buf, struct buffer *body_buf)
{
 struct timespec start, end;
 struct fix_message *msg;
 uint64_t elapsed_nsec;
 int i;
 msg = new_order_single_message();
 msg->head_buf = head_buf;
 msg->body_buf = body_buf;
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  buffer_reset(msg->head_buf);
  buffer_reset(msg->body_buf);
  fix_message_unparse(msg);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", "format      ", count, (double)elapsed_nsec/(double)count/1000.0);
 fix_message_free(msg);
}

canonical_original_code:
static void fix_message_unparse_benchmark(int count, struct buffer *head_buf, struct buffer *body_buf)
{
 struct timespec start; struct timespec end;
 struct fix_message *msg;
 unsigned long elapsed_nsec;
 int i;
 msg = new_order_single_message();
 msg->head_buf = head_buf;
 msg->body_buf = body_buf;
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  buffer_reset(msg->head_buf);
  buffer_reset(msg->body_buf);
  fix_message_unparse(msg);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", "format      ", count, (double)elapsed_nsec/(double)count/1000.0);
 fix_message_free(msg);
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }

user_defined_types: struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; }

user_defined_types: enum fix_msg_type { FIX_MSG_TYPE_HEARTBEAT=0, FIX_MSG_TYPE_TEST_REQUEST=1, FIX_MSG_TYPE_RESEND_REQUEST=2, FIX_MSG_TYPE_REJECT=3, FIX_MSG_TYPE_SEQUENCE_RESET=4, FIX_MSG_TYPE_LOGOUT=5, FIX_MSG_TYPE_EXECUTION_REPORT=6, FIX_MSG_TYPE_LOGON=7, FIX_MSG_TYPE_NEW_ORDER_SINGLE=8, FIX_MSG_TYPE_SNAPSHOT_REFRESH=9, FIX_MSG_TYPE_INCREMENT_REFRESH=10, FIX_MSG_TYPE_SESSION_STATUS=11, FIX_MSG_TYPE_SECURITY_STATUS=12, FIX_MSG_ORDER_CANCEL_REPLACE=13, FIX_MSG_ORDER_CANCEL_REJECT=14, FIX_MSG_ORDER_CANCEL_REQUEST=15, FIX_MSG_ORDER_MASS_CANCEL_REQUEST=16, FIX_MSG_ORDER_MASS_CANCEL_REPORT=17, FIX_MSG_QUOTE_REQUEST=18, FIX_MSG_SECURITY_DEFINITION_REQUEST=19, FIX_MSG_NEW_ORDER_CROSS=20, FIX_MSG_MASS_QUOTE=21, FIX_MSG_QUOTE_CANCEL=22, FIX_MSG_SECURITY_DEFINITION=23, FIX_MSG_QUOTE_ACKNOWLEDGEMENT=24, FIX_MSG_ORDER_MASS_STATUS_REQUEST=25, FIX_MSG_ORDER_MASS_ACTION_REQUEST=26, FIX_MSG_ORDER_MASS_ACTION_REPORT=27, FIX_MSG_TYPE_MAX=28, FIX_MSG_TYPE_UNKNOWN=expr }

user_defined_types: struct iovec { void *iov_base; unsigned long iov_len; }


decompiled_code:
__int64 __fastcall fix_template_unparse_benchmark(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rbp
int i; // ebx
__int64 v6; // rax
double v7; // xmm0_8
__int64 v8; // rdi
__int64 v9; // rax
unsigned int v10; // eax
struct timespec v12; // [rsp+0h] [rbp-198h] BYREF
struct timespec tp; // [rsp+10h] [rbp-188h] BYREF
char v14[32]; // [rsp+20h] [rbp-178h] BYREF
const char *v15; // [rsp+40h] [rbp-158h]
__int64 v16; // [rsp+58h] [rbp-140h]
__m128i v17; // [rsp+98h] [rbp-100h] BYREF
__int64 v18; // [rsp+A8h] [rbp-F0h]
__int64 v19; // [rsp+B0h] [rbp-E8h]
__int128 v20; // [rsp+B8h] [rbp-E0h]
__int128 v21; // [rsp+C8h] [rbp-D0h]

v4 = (_QWORD *)new_order_single_template_constprop_0();
v19 = 0LL;
v17 = _mm_load_si128((const __m128i *)&LC13);
v18 = 0x3030302E33LL;
v20 = 0LL;
v21 = 0LL;
fix_template_update_time(v4, &v17);
v16 = 499650LL;
v15 = "ABC_DEF";
clock_gettime(1, &v12);
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
++v16;
fix_template_unparse(v4, v14);
}
}
clock_gettime(1, &tp);
v6 = timespec_delta_isra_0(v12.tv_sec, v12.tv_nsec, tp.tv_sec, tp.tv_nsec);
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
printf(LC17, "format/templ", (unsigned int)a1, v7 / (double)a1 / 1000.0);
v8 = v4[9];
buffer_start_isra_0(v8, v4[12]);
v9 = buffer_size_isra_0(v8, v4[10]);
buffer_printf(a2, "%.*s", v9);
v10 = fix_message_parse(a3, (char *)&fix_dialects + 32, a2, 0LL);
printf("template unparse status: %i\n", v10);
return fix_template_free(v4);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rbp
int i; // ebx
__int64 v6; // rax
double v7; // xmm0_8
__int64 v8; // rdi
__int64 v9; // rax
unsigned int v10; // eax
struct timespec v12; // [rsp+0h] [rbp-198h] BYREF
struct timespec tp; // [rsp+10h] [rbp-188h] BYREF
char v14[32]; // [rsp+20h] [rbp-178h] BYREF
const char *v15; // [rsp+40h] [rbp-158h]
__int64 v16; // [rsp+58h] [rbp-140h]
__m128i v17; // [rsp+98h] [rbp-100h] BYREF
__int64 v18; // [rsp+A8h] [rbp-F0h]
__int64 v19; // [rsp+B0h] [rbp-E8h]
__int128 v20; // [rsp+B8h] [rbp-E0h]
__int128 v21; // [rsp+C8h] [rbp-D0h]

v4 = (_QWORD *)func5();
v19 = 0LL;
v17 = _mm_load_si128((const __m128i *)&LC13);
v18 = 0x3030302E33LL;
v20 = 0LL;
v21 = 0LL;
fix_template_update_time(v4, &v17);
v16 = 499650LL;
v15 = "ABC_DEF";
clock_gettime(1, &v12);
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
++v16;
fix_template_unparse(v4, v14);
}
}
clock_gettime(1, &tp);
v6 = func6(v12.tv_sec, v12.tv_nsec, tp.tv_sec, tp.tv_nsec);
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
printf(LC17, "format/templ", (unsigned int)a1, v7 / (double)a1 / 1000.0);
v8 = v4[9];
func10(v8, v4[12]);
v9 = func9(v8, v4[10]);
buffer_printf(a2, "%.*s", v9);
v10 = fix_message_parse(a3, (char *)&fix_dialects + 32, a2, 0LL);
printf("template unparse status: %i\n", v10);
return fix_template_free(v4);
}

original_code:
static void fix_template_unparse_benchmark(const int count, struct buffer *rx_buf, struct fix_message *rx_msg)
{
 struct fix_template *template;
 struct fix_session session;
 struct timespec start, end;
 uint64_t elapsed_nsec;
 int templ_parse;
 int i;
 template = new_order_single_template(session.str_now);
 strncpy(session.str_now, "20121227-11:20:43.000", 64);
 fix_template_update_time(template, session.str_now);
 session.out_msg_seq_num = 499650;
 session.sender_comp_id = "ABC_DEF";
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  session.out_msg_seq_num++;
  fix_template_unparse(template, &session);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", "format/templ", count, (double)elapsed_nsec/(double)count/1000.0);
 buffer_printf(rx_buf, "%.*s", (int)buffer_size(&template->buf), buffer_start(&template->buf));
 templ_parse = fix_message_parse(rx_msg, &fix_dialects[FIX_4_2], rx_buf, 0);
 printf("template unparse status: %i\n", templ_parse);
 fix_template_free(template);
}

canonical_original_code:
static void fix_template_unparse_benchmark(int count, struct buffer *rx_buf, struct fix_message *rx_msg)
{
 struct fix_template *template;
 struct fix_session session;
 struct timespec start; struct timespec end;
 unsigned long elapsed_nsec;
 int templ_parse;
 int i;
 template = new_order_single_template(session.str_now);
 strncpy(session.str_now, "20121227-11:20:43.000", 64);
 fix_template_update_time(template, session.str_now);
 session.out_msg_seq_num = 499650;
 session.sender_comp_id = "ABC_DEF";
 clock_gettime(1, &start);
 for (i = 0; i < count; i++) {
  session.out_msg_seq_num++;
  fix_template_unparse(template, &session);
 }
 clock_gettime(1, &end);
 elapsed_nsec = timespec_delta(&start, &end);
 printf("%-10s %d %f µs/message\n", "format/templ", count, (double)elapsed_nsec/(double)count/1000.0);
 buffer_printf(rx_buf, "%.*s", (int)buffer_size(&template->buf), buffer_start(&template->buf));
 templ_parse = fix_message_parse(rx_msg, &fix_dialects[FIX_4_2], rx_buf, 0);
 printf("template unparse status: %i\n", templ_parse);
 fix_template_free(template);
}

variable_types: struct fix_template { char *marker_body_length; char *marker_msg_seq_num; char *marker_sender_comp_id; char *marker_sending_time; char *marker_transact_time; char *marker_const_start; char *marker_const_end; unsigned long sender_comp_id_len; unsigned char const_csum; struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; } buf; char tx_data[1024]; unsigned long nr_fields; struct fix_field { int tag; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; } fields[48]; struct fix_field csum_field; struct iovec { void *iov_base; unsigned long iov_len; } iov[1]; } *

variable_types: struct fix_session { struct fix_dialect { enum fix_version { FIX_4_0=0, FIX_4_1=1, FIX_4_2=2, FIX_4_3=3, FIX_4_4=4, FIX_5_0=5, FIXT_1_1=6 } version; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } (*tag_type)(int tag); } *dialect; int sockfd; _Bool active; char *password; char *begin_string; char *sender_comp_id; char *target_comp_id; unsigned long in_msg_seq_num; unsigned long out_msg_seq_num; struct buffer { unsigned long start; unsigned long end; unsigned long capacity; char *data; } *rx_buffer; struct buffer *tx_head_buffer; struct buffer *tx_body_buffer; struct fix_message { enum fix_msg_type { FIX_MSG_TYPE_HEARTBEAT=0, FIX_MSG_TYPE_TEST_REQUEST=1, FIX_MSG_TYPE_RESEND_REQUEST=2, FIX_MSG_TYPE_REJECT=3, FIX_MSG_TYPE_SEQUENCE_RESET=4, FIX_MSG_TYPE_LOGOUT=5, FIX_MSG_TYPE_EXECUTION_REPORT=6, FIX_MSG_TYPE_LOGON=7, FIX_MSG_TYPE_NEW_ORDER_SINGLE=8, FIX_MSG_TYPE_SNAPSHOT_REFRESH=9, FIX_MSG_TYPE_INCREMENT_REFRESH=10, FIX_MSG_TYPE_SESSION_STATUS=11, FIX_MSG_TYPE_SECURITY_STATUS=12, FIX_MSG_ORDER_CANCEL_REPLACE=13, FIX_MSG_ORDER_CANCEL_REJECT=14, FIX_MSG_ORDER_CANCEL_REQUEST=15, FIX_MSG_ORDER_MASS_CANCEL_REQUEST=16, FIX_MSG_ORDER_MASS_CANCEL_REPORT=17, FIX_MSG_QUOTE_REQUEST=18, FIX_MSG_SECURITY_DEFINITION_REQUEST=19, FIX_MSG_NEW_ORDER_CROSS=20, FIX_MSG_MASS_QUOTE=21, FIX_MSG_QUOTE_CANCEL=22, FIX_MSG_SECURITY_DEFINITION=23, FIX_MSG_QUOTE_ACKNOWLEDGEMENT=24, FIX_MSG_ORDER_MASS_STATUS_REQUEST=25, FIX_MSG_ORDER_MASS_ACTION_REQUEST=26, FIX_MSG_ORDER_MASS_ACTION_REPORT=27, FIX_MSG_TYPE_MAX=28, FIX_MSG_TYPE_UNKNOWN=expr } type; char *begin_string; unsigned long body_length; char *msg_type; char *sender_comp_id; char *target_comp_id; unsigned long msg_seq_num; char *check_sum; char *str_now; struct buffer *head_buf; struct buffer *body_buf; unsigned long nr_fields; struct fix_field { int tag; enum fix_type { FIX_TYPE_INT=0, FIX_TYPE_FLOAT=1, FIX_TYPE_CHAR=2, FIX_TYPE_STRING=3, FIX_TYPE_CHECKSUM=4, FIX_TYPE_MSGSEQNUM=5, FIX_TYPE_STRING_8=6 } type; union { long int_value; double float_value; char char_value; char *string_value; char string_8_value[8]; }; } *fields; struct iovec { void *iov_base; unsigned long iov_len; } iov[2]; } *rx_message; int heartbtint; struct timespec { long tv_sec; long tv_nsec; } now; char str_now[64]; struct timespec rx_timestamp; struct timespec tx_timestamp; char testreqid[64]; struct timespec tr_timestamp; int tr_pending; enum fix_failure_reason { FIX_SUCCESS=0, FIX_FAILURE_CONN_CLOSED=1, FIX_FAILURE_RECV_ZERO_B=2, FIX_FAILURE_SYSTEM=3, FIX_FAILURE_GARBLED=4 } failure_reason; void *user_data; }

user_defined_types: struct fix_session { struct fix_dialect *dialect; int sockfd; _Bool active; char *password; char *begin_string; char *sender_comp_id; char *target_comp_id; unsigned long in_msg_seq_num; unsigned long out_msg_seq_num; struct buffer *rx_buffer; struct buffer *tx_head_buffer; struct buffer *tx_body_buffer; struct fix_message *rx_message; int heartbtint; struct timespec now; char str_now[64]; struct timespec rx_timestamp; struct timespec tx_timestamp; char testreqid[64]; struct timespec tr_timestamp; int tr_pending; enum fix_failure_reason failure_reason; void *user_data; }

user_defined_types: struct fix_template { char *marker_body_length; char *marker_msg_seq_num; char *marker_sender_comp_id; char *marker_sending_time; char *marker_transact_time; char *marker_const_start; char *marker_const_end; unsigned long sender_comp_id_len; unsigned char const_csum; struct buffer buf; char tx_data[1024]; unsigned long nr_fields; struct fix_field fields[48]; struct fix_field csum_field; struct iovec iov[1]; }

user_defined_types: struct fix_dialect { enum fix_version version; enum fix_type (*tag_type)(int tag); }


decompiled_code:
void __noreturn do_die(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
vprintf(a1, arg);
putchar(10);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
vprintf(a1, arg);
putchar(10);
exit(1);
}

original_code:
void do_die(const char *format, ...)
{
 va_list ap;
 __builtin_va_start(ap,format);
 vprintf(format, ap);
 __builtin_va_end(ap);
 printf("\n");
 exit(1);
}

canonical_original_code:
void do_die(char *format, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,format);
 vprintf(format, ap);
 __builtin_va_end(ap);
 printf("\n");
 exit(1);
}

variable_types:
format
char *


error

decompiled_code:
void __noreturn error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("error: ");
vprintf(format, arg);
putchar(10);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("error: ");
vprintf(format, arg);
putchar(10);
exit(1);
}

original_code:
void error(const char *format, ...)
{
 va_list ap;
 printf("error: ");
 __builtin_va_start(ap,format);
 vprintf(format, ap);
 __builtin_va_end(ap);
 printf("\n");
 exit(1);
}

canonical_original_code:
void error(char *format, ...)
{
 __builtin_va_list ap;
 printf("error: ");
 __builtin_va_start(ap,format);
 vprintf(format, ap);
 __builtin_va_end(ap);
 printf("\n");
 exit(1);
}


decompiled_code:
__int64 __fastcall modp_itoa10(int a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // r10
unsigned __int8 *v3; // rcx
unsigned int v4; // edx
unsigned __int8 *v5; // r8
unsigned int v6; // esi
unsigned __int8 *v7; // rax
__int64 v8; // rcx
__int64 v9; // r10

v2 = a2;
v3 = a2;
v4 = abs32(a1);
do
{
v5 = v3++;
*(v3 - 1) = v4 % 0xA + 48;
v6 = v4;
v4 /= 0xAu;
}
while ( v6 > 9 );
if ( a1 < 0 )
{
v7 = v5 + 2;
*v3 = 45;
v5 = v3;
v3 = v7;
}
*v3 = 0;
strreverse(v2, v5);
return v8 - v9;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // r10
unsigned __int8 *v3; // rcx
unsigned int v4; // edx
unsigned __int8 *v5; // r8
unsigned int v6; // esi
unsigned __int8 *v7; // rax
__int64 v8; // rcx
__int64 v9; // r10

v2 = a2;
v3 = a2;
v4 = abs32(a1);
do
{
v5 = v3++;
*(v3 - 1) = v4 % 0xA + 48;
v6 = v4;
v4 /= 0xAu;
}
while ( v6 > 9 );
if ( a1 < 0 )
{
v7 = v5 + 2;
*v3 = 45;
v5 = v3;
v3 = v7;
}
*v3 = 0;
func0(v2, v5);
return v8 - v9;
}

original_code:
size_t modp_itoa10(int32_t value, char* str)
{
    char* wstr=str;
    uint32_t uvalue = (value < 0) ? (uint32_t)(-value) : (uint32_t)(value);
    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
    if (value < 0) *wstr++ = '-';
    *wstr='\0';
    strreverse(str,wstr-1);
    return (size_t)(wstr - str);
}

canonical_original_code:
unsigned long modp_itoa10(int value, char *str)
{
    char *wstr = str;
    unsigned int uvalue = (value < 0) ? (uint32_t)(-value) : (uint32_t)(value);
    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
    if (value < 0) *wstr++ = '-';
    *wstr='\0';
    strreverse(str,wstr-1);
    return (unsigned long)(wstr - str);
}

variable_types: value int

variable_types:
str
char *

variable_types:
wstr
char *

variable_types:
uvalue
unsigned int


decompiled_code:
__int64 __fastcall modp_uitoa10(unsigned int a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rcx
unsigned __int8 *v3; // r8
unsigned int v4; // edx
__int64 v5; // rcx
__int64 v6; // r10

v2 = a2;
do
{
v3 = v2++;
*(v2 - 1) = a1 % 0xA + 48;
v4 = a1;
a1 /= 0xAu;
}
while ( v4 > 9 );
*v2 = 0;
strreverse(a2, v3);
return v5 - v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rcx
unsigned __int8 *v3; // r8
unsigned int v4; // edx
__int64 v5; // rcx
__int64 v6; // r10

v2 = a2;
do
{
v3 = v2++;
*(v2 - 1) = a1 % 0xA + 48;
v4 = a1;
a1 /= 0xAu;
}
while ( v4 > 9 );
*v2 = 0;
func0(a2, v3);
return v5 - v6;
}

original_code:
size_t modp_uitoa10(uint32_t value, char* str)
{
    char* wstr=str;
    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);
    *wstr='\0';
    strreverse(str, wstr-1);
    return (size_t)(wstr - str);
}

canonical_original_code:
unsigned long modp_uitoa10(unsigned int value, char *str)
{
    char *wstr = str;
    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);
    *wstr='\0';
    strreverse(str, wstr-1);
    return (unsigned long)(wstr - str);
}

variable_types:
value
unsigned int


decompiled_code:
__int64 __fastcall modp_litoa10(__int64 a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // r9
unsigned __int8 *v3; // rcx
unsigned __int64 v4; // rsi
unsigned __int8 *v5; // r8
unsigned __int64 v6; // rax
unsigned __int8 *v7; // rax
__int64 v8; // rcx
__int64 v9; // r9

v2 = a2;
v3 = a2;
v4 = abs64(a1);
do
{
v5 = v3++;
*(v3 - 1) = v4 % 0xA + 48;
v6 = v4;
v4 /= 0xAuLL;
}
while ( v6 > 9 );
if ( a1 < 0 )
{
v7 = v5 + 2;
*v3 = 45;
v5 = v3;
v3 = v7;
}
*v3 = 0;
strreverse(v2, v5);
return v8 - v9;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // r9
unsigned __int8 *v3; // rcx
unsigned __int64 v4; // rsi
unsigned __int8 *v5; // r8
unsigned __int64 v6; // rax
unsigned __int8 *v7; // rax
__int64 v8; // rcx
__int64 v9; // r9

v2 = a2;
v3 = a2;
v4 = abs64(a1);
do
{
v5 = v3++;
*(v3 - 1) = v4 % 0xA + 48;
v6 = v4;
v4 /= 0xAuLL;
}
while ( v6 > 9 );
if ( a1 < 0 )
{
v7 = v5 + 2;
*v3 = 45;
v5 = v3;
v3 = v7;
}
*v3 = 0;
func0(v2, v5);
return v8 - v9;
}

original_code:
size_t modp_litoa10(int64_t value, char* str)
{
    char* wstr=str;
    uint64_t uvalue = (value < 0) ? (uint64_t)(-value) : (uint64_t)(value);
    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
    if (value < 0) *wstr++ = '-';
    *wstr='\0';
    strreverse(str,wstr-1);
    return (size_t)(wstr - str);
}

canonical_original_code:
unsigned long modp_litoa10(long value, char *str)
{
    char *wstr = str;
    unsigned long uvalue = (value < 0) ? (uint64_t)(-value) : (uint64_t)(value);
    do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
    if (value < 0) *wstr++ = '-';
    *wstr='\0';
    strreverse(str,wstr-1);
    return (unsigned long)(wstr - str);
}

variable_types: value long

variable_types:
uvalue
unsigned long


decompiled_code:
__int64 __fastcall modp_ulitoa10(unsigned __int64 a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rcx
unsigned __int8 *v3; // r8
unsigned __int64 v4; // rax
__int64 v5; // rcx
__int64 v6; // r9

v2 = a2;
do
{
v3 = v2++;
*(v2 - 1) = a1 % 0xA + 48;
v4 = a1;
a1 /= 0xAuLL;
}
while ( v4 > 9 );
*v2 = 0;
strreverse(a2, v3);
return v5 - v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // rcx
unsigned __int8 *v3; // r8
unsigned __int64 v4; // rax
__int64 v5; // rcx
__int64 v6; // r9

v2 = a2;
do
{
v3 = v2++;
*(v2 - 1) = a1 % 0xA + 48;
v4 = a1;
a1 /= 0xAuLL;
}
while ( v4 > 9 );
*v2 = 0;
func0(a2, v3);
return v5 - v6;
}

original_code:
size_t modp_ulitoa10(uint64_t value, char* str)
{
    char* wstr=str;
    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);
    *wstr='\0';
    strreverse(str, wstr-1);
    return (size_t)(wstr - str);
}

canonical_original_code:
unsigned long modp_ulitoa10(unsigned long value, char *str)
{
    char *wstr = str;
    do *wstr++ = (char)(48 + (value % 10)); while (value /= 10);
    *wstr='\0';
    strreverse(str, wstr-1);
    return (unsigned long)(wstr - str);
}

variable_types:
value
unsigned long