decompiled_code:
_BOOL8 __fastcall utf8_uppercase_letter(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 65 <= 0x19;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 65 <= 0x19;
}

original_code:
extern int utf8_uppercase_letter( uint_t u )
{
    if ( u > 65280 ) u -= 65248;
    return ( u >= 65 && u <= 90 );
}

canonical_original_code:
extern int utf8_uppercase_letter(unsigned int u)
{
    if ( u > 65280 ) u -= 65248;
    return ( u >= 65 && u <= 90 );
}


repo: Travis-Sun/friso

decompiled_code:
_BOOL8 __fastcall utf8_lowercase_letter(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 97 <= 0x19;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 97 <= 0x19;
}

original_code:
extern int utf8_lowercase_letter( uint_t u )
{
    if ( u > 65280 ) u -= 65248;
    return ( u >= 97 && u <= 122 );
}

canonical_original_code:
extern int utf8_lowercase_letter(unsigned int u)
{
    if ( u > 65280 ) u -= 65248;
    return ( u >= 97 && u <= 122 );
}

variable_types:
u
unsigned int

return_type: int


decompiled_code:
_BOOL8 __fastcall utf8_numeric_letter(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 48 <= 9;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return a1 - 48 <= 9;
}

original_code:
extern int utf8_numeric_letter( uint_t u )
{
    if ( u > 65280 ) u -= 65248;
    return ( ( u >= 48 && u <= 57 ) );
}

canonical_original_code:
extern int utf8_numeric_letter(unsigned int u)
{
    if ( u > 65280 ) u -= 65248;
    return ( ( u >= 48 && u <= 57 ) );
}


decompiled_code:
_BOOL8 __fastcall utf8_en_letter(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return (a1 & 0xFFFFFFDF) - 65 <= 0x19;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(unsigned int a1)
{
if ( a1 > 0xFF00 )
a1 -= 65248;
return (a1 & 0xFFFFFFDF) - 65 <= 0x19;
}


decompiled_code:
__int64 __fastcall utf8_numeric_string(char *a1)
{
char v1; // al
char *v2; // rbx
int v3; // er12
int v4; // eax

v1 = *a1;
if ( !*a1 )
return 1LL;
v2 = a1;
while ( v1 < 0 )
{
v3 = get_utf8_unicode(v2);
v4 = get_utf8_bytes(*v2);
if ( (unsigned int)(v3 - 65296) > 9 )
return 0LL;
LABEL_4:
v2 += v4;
v1 = *v2;
if ( !*v2 )
return 1LL;
}
if ( (unsigned __int8)(v1 - 48) <= 9u )
{
v4 = 1;
goto LABEL_4;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(char *a1)
{
char v1; // al
char *v2; // rbx
int v3; // er12
int v4; // eax

v1 = *a1;
if ( !*a1 )
return 1LL;
v2 = a1;
while ( v1 < 0 )
{
v3 = func2(v2);
v4 = func1(*v2);
if ( (unsigned int)(v3 - 65296) > 9 )
return 0LL;
LABEL_4:
v2 += v4;
v1 = *v2;
if ( !*v2 )
return 1LL;
}
if ( (unsigned __int8)(v1 - 48) <= 9u )
{
v4 = 1;
goto LABEL_4;
}
return 0LL;
}

original_code:
extern int utf8_numeric_string( const fstring str )
{
    fstring s = str;
    int bytes, u;
    while ( *s != '\0' )
    {
 bytes = 1;
 if ( *s < 0 )
 {
     u = get_utf8_unicode(s);
     bytes = get_utf8_bytes(*s);
     if ( u < 65296 || u > 65305 ) return 0;
 }
 else if ( *s < 48 || *s > 57 ) return 0;
 s += bytes;
    }
    return 1;
}

canonical_original_code:
extern int utf8_numeric_string(char *str)
{
    char *s = str;
    int bytes; int u;
    while ( *s != '\0' )
    {
 bytes = 1;
 if ( *s < 0 )
 {
     u = get_utf8_unicode(s);
     bytes = get_utf8_bytes(*s);
     if ( u < 65296 || u > 65305 ) return 0;
 }
 else if ( *s < 48 || *s > 57 ) return 0;
 s += bytes;
    }
    return 1;
}

variable_types:
str
char *

variable_types:
s
char *

variable_types: bytes int

variable_types: u int


decompiled_code:
__int64 __fastcall utf8_decimal_string(const char *a1)
{
int v1; // eax
unsigned int v2; // edx
int v3; // er13
int v4; // er15
int v5; // ebp
char *v6; // rbx
char v7; // al
int v9; // [rsp+Ch] [rbp-3Ch]

v1 = strlen(a1);
v2 = 0;
if ( *a1 != 46 )
{
v3 = v1;
if ( a1[v1 - 1] != 46 )
{
if ( v1 > 1 )
{
v4 = 0;
v5 = 1;
while ( 1 )
{
v6 = (char *)&a1[v5];
v7 = *v6;
if ( *v6 == 46 )
{
++v5;
++v4;
}
else
{
if ( v7 < 0 )
{
v9 = get_utf8_unicode((char *)&a1[v5]);
v2 = get_utf8_bytes(*v6);
if ( (unsigned int)(v9 - 65296) > 9 )
return 0;
}
else if ( (unsigned __int8)(v7 - 48) > 9u )
{
return 0;
}
v5 += v2;
}
v2 = 1;
if ( v5 >= v3 )
goto LABEL_14;
}
}
v4 = 0;
LABEL_14:
v2 = v4 == 1;
}
}
return v2;
}

original_code:
extern int utf8_decimal_string( const fstring str )
{
    int len = strlen(str), i, p = 0;
    int bytes = 0, u;
    if ( str[0] == '.' || str[len-1] == '.' ) return 0;
    for ( i = 1; i < len; bytes = 1 )
    {
 if ( str[i] == '.' )
 {
     i++;
     p++;
     continue;
 }
 else if ( str[i] < 0 )
 {
     u = get_utf8_unicode(str+i);
     bytes = get_utf8_bytes(str[i]);
     if ( u < 65296 || u > 65305 ) return 0;
 }
 else if ( str[i] < 48 || str[i] > 57 ) return 0;
 i += bytes;
    }
    return (p == 1);
}

canonical_original_code:
extern int utf8_decimal_string(char *str)
{
    int len = strlen(str); int i; int p = 0;
    int bytes = 0; int u;
    if ( str[0] == '.' || str[len-1] == '.' ) return 0;
    for ( i = 1; i < len; bytes = 1 )
    {
 if ( str[i] == '.' )
 {
     i++;
     p++;
     continue;
 }
 else if ( str[i] < 0 )
 {
     u = get_utf8_unicode(str+i);
     bytes = get_utf8_bytes(str[i]);
     if ( u < 65296 || u > 65305 ) return 0;
 }
 else if ( str[i] < 48 || str[i] > 57 ) return 0;
 i += bytes;
    }
    return (p == 1);
}

variable_types: len int

variable_types: i int

variable_types: p int


decompiled_code:
__int64 __fastcall utf8_whitespace(int a1)
{
return (a1 == 12288) | (unsigned __int8)(a1 == 32);
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1)
{
return (a1 == 12288) | (unsigned __int8)(a1 == 32);
}

original_code:
extern int utf8_whitespace( uint_t u )
{
    if ( u == 32 || u == 12288 )
 return 1;
    return 0;
}

canonical_original_code:
extern int utf8_whitespace(unsigned int u)
{
    if ( u == 32 || u == 12288 )
 return 1;
    return 0;
}


decompiled_code:
_BOOL8 __fastcall utf8_en_punctuation(int a1)
{
unsigned __int64 v1; // rax
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v1 = (unsigned int)(a1 - 33);
if ( (unsigned int)v1 <= 0x3F && (v2 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v2, v1)) )
result = 1LL;
else
result = (unsigned int)(a1 - 123) <= 3;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(int a1)
{
unsigned __int64 v1; // rax
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v1 = (unsigned int)(a1 - 33);
if ( (unsigned int)v1 <= 0x3F && (v2 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v2, v1)) )
result = 1LL;
else
result = (unsigned int)(a1 - 123) <= 3;
return result;
}


decompiled_code:
_BOOL8 __fastcall utf8_cn_punctuation(int a1)
{
unsigned __int64 v1; // rax
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v1 = (unsigned int)(a1 - 65281);
if ( (unsigned int)v1 <= 0x3F )
{
v2 = 0xFC0000007E007FFFLL;
if ( _bittest64((const __int64 *)&v2, v1) )
return 1LL;
return (unsigned int)(a1 - 12289) <= 0x1E;
}
result = 1LL;
if ( (unsigned int)(a1 - 65371) > 0xA )
return (unsigned int)(a1 - 12289) <= 0x1E;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(int a1)
{
unsigned __int64 v1; // rax
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v1 = (unsigned int)(a1 - 65281);
if ( (unsigned int)v1 <= 0x3F )
{
v2 = 0xFC0000007E007FFFLL;
if ( _bittest64((const __int64 *)&v2, v1) )
return 1LL;
return (unsigned int)(a1 - 12289) <= 0x1E;
}
result = 1LL;
if ( (unsigned int)(a1 - 65371) > 0xA )
return (unsigned int)(a1 - 12289) <= 0x1E;
return result;
}


decompiled_code:
__int64 utf8_other_number()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func18()
{
return 0LL;
}

original_code:
extern int utf8_other_number( uint_t u )
{
    return 0;
}

canonical_original_code:
extern int utf8_other_number(unsigned int u)
{
    return 0;
}


decompiled_code:
__int64 __fastcall utf8_keep_punctuation(__int64 a1)
{
if ( !_keep_punctuations_hash__ )
{
_keep_punctuations_hash__ = new_hash_table();
hash_put_mapping(_keep_punctuations_hash__, &LC0, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC1, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC2, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC3, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC4, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC5, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC6, 0LL);
}
return hash_exist_mapping(_keep_punctuations_hash__, a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
if ( !_keep_punctuations_hash__ )
{
_keep_punctuations_hash__ = new_hash_table();
hash_put_mapping(_keep_punctuations_hash__, &LC0, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC1, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC2, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC3, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC4, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC5, 0LL);
hash_put_mapping(_keep_punctuations_hash__, &LC6, 0LL);
}
return hash_exist_mapping(_keep_punctuations_hash__, a1);
}

original_code:
extern int utf8_keep_punctuation( fstring str )
{
    if ( __keep_punctuations_hash__ == ((void *)0) )
    {
 __keep_punctuations_hash__ = new_hash_table();
 hash_put_mapping( __keep_punctuations_hash__, "@", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "%", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "&", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, ".", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "'", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "#", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "+", ((void *)0) );
    }
    return hash_exist_mapping( __keep_punctuations_hash__, str );
}

canonical_original_code:
extern int utf8_keep_punctuation(char *str)
{
    if ( __keep_punctuations_hash__ == ((void *)0) )
    {
 __keep_punctuations_hash__ = new_hash_table();
 hash_put_mapping( __keep_punctuations_hash__, "@", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "%", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "&", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, ".", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "'", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "#", ((void *)0) );
 hash_put_mapping( __keep_punctuations_hash__, "+", ((void *)0) );
    }
    return hash_exist_mapping( __keep_punctuations_hash__, str );
}


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

if ( !a1 )
return utf8_cjk_string(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_cn_string(a2 + 40);
return result;
}

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

if ( !a1 )
return utf8_cjk_string(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_cn_string(a2 + 40);
return result;
}

original_code:
extern int friso_cn_string(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_cjk_string(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_cn_string(task->buffer);
    return 0;
}

canonical_original_code:
extern int friso_cn_string(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_cjk_string(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_cn_string(task->buffer);
    return 0;
}

variable_types: enum friso_charset_t { FRISO_UTF8=0, FRISO_GBK=1 }

variable_types: struct friso_task_entry { char *text; unsigned int idx; unsigned int length; unsigned int bytes; unsigned int unicode; struct friso_link_entry { struct friso_link_node { void *value; struct friso_link_node *prev; struct friso_link_node *next; } *head; struct friso_link_node *tail; unsigned int size; } *pool; struct friso_hits_entry { int offset; char word[128]; } *hits; char buffer[7]; } *

user_defined_types: struct friso_task_entry { char *text; unsigned int idx; unsigned int length; unsigned int bytes; unsigned int unicode; struct friso_link_entry *pool; struct friso_hits_entry *hits; char buffer[7]; }

user_defined_types: struct friso_link_entry { struct friso_link_node *head; struct friso_link_node *tail; unsigned int size; }


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

if ( !a1 )
return utf8_whitespace(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_whitespace(a2 + 40);
return result;
}

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

if ( !a1 )
return utf8_whitespace(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_whitespace(a2 + 40);
return result;
}

original_code:
extern int friso_whitespace(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_whitespace(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_whitespace(task->buffer);
    return 0;
}

canonical_original_code:
extern int friso_whitespace(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_whitespace(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_whitespace(task->buffer);
    return 0;
}

user_defined_types: enum friso_charset_t { FRISO_UTF8=0, FRISO_GBK=1 }

user_defined_types: struct friso_hits_entry { int offset; char word[128]; }

user_defined_types: struct friso_link_node { void *value; struct friso_link_node *prev; struct friso_link_node *next; }


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

if ( !a1 )
return utf8_en_letter((unsigned int)*(char *)(*(_QWORD *)a2 + *(unsigned int *)(a2 + 8)));
result = 0LL;
if ( a1 == 1 )
result = gbk_en_letter(*(_QWORD *)a2 + *(unsigned int *)(a2 + 8));
return result;
}

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

if ( !a1 )
return utf8_en_letter((unsigned int)*(char *)(*(_QWORD *)a2 + *(unsigned int *)(a2 + 8)));
result = 0LL;
if ( a1 == 1 )
result = gbk_en_letter(*(_QWORD *)a2 + *(unsigned int *)(a2 + 8));
return result;
}

original_code:
extern int friso_en_letter(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_letter( ( uint_t ) task->text[task->idx]);
    else if ( charset == FRISO_GBK )
 return gbk_en_letter( task->text + task->idx );
    return 0;
}

canonical_original_code:
extern int friso_en_letter(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_letter( ( unsigned int ) task->text[task->idx]);
    else if ( charset == FRISO_GBK )
 return gbk_en_letter( task->text + task->idx );
    return 0;
}


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

if ( !a1 )
return utf8_halfwidth_en_char(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_halfwidth_en_char((unsigned int)*(char *)(a2 + 40));
return result;
}

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

if ( !a1 )
return utf8_halfwidth_en_char(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_halfwidth_en_char((unsigned int)*(char *)(a2 + 40));
return result;
}

original_code:
extern int friso_halfwidth_en_char(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_halfwidth_en_char(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_halfwidth_en_char(task->buffer[0]);
    return 0;
}

canonical_original_code:
extern int friso_halfwidth_en_char(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_halfwidth_en_char(task->unicode);
    else if ( charset == FRISO_GBK )
 return gbk_halfwidth_en_char(task->buffer[0]);
    return 0;
}


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

if ( !a1 )
return utf8_fullwidth_en_char(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_fullwidth_en_char(a2 + 40);
return result;
}

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

if ( !a1 )
return utf8_fullwidth_en_char(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_fullwidth_en_char(a2 + 40);
return result;
}

original_code:
extern int friso_fullwidth_en_char(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_fullwidth_en_char( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_fullwidth_en_char( task->buffer );
    return 0;
}

canonical_original_code:
extern int friso_fullwidth_en_char(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_fullwidth_en_char( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_fullwidth_en_char( task->buffer );
    return 0;
}


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

if ( !a1 )
return utf8_en_punctuation(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_en_punctuation((unsigned int)*(char *)(a2 + 40));
return result;
}

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

if ( !a1 )
return utf8_en_punctuation(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_en_punctuation((unsigned int)*(char *)(a2 + 40));
return result;
}

original_code:
extern int friso_en_punctuation(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_punctuation( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_en_punctuation( task->buffer[0] );
    return 0;
}

canonical_original_code:
extern int friso_en_punctuation(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_punctuation( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_en_punctuation( task->buffer[0] );
    return 0;
}


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

if ( !a1 )
return utf8_cn_punctuation(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_cn_punctuation(a2 + 40);
return result;
}

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

if ( !a1 )
return utf8_cn_punctuation(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_cn_punctuation(a2 + 40);
return result;
}

original_code:
extern int friso_cn_punctuation(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_cn_punctuation( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_cn_punctuation( task->buffer );
    return 0;
}

canonical_original_code:
extern int friso_cn_punctuation(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_cn_punctuation( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_cn_punctuation( task->buffer );
    return 0;
}


decompiled_code:
__int64 friso_other_number()
{
return 0LL;
}

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

original_code:
extern int friso_other_number(
 friso_charset_t charset,
 friso_task_t task )
{
    return 0;
}

canonical_original_code:
extern int friso_other_number(enum friso_charset_t charset, struct friso_task_entry *task)
{
    return 0;
}


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

if ( !a1 || (result = 0LL, a1 == 1) )
result = utf8_keep_punctuation(a2 + 40);
return result;
}

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

if ( !a1 || (result = 0LL, a1 == 1) )
result = utf8_keep_punctuation(a2 + 40);
return result;
}

original_code:
extern int friso_keep_punctuation(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_keep_punctuation( task->buffer );
    else if ( charset == FRISO_GBK )
 return utf8_keep_punctuation(task->buffer);
    return 0;
}

canonical_original_code:
extern int friso_keep_punctuation(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_keep_punctuation( task->buffer );
    else if ( charset == FRISO_GBK )
 return utf8_keep_punctuation(task->buffer);
    return 0;
}


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

if ( !a1 )
return utf8_en_punctuation((unsigned int)a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_en_punctuation((unsigned int)a2);
return result;
}

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

if ( !a1 )
return utf8_en_punctuation((unsigned int)a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_en_punctuation((unsigned int)a2);
return result;
}

original_code:
extern int is_en_punctuation(
 friso_charset_t charset, char c )
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_punctuation( (uint_t) c);
    else if ( charset == FRISO_GBK )
 return gbk_en_punctuation( c );
    return 0;
}

canonical_original_code:
extern int is_en_punctuation(enum friso_charset_t charset, char c)
{
    if ( charset == FRISO_UTF8 )
 return utf8_en_punctuation( (unsigned int) c);
    else if ( charset == FRISO_GBK )
 return gbk_en_punctuation( c );
    return 0;
}

variable_types: c char


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

if ( !a1 )
return utf8_numeric_string(a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_numeric_string(a2);
return result;
}

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

if ( !a1 )
return utf8_numeric_string(a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_numeric_string(a2);
return result;
}

original_code:
extern int friso_numeric_string(
 friso_charset_t charset,
 char *buffer )
{
    if ( charset == FRISO_UTF8 )
 return utf8_numeric_string( buffer );
    else if ( charset == FRISO_GBK )
 return gbk_numeric_string( buffer );
    return 0;
}

canonical_original_code:
extern int friso_numeric_string(enum friso_charset_t charset, char *buffer)
{
    if ( charset == FRISO_UTF8 )
 return utf8_numeric_string( buffer );
    else if ( charset == FRISO_GBK )
 return gbk_numeric_string( buffer );
    return 0;
}

variable_types:
buffer
char *


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

if ( !a1 )
return utf8_decimal_string(a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_decimal_string(a2);
return result;
}

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

if ( !a1 )
return utf8_decimal_string(a2);
result = 0LL;
if ( a1 == 1 )
result = gbk_decimal_string(a2);
return result;
}

original_code:
extern int friso_decimal_string(
 friso_charset_t charset, char *buffer )
{
    if ( charset == FRISO_UTF8 )
 return utf8_decimal_string( buffer );
    else if ( charset == FRISO_GBK )
 return gbk_decimal_string( buffer );
    return 0;
}

canonical_original_code:
extern int friso_decimal_string(enum friso_charset_t charset, char *buffer)
{
    if ( charset == FRISO_UTF8 )
 return utf8_decimal_string( buffer );
    else if ( charset == FRISO_GBK )
 return gbk_decimal_string( buffer );
    return 0;
}


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

if ( !a1 )
return utf8_uppercase_letter(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_uppercase_letter(a2 + 40);
return result;
}

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

if ( !a1 )
return utf8_uppercase_letter(*(unsigned int *)(a2 + 20));
result = 0LL;
if ( a1 == 1 )
result = gbk_uppercase_letter(a2 + 40);
return result;
}

original_code:
extern int friso_uppercase_letter(
 friso_charset_t charset,
 friso_task_t task )
{
    if ( charset == FRISO_UTF8 )
 return utf8_uppercase_letter( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_uppercase_letter( task->buffer );
    return 0;
}

canonical_original_code:
extern int friso_uppercase_letter(enum friso_charset_t charset, struct friso_task_entry *task)
{
    if ( charset == FRISO_UTF8 )
 return utf8_uppercase_letter( task->unicode );
    else if ( charset == FRISO_GBK )
 return gbk_uppercase_letter( task->buffer );
    return 0;
}


original_code:
extern int gbk_next_word(
 friso_task_t task,
 uint_t *idx,
 fstring __word )
{
    int c;
    if ( *idx >= task->length ) return 0;
    c = (uchar_t)task->text[*idx];
    if ( c <= 0x80 ) task->bytes = 1;
    else task->bytes = 2;
    memcpy(__word, task->text + (*idx), task->bytes);
    (*idx) += task->bytes;
    __word[task->bytes] = '\0';
    return task->bytes;
}

canonical_original_code:
extern int gbk_next_word(struct friso_task_entry *task, unsigned int *idx, char *__word)
{
    int c;
    if ( *idx >= task->length ) return 0;
    c = (unsigned char)task->text[*idx];
    if ( c <= 0x80 ) task->bytes = 1;
    else task->bytes = 2;
    memcpy(__word, task->text + (*idx), task->bytes);
    (*idx) += task->bytes;
    __word[task->bytes] = '\0';
    return task->bytes;
}

variable_types:
idx
unsigned int *

variable_types: c int


decompiled_code:
_BOOL8 __fastcall gbk_cn_string(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
int v2; // edx
_BOOL4 v3; // edx
unsigned int v5; // ecx

v1 = a1[1];
v2 = *a1;
if ( (unsigned int)(v2 - 176) > 0x47 )
{
if ( (unsigned int)(v2 - 129) <= 0x1F )
return (unsigned int)v1 - 128 <= 0x7E || (unsigned int)v1 - 64 <= 0x3E;
v5 = v2 - 170;
v3 = 0;
if ( v5 > 0x54 )
return v3;
return (unsigned int)v1 - 64 <= 0xBE;
}
v3 = 1;
if ( (unsigned int)v1 - 161 > 0x5D )
return (unsigned int)v1 - 64 <= 0xBE;
return v3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
int v2; // edx
_BOOL4 v3; // edx
unsigned int v5; // ecx

v1 = a1[1];
v2 = *a1;
if ( (unsigned int)(v2 - 176) > 0x47 )
{
if ( (unsigned int)(v2 - 129) <= 0x1F )
return (unsigned int)v1 - 128 <= 0x7E || (unsigned int)v1 - 64 <= 0x3E;
v5 = v2 - 170;
v3 = 0;
if ( v5 > 0x54 )
return v3;
return (unsigned int)v1 - 64 <= 0xBE;
}
v3 = 1;
if ( (unsigned int)v1 - 161 > 0x5D )
return (unsigned int)v1 - 64 <= 0xBE;
return v3;
}


decompiled_code:
_BOOL8 __fastcall gbk_halfwidth_en_char(unsigned __int8 a1)
{
return (unsigned int)a1 - 32 <= 0x5E;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(unsigned __int8 a1)
{
return (unsigned int)a1 - 32 <= 0x5E;
}

original_code:
extern int gbk_halfwidth_en_char( char c )
{
    int u = (uchar_t) c;
    return ( u >= 32 && u <= 126 );
}

canonical_original_code:
extern int gbk_halfwidth_en_char(char c)
{
    int u = (uchar_t) c;
    return ( u >= 32 && u <= 126 );
}


decompiled_code:
__int64 __fastcall gbk_fullwidth_en_char(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 == 0xA3 )
result = ((unsigned int)(unsigned __int8)a1[1] - 176 <= 9) | (unsigned __int8)((unsigned __int8)((a1[1] & 0xDF) + 63) <= 0x19u);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 == 0xA3 )
result = ((unsigned int)(unsigned __int8)a1[1] - 176 <= 9) | (unsigned __int8)((unsigned __int8)((a1[1] & 0xDF) + 63) <= 0x19u);
return result;
}

original_code:
extern int gbk_fullwidth_en_char( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( (c1 == 0xA3)
     && ( (c2 >= 0xB0 && c2 <= 0xB9)
        || ( c2 >= 0xC1 && c2 <= 0xDA )
        || ( c2 >= 0xE1 && c2 <= 0xFA) ) );
}

canonical_original_code:
extern int gbk_fullwidth_en_char(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( (c1 == 0xA3)
     && ( (c2 >= 0xB0 && c2 <= 0xB9)
        || ( c2 >= 0xC1 && c2 <= 0xDA )
        || ( c2 >= 0xE1 && c2 <= 0xFA) ) );
}


decompiled_code:
_BOOL8 __fastcall gbk_uppercase_letter(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 65 <= 0x19;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 193 <= 0x19;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 65 <= 0x19;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 193 <= 0x19;
return result;
}

original_code:
extern int gbk_uppercase_letter( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 65 && c1 <= 90 );
    else
 return ( c1 == 0xa3 && ( c2 >= 0xc1 && c2 <= 0xda ) );
}

canonical_original_code:
extern int gbk_uppercase_letter(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 65 && c1 <= 90 );
    else
 return ( c1 == 0xa3 && ( c2 >= 0xc1 && c2 <= 0xda ) );
}


decompiled_code:
_BOOL8 __fastcall gbk_lowercase_letter(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 97 <= 0x19;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 225 <= 0x19;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 97 <= 0x19;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 225 <= 0x19;
return result;
}

original_code:
extern int gbk_lowercase_letter( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 97 && c1 <= 122 );
    else
 return ( c1 == 0xa3 && ( c2 >= 0xe1 && c2 <= 0xfa ) );
}

canonical_original_code:
extern int gbk_lowercase_letter(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 97 && c1 <= 122 );
    else
 return ( c1 == 0xa3 && ( c2 >= 0xe1 && c2 <= 0xfa ) );
}


decompiled_code:
_BOOL8 __fastcall gbk_numeric_letter(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 48 <= 9;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 176 <= 9;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(unsigned __int8 *a1)
{
unsigned int v1; // edx
_BOOL8 result; // rax

v1 = *a1;
if ( v1 <= 0x80 )
return v1 - 48 <= 9;
result = 0LL;
if ( v1 == 163 )
result = (unsigned int)a1[1] - 176 <= 9;
return result;
}

original_code:
extern int gbk_numeric_letter( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 48 && c1 <= 57 );
    else
 return ( ( c1 == 0xa3 ) && ( c2 >= 0xb0 && c2 <= 0xb9 ) );
}

canonical_original_code:
extern int gbk_numeric_letter(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 )
 return ( c1 >= 48 && c1 <= 57 );
    else
 return ( ( c1 == 0xa3 ) && ( c2 >= 0xb0 && c2 <= 0xb9 ) );
}


decompiled_code:
__int64 __fastcall gbk_numeric_string(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
int v2; // edx

v1 = *a1;
if ( !*a1 )
return 1LL;
v2 = 0;
while ( v1 <= 0x80u )
{
if ( v1 <= 0x2Fu || v2 > 57 )
return 0LL;
++a1;
LABEL_6:
v1 = *a1;
if ( !*a1 )
return 1LL;
}
if ( v1 != 163 )
return 0LL;
v2 = a1[1];
if ( (unsigned int)(v2 - 176) <= 9 )
{
a1 += 2;
goto LABEL_6;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 *a1)
{
unsigned __int8 v1; // al
int v2; // edx

v1 = *a1;
if ( !*a1 )
return 1LL;
v2 = 0;
while ( v1 <= 0x80u )
{
if ( v1 <= 0x2Fu || v2 > 57 )
return 0LL;
++a1;
LABEL_6:
v1 = *a1;
if ( !*a1 )
return 1LL;
}
if ( v1 != 163 )
return 0LL;
v2 = a1[1];
if ( (unsigned int)(v2 - 176) <= 9 )
{
a1 += 2;
goto LABEL_6;
}
return 0LL;
}

original_code:
extern int gbk_numeric_string( char *str )
{
    char *s = str;
    int c1 = 0;
    int c2 = 0;
    while ( *s != '\0' )
    {
 c1 = (uchar_t) (*s++);
 if ( c1 <= 0x80 )
 {
     if ( c1 < 48 || c2 > 57 ) return 0;
 }
 else
 {
     if ( c1 != 0xa3 ) return 0;
     c2 = (uchar_t) (*s++);
     if ( c2 < 0xb0 || c2 > 0xb9 ) return 0;
 }
    }
    return 1;
}

canonical_original_code:
extern int gbk_numeric_string(char *str)
{
    char *s = str;
    int c1 = 0;
    int c2 = 0;
    while ( *s != '\0' )
    {
 c1 = (uchar_t) (*s++);
 if ( c1 <= 0x80 )
 {
     if ( c1 < 48 || c2 > 57 ) return 0;
 }
 else
 {
     if ( c1 != 0xa3 ) return 0;
     c2 = (uchar_t) (*s++);
     if ( c2 < 0xb0 || c2 > 0xb9 ) return 0;
 }
    }
    return 1;
}


decompiled_code:
__int64 __fastcall gbk_decimal_string(const char *a1)
{
int v2; // eax
int v3; // edx
int v4; // edi
int v5; // er8
int v6; // ecx
unsigned __int8 v7; // al

v2 = strlen(a1);
v3 = 0;
if ( *a1 != 46 )
{
v4 = v2;
if ( a1[v2 - 1] != 46 )
{
if ( v2 > 0 )
{
v5 = 0;
while ( 1 )
{
v6 = v3 + 1;
v7 = a1[v3];
if ( v7 == 46 )
{
++v5;
++v3;
}
else if ( v7 > 0x80u )
{
if ( v7 != 163 )
return 0;
v3 += 2;
if ( (unsigned int)(unsigned __int8)a1[v6] - 176 > 9 )
return 0;
}
else
{
if ( (unsigned int)v7 - 48 > 9 )
return 0;
++v3;
}
if ( v4 <= v3 )
goto LABEL_14;
}
}
v5 = 0;
LABEL_14:
v3 = v5 == 1;
}
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
int v2; // eax
int v3; // edx
int v4; // edi
int v5; // er8
int v6; // ecx
unsigned __int8 v7; // al

v2 = strlen(a1);
v3 = 0;
if ( *a1 != 46 )
{
v4 = v2;
if ( a1[v2 - 1] != 46 )
{
if ( v2 > 0 )
{
v5 = 0;
while ( 1 )
{
v6 = v3 + 1;
v7 = a1[v3];
if ( v7 == 46 )
{
++v5;
++v3;
}
else if ( v7 > 0x80u )
{
if ( v7 != 163 )
return 0;
v3 += 2;
if ( (unsigned int)(unsigned __int8)a1[v6] - 176 > 9 )
return 0;
}
else
{
if ( (unsigned int)v7 - 48 > 9 )
return 0;
++v3;
}
if ( v4 <= v3 )
goto LABEL_14;
}
}
v5 = 0;
LABEL_14:
v3 = v5 == 1;
}
}
return (unsigned int)v3;
}

original_code:
extern int gbk_decimal_string( char *str )
{
    int c1 = 0;
    int c2 = 0;
    int len = strlen(str), i, p = 0;
    if ( str[0] == '.' || str[len - 1] == '.' ) return 0;
    for ( i = 0; i < len; )
    {
 c1 = (uchar_t) str[i++];
 if ( c1 == 46 )
 {
     p++;
     continue;
 }
 if ( c1 <= 0x80 )
 {
     if ( c1 < 48 || c1 > 57 ) return 0;
 }
 else
 {
     if ( c1 != 0xa3 ) return 0;
     c2 = (uchar_t) str[i++];
     if ( c2 < 0xb0 || c2 > 0xb9 ) return 0;
 }
    }
    return (p == 1);
}

canonical_original_code:
extern int gbk_decimal_string(char *str)
{
    int c1 = 0;
    int c2 = 0;
    int len = strlen(str); int i; int p = 0;
    if ( str[0] == '.' || str[len - 1] == '.' ) return 0;
    for ( i = 0; i < len; )
    {
 c1 = (unsigned char) str[i++];
 if ( c1 == 46 )
 {
     p++;
     continue;
 }
 if ( c1 <= 0x80 )
 {
     if ( c1 < 48 || c1 > 57 ) return 0;
 }
 else
 {
     if ( c1 != 0xa3 ) return 0;
     c2 = (unsigned char) str[i++];
     if ( c2 < 0xb0 || c2 > 0xb9 ) return 0;
 }
    }
    return (p == 1);
}


decompiled_code:
_BOOL8 __fastcall gbk_en_letter(unsigned __int8 *a1)
{
_BOOL8 result; // rax

if ( *a1 <= 0x80u )
return (unsigned __int8)((*a1 & 0xDF) - 65) <= 0x19u;
result = 0LL;
if ( *a1 == 163 )
result = (unsigned __int8)((a1[1] & 0xDF) + 63) <= 0x19u;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(unsigned __int8 *a1)
{
_BOOL8 result; // rax

if ( *a1 <= 0x80u )
return (unsigned __int8)((*a1 & 0xDF) - 65) <= 0x19u;
result = 0LL;
if ( *a1 == 163 )
result = (unsigned __int8)((a1[1] & 0xDF) + 63) <= 0x19u;
return result;
}


decompiled_code:
__int64 __fastcall gbk_whitespace(unsigned __int8 *a1)
{
unsigned int v1; // eax
__int64 result; // rax

v1 = *a1;
if ( v1 > 0x80 )
result = (v1 == 163) & (unsigned __int8)(a1[1] == 0xA0);
else
result = v1 == 32;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int8 *a1)
{
unsigned int v1; // eax
__int64 result; // rax

v1 = *a1;
if ( v1 > 0x80 )
result = (v1 == 163) & (unsigned __int8)(a1[1] == 0xA0);
else
result = v1 == 32;
return result;
}

original_code:
extern int gbk_whitespace( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 ) return (c1 == 32);
    else return ( c1 == 0xa3 && c2 == 0xa0 );
}

canonical_original_code:
extern int gbk_whitespace(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    if ( c1 <= 0x80 ) return (c1 == 32);
    else return ( c1 == 0xa3 && c2 == 0xa0 );
}


decompiled_code:
__int64 __fastcall gbk_letter_number(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 == 0xA2 )
result = ((unsigned int)(unsigned __int8)a1[1] - 240 <= 0xE) | (unsigned __int8)((unsigned int)(unsigned __int8)a1[1]
- 161 <= 0xF);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_BYTE *a1)
{
__int64 result; // rax

result = 0LL;
if ( *a1 == 0xA2 )
result = ((unsigned int)(unsigned __int8)a1[1] - 240 <= 0xE) | (unsigned __int8)((unsigned int)(unsigned __int8)a1[1]
- 161 <= 0xF);
return result;
}

original_code:
extern int gbk_letter_number( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( (c1 == 0xa2)
     && ( ( c2 >= 0xa1 && c2 <= 0xb0 )
  || ( c2 >= 0xf0 && c2 <= 0xfe ) ) );
}

canonical_original_code:
extern int gbk_letter_number(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( (c1 == 0xa2)
     && ( ( c2 >= 0xa1 && c2 <= 0xb0 )
  || ( c2 >= 0xf0 && c2 <= 0xfe ) ) );
}


decompiled_code:
_BOOL8 __fastcall gbk_other_number(_BYTE *a1)
{
_BOOL4 v1; // edx

v1 = 0;
if ( *a1 == 0xA2 )
v1 = (unsigned int)(unsigned __int8)a1[1] - 197 <= 0x29;
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(_BYTE *a1)
{
_BOOL4 v1; // edx

v1 = 0;
if ( *a1 == 0xA2 )
v1 = (unsigned int)(unsigned __int8)a1[1] - 197 <= 0x29;
return v1;
}

original_code:
extern int gbk_other_number( char *str )
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( ( c1 == 0xa2 ) && ( c2 >= 0xc5 && c2 <= 0xee ) );
}

canonical_original_code:
extern int gbk_other_number(char *str)
{
    int c1 = (uchar_t) str[0];
    int c2 = (uchar_t) str[1];
    return ( ( c1 == 0xa2 ) && ( c2 >= 0xc5 && c2 <= 0xee ) );
}


decompiled_code:
_BOOL8 __fastcall gbk_en_punctuation(int a1)
{
unsigned __int64 v1; // rdx
_BOOL8 result; // rax

if ( (unsigned __int8)(a1 - 33) <= 0x3Fu
&& (v1 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v1, (unsigned int)(a1 - 33))) )
{
result = 1LL;
}
else
{
result = (unsigned int)(unsigned __int8)a1 - 123 <= 3;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(int a1)
{
unsigned __int64 v1; // rdx
_BOOL8 result; // rax

if ( (unsigned __int8)(a1 - 33) <= 0x3Fu
&& (v1 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v1, (unsigned int)(a1 - 33))) )
{
result = 1LL;
}
else
{
result = (unsigned int)(unsigned __int8)a1 - 123 <= 3;
}
return result;
}


decompiled_code:
_BOOL8 __fastcall gbk_cn_punctuation(unsigned __int8 *a1)
{
int v1; // edx
int v2; // eax
_BOOL4 v3; // ecx
unsigned __int64 v4; // rcx

v1 = *a1;
v2 = a1[1];
switch ( v1 )
{
case 163:
if ( (unsigned __int8)(v2 + 95) <= 0x3Fu
&& (v4 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v4, (unsigned int)(v2 + 95))) )
{
v3 = 1;
}
else
{
v3 = (unsigned int)(unsigned __int8)v2 - 251 <= 3;
}
break;
case 161:
v3 = (unsigned int)(unsigned __int8)v2 - 176 <= 0xF || (unsigned int)(unsigned __int8)v2 - 161 <= 0xD;
break;
case 166:
v3 = (unsigned int)(unsigned __int8)v2 - 249 <= 5;
break;
default:
v3 = 0;
if ( v1 == 168 )
v3 = (unsigned int)(unsigned __int8)v2 - 64 <= 7;
break;
}
return v3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(unsigned __int8 *a1)
{
int v1; // edx
int v2; // eax
_BOOL4 v3; // ecx
unsigned __int64 v4; // rcx

v1 = *a1;
v2 = a1[1];
switch ( v1 )
{
case 163:
if ( (unsigned __int8)(v2 + 95) <= 0x3Fu
&& (v4 = 0xFC000000FE007FFFLL, _bittest64((const __int64 *)&v4, (unsigned int)(v2 + 95))) )
{
v3 = 1;
}
else
{
v3 = (unsigned int)(unsigned __int8)v2 - 251 <= 3;
}
break;
case 161:
v3 = (unsigned int)(unsigned __int8)v2 - 176 <= 0xF || (unsigned int)(unsigned __int8)v2 - 161 <= 0xD;
break;
case 166:
v3 = (unsigned int)(unsigned __int8)v2 - 249 <= 5;
break;
default:
v3 = 0;
if ( v1 == 168 )
v3 = (unsigned int)(unsigned __int8)v2 - 64 <= 7;
break;
}
return v3;
}


decompiled_code:
void *__fastcall create_buffer(size_t n)
{
void *v1; // rax

v1 = malloc((unsigned int)n);
if ( !v1 )
{
puts("Unable to do the memory allocation, program will now exit");
exit(1);
}
return memset(v1, 0, (unsigned int)n);
}

canonical_decompiled_code:
void *__fastcall func0(size_t n)
{
void *v1; // rax

v1 = malloc((unsigned int)n);
if ( !v1 )
{
puts("Unable to do the memory allocation, program will now exit");
exit(1);
}
return memset(v1, 0, (unsigned int)n);
}

original_code:
static inline fstring create_buffer( uint_t length )
{
    fstring buffer = ( fstring ) malloc(length);
    if ( buffer == ((void *)0) ) {
 printf("Unable to do the memory allocation, program will now exit\n" ); exit(1);
    }
    memset( buffer, 0x00, length );
    return buffer;
}

canonical_original_code:
static inline char *create_buffer(unsigned int length)
{
    char *buffer = ( fstring ) malloc(length);
    if ( buffer == ((void *)0) ) {
 printf("Unable to do the memory allocation, program will now exit\n" ); exit(1);
    }
    memset( buffer, 0x00, length );
    return buffer;
}

variable_types:
length
unsigned int

return_type: char *


decompiled_code:
__int64 __fastcall resize_buffer(__int64 a1, unsigned int a2)
{
void *v2; // r12

v2 = create_buffer(a2);
memcpy(v2, *(const void **)a1, *(unsigned int *)(a1 + 8));
free(*(void **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 12) = a2;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
void *v2; // r12

v2 = func0(a2);
memcpy(v2, *(const void **)a1, *(unsigned int *)(a1 + 8));
free(*(void **)a1);
*(_QWORD *)a1 = v2;
*(_DWORD *)(a1 + 12) = a2;
return a1;
}

original_code:
static inline string_buffer_t resize_buffer(
 string_buffer_t sb, uint_t __allocs )
{
    fstring str = create_buffer( __allocs );
    memcpy( str, sb->buffer, sb->length );
    free( sb->buffer );
    sb->buffer = str;
    sb->allocs = __allocs;
    return sb;
}

canonical_original_code:
static inline struct string_buffer_entry *resize_buffer(struct string_buffer_entry *sb, unsigned int __allocs)
{
    char *str = create_buffer( __allocs );
    memcpy( str, sb->buffer, sb->length );
    free( sb->buffer );
    sb->buffer = str;
    sb->allocs = __allocs;
    return sb;
}

variable_types:
sb
struct string_buffer_entry *

return_type: struct string_buffer_entry { char *buffer; unsigned int length; unsigned int allocs; } *


decompiled_code:
void *__fastcall string_buffer_append(__int64 a1, const char *a2)
{
__int64 v2; // rbx
unsigned int v3; // ebp
unsigned int v4; // eax
void *result; // rax

v2 = a1;
v3 = strlen(a2);
v4 = *(_DWORD *)(a1 + 8) + v3;
if ( v4 > *(_DWORD *)(a1 + 12) )
v2 = resize_buffer(a1, 2 * v4 + 1);
result = memcpy((void *)(*(_QWORD *)v2 + *(unsigned int *)(v2 + 8)), a2, v3);
*(_DWORD *)(v2 + 8) += v3;
return result;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, const char *a2)
{
__int64 v2; // rbx
unsigned int v3; // ebp
unsigned int v4; // eax
void *result; // rax

v2 = a1;
v3 = strlen(a2);
v4 = *(_DWORD *)(a1 + 8) + v3;
if ( v4 > *(_DWORD *)(a1 + 12) )
v2 = func1(a1, 2 * v4 + 1);
result = memcpy((void *)(*(_QWORD *)v2 + *(unsigned int *)(v2 + 8)), a2, v3);
*(_DWORD *)(v2 + 8) += v3;
return result;
}

original_code:
extern void string_buffer_append(
 string_buffer_t sb, fstring __str )
{
    register uint_t __len__ = strlen( __str );
    if ( sb->length + __len__ > sb->allocs ) {
 sb = resize_buffer( sb, ( sb->length + __len__ ) * 2 + 1 );
    }
    memcpy( sb->buffer + sb->length, __str, __len__ );
    sb->length += __len__;
}

canonical_original_code:
extern void string_buffer_append(struct string_buffer_entry *sb, char *__str)
{
    register unsigned int __len__ = strlen( __str );
    if ( sb->length + __len__ > sb->allocs ) {
 sb = resize_buffer( sb, ( sb->length + __len__ ) * 2 + 1 );
    }
    memcpy( sb->buffer + sb->length, __str, __len__ );
    sb->length += __len__;
}

variable_types: struct string_buffer_entry { char *buffer; unsigned int length; unsigned int allocs; } *

return_type: void


decompiled_code:
void string_buffer_insert()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
extern void string_buffer_insert(
 string_buffer_t sb,
 uint_t idx,
 fstring __str )
{
}

canonical_original_code:
extern void string_buffer_insert(struct string_buffer_entry *sb, unsigned int idx, char *__str)
{
}

variable_types:
idx
unsigned int

user_defined_types: struct string_buffer_entry { char *buffer; unsigned int length; unsigned int allocs; }


decompiled_code:
__int64 __fastcall string_buffer_remove(_DWORD *a1, unsigned int a2, unsigned int a3)
{
unsigned int v3; // er10
unsigned int v4; // eax
unsigned int v5; // edx
unsigned int v6; // edx

v3 = a3;
v4 = a2 + a3;
if ( a2 + a3 < a1[2] )
{
v5 = a2;
do
*(_BYTE *)(*(_QWORD *)a1 + v5++) = *(_BYTE *)(*(_QWORD *)a1 + v4++);
while ( a1[2] > v4 );
}
*(_BYTE *)(*(_QWORD *)a1 + v4) = 0;
v6 = a1[2] - a2;
if ( v6 )
{
if ( v3 > v6 )
v3 = a1[2] - a2;
a1[2] -= v3;
}
*(_BYTE *)(*(_QWORD *)a1 + (unsigned int)(a1[2] - 1)) = 0;
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1, unsigned int a2, unsigned int a3)
{
unsigned int v3; // er10
unsigned int v4; // eax
unsigned int v5; // edx
unsigned int v6; // edx

v3 = a3;
v4 = a2 + a3;
if ( a2 + a3 < a1[2] )
{
v5 = a2;
do
*(_BYTE *)(*(_QWORD *)a1 + v5++) = *(_BYTE *)(*(_QWORD *)a1 + v4++);
while ( a1[2] > v4 );
}
*(_BYTE *)(*(_QWORD *)a1 + v4) = 0;
v6 = a1[2] - a2;
if ( v6 )
{
if ( v3 > v6 )
v3 = a1[2] - a2;
a1[2] -= v3;
}
*(_BYTE *)(*(_QWORD *)a1 + (unsigned int)(a1[2] - 1)) = 0;
return *(_QWORD *)a1;
}

original_code:
extern fstring string_buffer_remove(
 string_buffer_t sb,
 uint_t idx,
 uint_t length )
{
    uint_t t;
    for ( t = idx + length; t < sb->length; t++ ) {
 sb->buffer[t - length] = sb->buffer[t];
    }
    sb->buffer[t] = '\0';
    t = sb->length - idx;
    if ( t > 0 ) {
 sb->length -= ( t > length ) ? length : t;
    }
    sb->buffer[sb->length-1] = '\0';
    return sb->buffer;
}

canonical_original_code:
extern char *string_buffer_remove(struct string_buffer_entry *sb, unsigned int idx, unsigned int length)
{
    unsigned int t;
    for ( t = idx + length; t < sb->length; t++ ) {
 sb->buffer[t - length] = sb->buffer[t];
    }
    sb->buffer[t] = '\0';
    t = sb->length - idx;
    if ( t > 0 ) {
 sb->length -= ( t > length ) ? length : t;
    }
    sb->buffer[sb->length-1] = '\0';
    return sb->buffer;
}

variable_types:
t
unsigned int


decompiled_code:
__int64 __fastcall string_buffer_trim(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // esi

result = a1;
v2 = *(_DWORD *)(a1 + 8);
if ( v2 < *(_DWORD *)(a1 + 12) - 1 )
result = resize_buffer(a1, v2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // esi

result = a1;
v2 = *(_DWORD *)(a1 + 8);
if ( v2 < *(_DWORD *)(a1 + 12) - 1 )
result = func1(a1, v2 + 1);
return result;
}

original_code:
extern string_buffer_t string_buffer_trim( string_buffer_t sb )
{
    if ( sb->length < sb->allocs - 1 ) {
 sb = resize_buffer( sb, sb->length + 1 );
    }
    return sb;
}

canonical_original_code:
extern struct string_buffer_entry *string_buffer_trim(struct string_buffer_entry *sb)
{
    if ( sb->length < sb->allocs - 1 ) {
 sb = resize_buffer( sb, sb->length + 1 );
    }
    return sb;
}


decompiled_code:
__int64 __fastcall string_buffer_devote(__int64 *a1)
{
__int64 v1; // rbx

v1 = *a1;
free(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1)
{
__int64 v1; // rbx

v1 = *a1;
free(a1);
return v1;
}

original_code:
extern fstring string_buffer_devote( string_buffer_t sb )
{
    fstring buffer = sb->buffer;
    free( sb );
    return buffer;
}

canonical_original_code:
extern char *string_buffer_devote(struct string_buffer_entry *sb)
{
    char *buffer = sb->buffer;
    free( sb );
    return buffer;
}


decompiled_code:
void *__fastcall string_buffer_clear(__int64 a1)
{
void *result; // rax

result = memset(*(void **)a1, 0, *(unsigned int *)(a1 + 8));
*(_DWORD *)(a1 + 8) = 0;
return result;
}

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

result = memset(*(void **)a1, 0, *(unsigned int *)(a1 + 8));
*(_DWORD *)(a1 + 8) = 0;
return result;
}

original_code:
extern void string_buffer_clear( string_buffer_t sb )
{
    memset( sb->buffer, 0x00, sb->length );
    sb->length = 0;
}

canonical_original_code:
extern void string_buffer_clear(struct string_buffer_entry *sb)
{
    memset( sb->buffer, 0x00, sb->length );
    sb->length = 0;
}


decompiled_code:
void __fastcall free_string_buffer(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
extern void free_string_buffer( string_buffer_t sb )
{
    free( sb->buffer );
    free( sb );
}

canonical_original_code:
extern void free_string_buffer(struct string_buffer_entry *sb)
{
    free( sb->buffer );
    free( sb );
}


decompiled_code:
size_t __fastcall string_split_reset(__int64 a1, const char *a2, const char *a3)
{
size_t result; // rax

*(_QWORD *)(a1 + 16) = a2;
*(_DWORD *)(a1 + 24) = strlen(a2);
*(_QWORD *)a1 = a3;
result = strlen(a3);
*(_DWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 28) = 0;
return result;
}

canonical_decompiled_code:
size_t __fastcall func10(__int64 a1, const char *a2, const char *a3)
{
size_t result; // rax

*(_QWORD *)(a1 + 16) = a2;
*(_DWORD *)(a1 + 24) = strlen(a2);
*(_QWORD *)a1 = a3;
result = strlen(a3);
*(_DWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 28) = 0;
return result;
}

original_code:
extern void string_split_reset(
 string_split_t sst,
 fstring delimiter,
 fstring source )
{
    sst->delimiter = delimiter;
    sst->delLen = strlen(delimiter);
    sst->source = source;
    sst->srcLen = strlen(source);
    sst->idx = 0;
}

canonical_original_code:
extern void string_split_reset(struct string_split_entry *sst, char *delimiter, char *source)
{
    sst->delimiter = delimiter;
    sst->delLen = strlen(delimiter);
    sst->source = source;
    sst->srcLen = strlen(source);
    sst->idx = 0;
}

variable_types: struct string_split_entry { char *source; unsigned int srcLen; char *delimiter; unsigned int delLen; unsigned int idx; } *

variable_types:
delimiter
char *

variable_types:
source
char *


decompiled_code:
size_t __fastcall string_split_set_source(__int64 a1, const char *a2)
{
size_t result; // rax

*(_QWORD *)a1 = a2;
result = strlen(a2);
*(_DWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 28) = 0;
return result;
}

canonical_decompiled_code:
size_t __fastcall func11(__int64 a1, const char *a2)
{
size_t result; // rax

*(_QWORD *)a1 = a2;
result = strlen(a2);
*(_DWORD *)(a1 + 8) = result;
*(_DWORD *)(a1 + 28) = 0;
return result;
}

original_code:
extern void string_split_set_source(
 string_split_t sst, fstring source )
{
    sst->source = source;
    sst->srcLen = strlen(source);
    sst->idx = 0;
}

canonical_original_code:
extern void string_split_set_source(struct string_split_entry *sst, char *source)
{
    sst->source = source;
    sst->srcLen = strlen(source);
    sst->idx = 0;
}

user_defined_types: struct string_split_entry { char *source; unsigned int srcLen; char *delimiter; unsigned int delLen; unsigned int idx; }


decompiled_code:
size_t __fastcall string_split_set_delimiter(__int64 a1, const char *a2)
{
size_t result; // rax

*(_QWORD *)(a1 + 16) = a2;
result = strlen(a2);
*(_QWORD *)(a1 + 24) = (unsigned int)result;
return result;
}

canonical_decompiled_code:
size_t __fastcall func12(__int64 a1, const char *a2)
{
size_t result; // rax

*(_QWORD *)(a1 + 16) = a2;
result = strlen(a2);
*(_QWORD *)(a1 + 24) = (unsigned int)result;
return result;
}

original_code:
extern void string_split_set_delimiter(
 string_split_t sst, fstring delimiter )
{
    sst->delimiter = delimiter;
    sst->delLen = strlen( delimiter );
    sst->idx = 0;
}

canonical_original_code:
extern void string_split_set_delimiter(struct string_split_entry *sst, char *delimiter)
{
    sst->delimiter = delimiter;
    sst->delLen = strlen( delimiter );
    sst->idx = 0;
}


decompiled_code:
void __fastcall free_string_split(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func13(void *a1)
{
free(a1);
}

original_code:
extern void free_string_split( string_split_t sst )
{
    free( sst );
}

canonical_original_code:
extern void free_string_split(struct string_split_entry *sst)
{
    free( sst );
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // r13
int v5; // ebx
__int64 v6; // rbp
void *v7; // r12
int v9; // eax
const char *v10; // rdx
__int64 v11; // rbx
int v12; // eax
int v13; // er14
__int64 v14[2]; // [rsp+0h] [rbp-5038h] BYREF
char s[20520]; // [rsp+10h] [rbp-5028h] BYREF

v14[0] = 0LL;
v14[1] = 0LL;
memset(s, 0, 0x4FF0uLL);
if ( argc <= 0 )
goto LABEL_10;
v3 = argv;
v4 = 0LL;
do
{
if ( !strcasecmp("-init", *v3) )
v4 = v3[1];
++v3;
}
while ( v3 != &argv[(unsigned int)(argc - 1) + 1] );
if ( !v4 )
{
LABEL_10:
puts("Usage: friso -init lexicon path");
exit(0);
}
v5 = clock();
v6 = friso_new();
v7 = (void *)friso_new_config();
if ( (unsigned int)friso_init_from_ifile() == 1 )
{
v9 = clock();
printf("Initialized in %fsec\n", (double)(v9 - v5) / 1000000.0);
v10 = "UTF-8";
if ( *(_DWORD *)(v6 + 8) )
v10 = "GBK";
printf("+-Version: %s (%s)\n", "1.6.0", v10);
puts("+-----------------------------------------------------------+");
puts("| friso - a chinese word segmentation writen by c. |");
puts("| bug report email - chenxin619315@gmail.com. |");
puts("| or: visit http://code.google.com/p/friso. |");
puts("| java edition for http://code.google.com/p/jcseg |");
puts("| type 'quit' to exit the program. |");
puts("+-----------------------------------------------------------+");
v11 = friso_new_task();
while ( 1 )
{
printf("%s", "friso>> ");
getLine(stdin, v14);
if ( !strcasecmp((const char *)v14, "quit") )
break;
friso_set_text();
puts(&byte_40206E);
v13 = clock();
while ( friso_next() )
printf("%s/ ", (const char *)(*(_QWORD *)(v11 + 32) + 4LL));
v12 = clock();
printf("\nDone, cost < %fsec\n", (double)(v12 - v13) / 1000000.0);
}
puts("Thanks for trying friso.");
friso_free_task();
}
else
{
printf("fail to initialize friso and config.");
}
free(v7);
friso_free();
return 0;
}

original_code:
int main(int argc, char **argv) {
    clock_t s_time, e_time;
    char line[20480] = {0};
    int i;
    fstring __path__ = ((void *)0);
    friso_t friso;
    friso_config_t config;
    friso_task_t task;
    for ( i = 0; i < argc; i++ ) {
 if ( strcasecmp( "-init", argv[i] ) == 0 ) {
     __path__ = argv[i+1];
 }
    }
    if ( __path__ == ((void *)0) ) {
 printf("%s\n", "Usage: friso -init lexicon path" );
 exit(0);
    }
    s_time = clock();
    friso = friso_new();
    config = friso_new_config();
    if ( friso_init_from_ifile(friso, config, __path__) != 1 ) {
 printf("fail to initialize friso and config.");
 goto err;
    }
    e_time = clock();
    printf("Initialized in %fsec\n", (double) ( e_time - s_time ) / ((__clock_t) 1000000) );
    printf("+-Version: %s (%s)\n", "1.6.0", friso->charset == FRISO_UTF8 ? "UTF-8" : "GBK" );
    printf("%s\n", "+-----------------------------------------------------------+" ); printf("%s\n", "| friso - a chinese word segmentation writen by c.          |" ); printf("%s\n", "| bug report email - chenxin619315@gmail.com.               |" ); printf("%s\n", "| or: visit http://code.google.com/p/friso.                 |" ); printf("%s\n", "|     java edition for http://code.google.com/p/jcseg       |" ); printf("%s\n", "| type 'quit' to exit the program.                          |" ); printf("%s\n", "+-----------------------------------------------------------+" );;
    task = friso_new_task();
    while ( 1 ) {
 printf("%s", "friso>> " );
 getLine( stdin, line );
 if ( strcasecmp( line, "quit" ) == 0 ) {
     printf("%s\n", "Thanks for trying friso." ); break;
 }
 friso_set_text( task, line );
 printf("%s\n", "分词结果:" );
 s_time = clock();
 while ( ( friso_next( friso, config, task ) ) != ((void *)0) ) {
     printf("%s/ ", task->hits->word );
 }
 e_time = clock();
 printf("\nDone, cost < %fsec\n", ( (double)(e_time - s_time) ) / ((__clock_t) 1000000) );
    }
    friso_free_task( task );
err:
    free( config );
    friso_free(friso);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
    long s_time; long e_time;
    char line[20480] = {0};
    int i;
    char *__path__ = ((void *)0);
    struct friso_entry *friso;
    struct friso_config_entry *config;
    struct friso_task_entry *task;
    for ( i = 0; i < argc; i++ ) {
 if ( strcasecmp( "-init", argv[i] ) == 0 ) {
     __path__ = argv[i+1];
 }
    }
    if ( __path__ == ((void *)0) ) {
 printf("%s\n", "Usage: friso -init lexicon path" );
 exit(0);
    }
    s_time = clock();
    friso = friso_new();
    config = friso_new_config();
    if ( friso_init_from_ifile(friso, config, __path__) != 1 ) {
 printf("fail to initialize friso and config.");
 goto err;
    }
    e_time = clock();
    printf("Initialized in %fsec\n", (double) ( e_time - s_time ) / ((long) 1000000) );
    printf("+-Version: %s (%s)\n", "1.6.0", friso->charset == FRISO_UTF8 ? "UTF-8" : "GBK" );
    printf("%s\n", "+-----------------------------------------------------------+" ); printf("%s\n", "| friso - a chinese word segmentation writen by c.          |" ); printf("%s\n", "| bug report email - chenxin619315@gmail.com.               |" ); printf("%s\n", "| or: visit http://code.google.com/p/friso.                 |" ); printf("%s\n", "|     java edition for http://code.google.com/p/jcseg       |" ); printf("%s\n", "| type 'quit' to exit the program.                          |" ); printf("%s\n", "+-----------------------------------------------------------+" );;
    task = friso_new_task();
    while ( 1 ) {
 printf("%s", "friso>> " );
 getLine( stdin, line );
 if ( strcasecmp( line, "quit" ) == 0 ) {
     printf("%s\n", "Thanks for trying friso." ); break;
 }
 friso_set_text( task, line );
 printf("%s\n", "分词结果:" );
 s_time = clock();
 while ( ( friso_next( friso, config, task ) ) != ((void *)0) ) {
     printf("%s/ ", task->hits->word );
 }
 e_time = clock();
 printf("\nDone, cost < %fsec\n", ( (double)(e_time - s_time) ) / ((long) 1000000) );
    }
    friso_free_task( task );
err:
    free( config );
    friso_free(friso);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
line
char [20480]

variable_types: struct friso_entry { struct friso_hash_cdt { unsigned int length; unsigned int size; float factor; unsigned int threshold; struct hash_entry { char *_key; void *_val; struct hash_entry *_next; } **table; } **dic; enum friso_charset_t { FRISO_UTF8=0, FRISO_GBK=1 } charset; } *

variable_types: struct friso_config_entry { unsigned short max_len; unsigned short r_name; unsigned short mix_len; unsigned short lna_len; unsigned short add_syn; unsigned short clr_stw; unsigned short keep_urec; unsigned short spx_out; unsigned int nthreshold; enum friso_mode_t { __FRISO_SIMPLE_MODE__=1, __FRISO_COMPLEX_MODE__=2 } mode; } *

user_defined_types: struct friso_entry { struct friso_hash_cdt **dic; enum friso_charset_t charset; }

user_defined_types: struct friso_config_entry { unsigned short max_len; unsigned short r_name; unsigned short mix_len; unsigned short lna_len; unsigned short add_syn; unsigned short clr_stw; unsigned short keep_urec; unsigned short spx_out; unsigned int nthreshold; enum friso_mode_t mode; }

user_defined_types: struct friso_hash_cdt { unsigned int length; unsigned int size; float factor; unsigned int threshold; struct hash_entry **table; }


repo: TripleChocPi/LIRC

decompiled_code:
int display_welcome()
{
printf("LIRC Server v%s starting...\n", "0.01");
puts("Developed by TripleChocPi 2013.\n");
puts("LIRC is an open-source project released under the GPL v3.");
puts("Pull requests are welcome. For more information on LIRC's");
puts("design philosophy and goals please visit our GitHub repo");
return printf("at %s\n\n", "https://github.com/TripleChocPi/LIRC/");
}

canonical_decompiled_code:
int func0()
{
printf("LIRC Server v%s starting...\n", "0.01");
puts("Developed by TripleChocPi 2013.\n");
puts("LIRC is an open-source project released under the GPL v3.");
puts("Pull requests are welcome. For more information on LIRC's");
puts("design philosophy and goals please visit our GitHub repo");
return printf("at %s\n\n", "https://github.com/TripleChocPi/LIRC/");
}

original_code:
void
display_welcome()
{
  printf("LIRC Server v%s starting...\n", "0.01");
  printf("Developed by TripleChocPi 2013.\n\n");
  printf("LIRC is an open-source project released under the GPL v3.\n");
  printf("Pull requests are welcome. For more information on LIRC's\n");
  printf("design philosophy and goals please visit our GitHub repo\n");
  printf("at %s\n\n", "https://github.com/TripleChocPi/LIRC/");
}


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_BYTE v3[32]; // [rsp+0h] [rbp-58h] BYREF
char v4[56]; // [rsp+20h] [rbp-38h] BYREF

display_welcome();
lirc_server_init(v4, v3);
while ( 1 )
lirc_server_main_loop(v4, v3);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_BYTE v3[32]; // [rsp+0h] [rbp-58h] BYREF
char v4[56]; // [rsp+20h] [rbp-38h] BYREF

func0();
lirc_server_init(v4, v3);
while ( 1 )
lirc_server_main_loop(v4, v3);
}

original_code:
int
main(int argc, char *argv[])
{
  LIRCServer lirc_server;
  LIRCSettings lirc_settings;
  display_welcome();
  lirc_server_init(&lirc_server, &lirc_settings);
  while (TRUE)
  {
    lirc_server_main_loop(&lirc_server, &lirc_settings);
  }
  printf ("Server is shutting down.\n");
  lirc_server_close(&lirc_server);
  lirc_settings_destroy(&lirc_settings);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  struct LIRCServer_struct lirc_server;
  struct LIRCSettings_struct lirc_settings;
  display_welcome();
  lirc_server_init(&lirc_server, &lirc_settings);
  while (TRUE)
  {
    lirc_server_main_loop(&lirc_server, &lirc_settings);
  }
  printf ("Server is shutting down.\n");
  lirc_server_close(&lirc_server);
  lirc_settings_destroy(&lirc_settings);
  return 0;
}

variable_types:
argv
char *[]

variable_types: struct LIRCServer_struct { int epoll; int l_socket; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } l_socket_addr; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *client_list; struct dlist_t *channel_list; }

variable_types: struct LIRCSettings_struct { int port; char *server_name; char *motd; }

user_defined_types: struct LIRCServer_struct { int epoll; int l_socket; struct sockaddr_in l_socket_addr; struct dlist_t *client_list; struct dlist_t *channel_list; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct dlist_t { struct dlnode *head; struct dlnode *foot; int list_len; int size; }


original_code:
static BOOL
lirc_server_socket_init(LIRCServer* server, LIRCSettings* settings)
{
  if ((server->l_socket = socket(2, SOCK_STREAM, 0)) < 0)
    return FALSE;
  server->l_socket_addr.sin_family = 2;
  server->l_socket_addr.sin_port = htons(settings->port);
  server->l_socket_addr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
  return TRUE;
}

canonical_original_code:
static enum BOOL lirc_server_socket_init(struct LIRCServer_struct *server, struct LIRCSettings_struct *settings)
{
  if ((server->l_socket = socket(2, SOCK_STREAM, 0)) < 0)
    return FALSE;
  server->l_socket_addr.sin_family = 2;
  server->l_socket_addr.sin_port = htons(settings->port);
  server->l_socket_addr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
  return TRUE;
}

variable_types: struct LIRCServer_struct { int epoll; int l_socket; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } l_socket_addr; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *client_list; struct dlist_t *channel_list; } *

variable_types: struct LIRCSettings_struct { int port; char *server_name; char *motd; } *

return_type: enum BOOL { FALSE=0, TRUE=1 }


decompiled_code:
__int64 __fastcall lirc_server_bind(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = bind(*(_DWORD *)(a1 + 4), (const struct sockaddr *)(a1 + 8), 0x10u);
result = 0LL;
if ( v1 >= 0 )
{
make_socket_non_blocking(*(unsigned int *)(a1 + 4));
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = bind(*(_DWORD *)(a1 + 4), (const struct sockaddr *)(a1 + 8), 0x10u);
result = 0LL;
if ( v1 >= 0 )
{
make_socket_non_blocking(*(unsigned int *)(a1 + 4));
result = 1LL;
}
return result;
}

original_code:
static BOOL
lirc_server_bind(LIRCServer* server)
{
  if (bind(server->l_socket, (const struct sockaddr *)&(server->l_socket_addr),
           sizeof (server->l_socket_addr)) < 0)
    return FALSE;
  else
  {
    make_socket_non_blocking(server->l_socket);
    return TRUE;
  }
}

canonical_original_code:
static enum BOOL lirc_server_bind(struct LIRCServer_struct *server)
{
  if (bind(server->l_socket, (struct sockaddr *)&(server->l_socket_addr),
           sizeof (server->l_socket_addr)) < 0)
    return FALSE;
  else
  {
    make_socket_non_blocking(server->l_socket);
    return TRUE;
  }
}

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; }


decompiled_code:
_BOOL8 __fastcall lirc_server_init_epoll(int *a1)
{
int v2; // edi
_BOOL8 result; // rax
struct epoll_event event; // [rsp+4h] [rbp-14h] BYREF

v2 = epoll_create1(0);
*a1 = v2;
result = 0LL;
if ( v2 != -1 )
{
event.data.fd = a1[1];
event.events = -2147483647;
result = epoll_ctl(v2, 1, event.data.fd, &event) != -1;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(int *a1)
{
int v2; // edi
_BOOL8 result; // rax
struct epoll_event event; // [rsp+4h] [rbp-14h] BYREF

v2 = epoll_create1(0);
*a1 = v2;
result = 0LL;
if ( v2 != -1 )
{
event.data.fd = a1[1];
event.events = -2147483647;
result = epoll_ctl(v2, 1, event.data.fd, &event) != -1;
}
return result;
}

original_code:
static BOOL
lirc_server_init_epoll(LIRCServer* server)
{
  struct epoll_event event;
  server->epoll = epoll_create1(0);
  if (server->epoll == -1)
    return FALSE;
  event.data.fd = server->l_socket;
  event.events = EPOLLIN | EPOLLET;
  return (epoll_ctl(server->epoll, 1,
                    server->l_socket, &event) != -1)
         ? TRUE : FALSE;
}

canonical_original_code:
static enum BOOL lirc_server_init_epoll(struct LIRCServer_struct *server)
{
  struct epoll_event event;
  server->epoll = epoll_create1(0);
  if (server->epoll == -1)
    return FALSE;
  event.data.fd = server->l_socket;
  event.events = EPOLLIN | EPOLLET;
  return (epoll_ctl(server->epoll, 1,
                    server->l_socket, &event) != -1)
         ? TRUE : FALSE;
}

variable_types: struct epoll_event { unsigned int events; union epoll_data { void *ptr; int fd; unsigned int u32; unsigned long u64; } data; }

user_defined_types: struct epoll_event { unsigned int events; union epoll_data data; }


decompiled_code:
int __fastcall lirc_server_close(__int64 a1)
{
return close(*(_DWORD *)(a1 + 4));
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
return close(*(_DWORD *)(a1 + 4));
}

original_code:
void
lirc_server_close(LIRCServer* server)
{
  close(server->l_socket);
}

canonical_original_code:
void lirc_server_close(struct LIRCServer_struct *server)
{
  close(server->l_socket);
}


decompiled_code:
int __fastcall lirc_server_init(__int64 a1, __int16 *a2)
{
if ( !(unsigned int)lirc_init_settings(a2, "./settings.cfg") )
{
lirc_settings_destroy(a2);
exit(1);
}
printf("Settings loaded from %s.\n", "./settings.cfg");
if ( !(unsigned int)lirc_server_socket_init(a1, a2) )
{
perror("Creating the server socket failed");
lirc_settings_destroy(a2);
}
puts("Server socket created...");
if ( !(unsigned int)lirc_server_bind(a1) )
{
fwrite("LIRC could not bind to the port specified.\n", 1uLL, 0x2BuLL, stderr);
lirc_settings_destroy(a2);
exit(1);
}
if ( !lirc_server_listen(a1) )
{
fwrite("LIRC could not listen on the socket specified.\n", 1uLL, 0x2FuLL, stderr);
lirc_server_close(a1);
lirc_settings_destroy(a2);
exit(1);
}
if ( !lirc_server_init_epoll((int *)a1) )
{
fwrite("LIRC could not initiate an epoll instance.\n", 1uLL, 0x2BuLL, stderr);
lirc_server_close(a1);
lirc_settings_destroy(a2);
exit(1);
}
*(_QWORD *)(a1 + 24) = make_empty_list();
*(_QWORD *)(a1 + 32) = make_empty_list();
return printf("Server socket bound and listening on port %d.\n", *(unsigned int *)a2);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, __int16 *a2)
{
if ( !(unsigned int)lirc_init_settings(a2, "./settings.cfg") )
{
lirc_settings_destroy(a2);
exit(1);
}
printf("Settings loaded from %s.\n", "./settings.cfg");
if ( !(unsigned int)func2(a1, a2) )
{
perror("Creating the server socket failed");
lirc_settings_destroy(a2);
}
puts("Server socket created...");
if ( !(unsigned int)func3(a1) )
{
fwrite("LIRC could not bind to the port specified.\n", 1uLL, 0x2BuLL, stderr);
lirc_settings_destroy(a2);
exit(1);
}
if ( !func4(a1) )
{
fwrite("LIRC could not listen on the socket specified.\n", 1uLL, 0x2FuLL, stderr);
func6(a1);
lirc_settings_destroy(a2);
exit(1);
}
if ( !func5((int *)a1) )
{
fwrite("LIRC could not initiate an epoll instance.\n", 1uLL, 0x2BuLL, stderr);
func6(a1);
lirc_settings_destroy(a2);
exit(1);
}
*(_QWORD *)(a1 + 24) = make_empty_list();
*(_QWORD *)(a1 + 32) = make_empty_list();
return printf("Server socket bound and listening on port %d.\n", *(unsigned int *)a2);
}

original_code:
void
lirc_server_init(LIRCServer* lirc_server, LIRCSettings* lirc_settings)
{
  if(!(lirc_init_settings(lirc_settings, "./settings.cfg")))
  {
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  printf("Settings loaded from %s.\n", "./settings.cfg");
  if(!(lirc_server_socket_init(lirc_server, lirc_settings)))
  {
    perror("Creating the server socket failed");
    lirc_settings_destroy(lirc_settings);
  }
  printf("Server socket created...\n");
  if(!(lirc_server_bind(lirc_server)))
  {
    fprintf(stderr, "LIRC could not bind to the port specified.\n");
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  if(!(lirc_server_listen(lirc_server)))
  {
    fprintf(stderr, "LIRC could not listen on the socket specified.\n");
    lirc_server_close(lirc_server);
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  if(!(lirc_server_init_epoll(lirc_server)))
  {
    fprintf(stderr, "LIRC could not initiate an epoll instance.\n");
    lirc_server_close(lirc_server);
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  lirc_server->client_list = make_empty_list();
  lirc_server->channel_list = make_empty_list();
  printf("Server socket bound and listening on port %d.\n",
         lirc_settings->port);
}

canonical_original_code:
void lirc_server_init(struct LIRCServer_struct *lirc_server, struct LIRCSettings_struct *lirc_settings)
{
  if(!(lirc_init_settings(lirc_settings, "./settings.cfg")))
  {
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  printf("Settings loaded from %s.\n", "./settings.cfg");
  if(!(lirc_server_socket_init(lirc_server, lirc_settings)))
  {
    perror("Creating the server socket failed");
    lirc_settings_destroy(lirc_settings);
  }
  printf("Server socket created...\n");
  if(!(lirc_server_bind(lirc_server)))
  {
    fprintf(stderr, "LIRC could not bind to the port specified.\n");
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  if(!(lirc_server_listen(lirc_server)))
  {
    fprintf(stderr, "LIRC could not listen on the socket specified.\n");
    lirc_server_close(lirc_server);
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  if(!(lirc_server_init_epoll(lirc_server)))
  {
    fprintf(stderr, "LIRC could not initiate an epoll instance.\n");
    lirc_server_close(lirc_server);
    lirc_settings_destroy(lirc_settings);
    exit(1);
  }
  lirc_server->client_list = make_empty_list();
  lirc_server->channel_list = make_empty_list();
  printf("Server socket bound and listening on port %d.\n",
         lirc_settings->port);
}

user_defined_types: struct LIRCSettings_struct { int port; char *server_name; char *motd; }


decompiled_code:
void __fastcall lirc_server_main_loop(int *a1, __int64 a2)
{
int v2; // eax
epoll_data_t *v3; // r15
ssize_t v4; // rax
char *i; // rbx
int v6; // eax
unsigned int v7; // eax
int v8; // ebx
epoll_data_t *v9; // [rsp+8h] [rbp-860h]
socklen_t addr_len; // [rsp+1Ch] [rbp-84Ch] BYREF
struct epoll_event save_ptr; // [rsp+20h] [rbp-848h] BYREF
struct sockaddr buf[32]; // [rsp+30h] [rbp-838h] BYREF
struct epoll_event events[132]; // [rsp+230h] [rbp-638h] BYREF

memset(events, 0, 0x600uLL);
v2 = epoll_wait(*a1, events, 128, -1);
if ( v2 > 0 )
{
v3 = &events[0].data;
v9 = &events[(unsigned int)(v2 - 1) + 1].data;
while ( 1 )
{
v6 = HIDWORD(v3[-1].u64);
if ( (v6 & 0x18) == 0 && (v6 & 1) != 0 )
break;
if ( v3->fd == a1[1] )
goto LABEL_20;
fwrite("Error on a client's socket. Connection closed.", 1uLL, 0x2EuLL, stderr);
close(v3->fd);
LABEL_17:
v3 = (epoll_data_t *)((char *)v3 + 12);
if ( v3 == v9 )
return;
}
if ( v3->fd != a1[1] )
{
while ( 1 )
{
memset(buf, 0, sizeof(buf));
v4 = read(v3->fd, buf, 0x200uLL);
if ( v4 == -1 )
break;
if ( !v4 )
goto LABEL_16;
for ( i = strtok_r((char *)buf, "\r\n", (char **)&save_ptr); i; i = strtok_r(0LL, "\r\n", (char **)&save_ptr) )
{
printf("Message recieved: %s\n", i);
lirc_client_parse(a1, a2, v3->u32, i);
}
}
if ( *_errno_location() == 11 )
goto LABEL_17;
perror("Read error");
LABEL_16:
puts("Disconnected a client.");
close(v3->fd);
goto LABEL_17;
}
LABEL_20:
while ( 1 )
{
addr_len = 16;
v7 = accept(a1[1], buf, &addr_len);
v8 = v7;
if ( v7 == -1 )
break;
make_socket_non_blocking(v7);
save_ptr.data.fd = v8;
save_ptr.events = -2147483647;
if ( epoll_ctl(*a1, 1, v8, &save_ptr) == -1 )
{
perror("epoll_ctl add client error");
lirc_server_close((__int64)a1);
lirc_settings_destroy(a2);
exit(1);
}
puts("Client connected.");
}
if ( *_errno_location() != 11 )
perror("Error accepting connection");
goto LABEL_17;
}
}

canonical_decompiled_code:
void __fastcall func8(int *a1, __int64 a2)
{
int v2; // eax
epoll_data_t *v3; // r15
ssize_t v4; // rax
char *i; // rbx
int v6; // eax
unsigned int v7; // eax
int v8; // ebx
epoll_data_t *v9; // [rsp+8h] [rbp-860h]
socklen_t addr_len; // [rsp+1Ch] [rbp-84Ch] BYREF
struct epoll_event save_ptr; // [rsp+20h] [rbp-848h] BYREF
struct sockaddr buf[32]; // [rsp+30h] [rbp-838h] BYREF
struct epoll_event events[132]; // [rsp+230h] [rbp-638h] BYREF

memset(events, 0, 0x600uLL);
v2 = epoll_wait(*a1, events, 128, -1);
if ( v2 > 0 )
{
v3 = &events[0].data;
v9 = &events[(unsigned int)(v2 - 1) + 1].data;
while ( 1 )
{
v6 = HIDWORD(v3[-1].u64);
if ( (v6 & 0x18) == 0 && (v6 & 1) != 0 )
break;
if ( v3->fd == a1[1] )
goto LABEL_20;
fwrite("Error on a client's socket. Connection closed.", 1uLL, 0x2EuLL, stderr);
close(v3->fd);
LABEL_17:
v3 = (epoll_data_t *)((char *)v3 + 12);
if ( v3 == v9 )
return;
}
if ( v3->fd != a1[1] )
{
while ( 1 )
{
memset(buf, 0, sizeof(buf));
v4 = read(v3->fd, buf, 0x200uLL);
if ( v4 == -1 )
break;
if ( !v4 )
goto LABEL_16;
for ( i = strtok_r((char *)buf, "\r\n", (char **)&save_ptr); i; i = strtok_r(0LL, "\r\n", (char **)&save_ptr) )
{
printf("Message recieved: %s\n", i);
lirc_client_parse(a1, a2, v3->u32, i);
}
}
if ( *_errno_location() == 11 )
goto LABEL_17;
perror("Read error");
LABEL_16:
puts("Disconnected a client.");
close(v3->fd);
goto LABEL_17;
}
LABEL_20:
while ( 1 )
{
addr_len = 16;
v7 = accept(a1[1], buf, &addr_len);
v8 = v7;
if ( v7 == -1 )
break;
make_socket_non_blocking(v7);
save_ptr.data.fd = v8;
save_ptr.events = -2147483647;
if ( epoll_ctl(*a1, 1, v8, &save_ptr) == -1 )
{
perror("epoll_ctl add client error");
func6((__int64)a1);
lirc_settings_destroy(a2);
exit(1);
}
puts("Client connected.");
}
if ( *_errno_location() != 11 )
perror("Error accepting connection");
goto LABEL_17;
}
}

original_code:
void
lirc_server_main_loop(LIRCServer* server, LIRCSettings* settings)
{
  int i, event_count;
  struct epoll_event events[128];
  memset(events, '\0', sizeof (struct epoll_event) * 128);
  event_count = epoll_wait(server->epoll, events, 128, -1);
  for (i = 0; i < event_count; i++)
  {
    if ((
          (events[i].events & EPOLLERR) ||
          (events[i].events & EPOLLHUP) ||
          (!(events[i].events & EPOLLIN))
        )
        && (events[i].data.fd != server->l_socket))
    {
      fprintf(stderr, "Error on a client's socket. Connection closed.");
      close(events[i].data.fd);
      continue;
    }
    else if (events[i].data.fd == server->l_socket)
    {
      while (TRUE)
      {
        struct epoll_event event;
        struct sockaddr in_addr;
        socklen_t in_len;
        int socket;
        in_len = sizeof (in_addr);
        socket = accept(server->l_socket, &in_addr, &in_len);
        if (socket == -1)
        {
          if (((*__errno_location ()) != 11) && ((*__errno_location ()) != 11))
            perror ("Error accepting connection");
          break;
        }
        make_socket_non_blocking(socket);
        event.data.fd = socket;
        event.events = EPOLLIN | EPOLLET;
        if ((epoll_ctl(server->epoll, 1, socket, &event)) == -1)
        {
          perror("epoll_ctl add client error");
          lirc_server_close(server);
          lirc_settings_destroy(settings);
          exit(1);
        }
        printf("Client connected.\n");
      }
    }
    else
    {
      BOOL disconnect = FALSE;
      while (TRUE)
      {
        ssize_t count;
        char buffer[512];
        char* saveptr;
        char* command;
        memset(buffer, '\0', sizeof(char) * 512);
        count = read(events[i].data.fd, buffer, sizeof(buffer));
        if (count == -1)
        {
          if ((*__errno_location ()) != 11)
          {
            perror("Read error");
            disconnect = TRUE;
          }
          break;
        }
        else if (count == 0)
        {
          disconnect = TRUE;
          break;
        }
        command = strtok_r(buffer, "\r\n", &saveptr);
        while (command)
        {
          printf("Message recieved: %s\n", command);
          lirc_client_parse(server, settings, events[i].data.fd, command);
          command = strtok_r(((void *)0), "\r\n", &saveptr);
        }
      }
      if (disconnect)
      {
        printf("Disconnected a client.\n");
        close(events[i].data.fd);
      }
    }
  }
}

canonical_original_code:
void lirc_server_main_loop(struct LIRCServer_struct *server, struct LIRCSettings_struct *settings)
{
  int i; int event_count;
  struct epoll_event events[128];
  memset(events, '\0', sizeof (struct epoll_event) * 128);
  event_count = epoll_wait(server->epoll, events, 128, -1);
  for (i = 0; i < event_count; i++)
  {
    if ((
          (events[i].events & EPOLLERR) ||
          (events[i].events & EPOLLHUP) ||
          (!(events[i].events & EPOLLIN))
        )
        && (events[i].data.fd != server->l_socket))
    {
      fprintf(stderr, "Error on a client's socket. Connection closed.");
      close(events[i].data.fd);
      continue;
    }
    else if (events[i].data.fd == server->l_socket)
    {
      while (TRUE)
      {
        struct epoll_event event;
        struct sockaddr in_addr;
        unsigned int in_len;
        int socket;
        in_len = sizeof (in_addr);
        socket = accept(server->l_socket, &in_addr, &in_len);
        if (socket == -1)
        {
          if (((*__errno_location ()) != 11) && ((*__errno_location ()) != 11))
            perror ("Error accepting connection");
          break;
        }
        make_socket_non_blocking(socket);
        event.data.fd = socket;
        event.events = EPOLLIN | EPOLLET;
        if ((epoll_ctl(server->epoll, 1, socket, &event)) == -1)
        {
          perror("epoll_ctl add client error");
          lirc_server_close(server);
          lirc_settings_destroy(settings);
          exit(1);
        }
        printf("Client connected.\n");
      }
    }
    else
    {
      enum BOOL disconnect = FALSE;
      while (TRUE)
      {
        long count;
        char buffer[512];
        char *saveptr;
        char *command;
        memset(buffer, '\0', sizeof(char) * 512);
        count = read(events[i].data.fd, buffer, sizeof(buffer));
        if (count == -1)
        {
          if ((*__errno_location ()) != 11)
          {
            perror("Read error");
            disconnect = TRUE;
          }
          break;
        }
        else if (count == 0)
        {
          disconnect = TRUE;
          break;
        }
        command = strtok_r(buffer, "\r\n", &saveptr);
        while (command)
        {
          printf("Message recieved: %s\n", command);
          lirc_client_parse(server, settings, events[i].data.fd, command);
          command = strtok_r(((void *)0), "\r\n", &saveptr);
        }
      }
      if (disconnect)
      {
        printf("Disconnected a client.\n");
        close(events[i].data.fd);
      }
    }
  }
}

variable_types: i int

variable_types: struct epoll_event { unsigned int events; union epoll_data { void *ptr; int fd; unsigned int u32; unsigned long u64; } data; } [128]

variable_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

variable_types: socket int

variable_types:
disconnect
enum BOOL { FALSE=0, TRUE=1 }

variable_types: count long

variable_types:
buffer
char [512]

variable_types:
saveptr
char *

variable_types:
command
char *


decompiled_code:
int __fastcall lirc_channel_cmp(const char **a1, const char *a2)
{
return strcmp(*a1, a2);
}

canonical_decompiled_code:
int __fastcall func1(const char **a1, const char *a2)
{
return strcmp(*a1, a2);
}

original_code:
static int lirc_channel_cmp(const void *channel, const void *c_str)
{
  LIRCChannelData* chan = (LIRCChannelData*)channel;
  char *c = (char *)c_str;
  return strcmp(chan->name, c);
}

canonical_original_code:
static int lirc_channel_cmp(void *channel, void *c_str)
{
  struct LIRCChannelData_struct *chan = (LIRCChannelData*)channel;
  char *c = (char *)c_str;
  return strcmp(chan->name, c);
}

variable_types:
channel
void *

variable_types: struct LIRCChannelData_struct { char *name; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *client_list; } *

variable_types:
c
char *

user_defined_types: struct LIRCChannelData_struct { char *name; struct dlist_t *client_list; }


decompiled_code:
_QWORD *lirc_channel_new_metadata()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)safe_malloc(16LL);
*v0 = 0LL;
v0[1] = make_empty_list();
return v0;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)safe_malloc(16LL);
*v0 = 0LL;
v0[1] = make_empty_list();
return v0;
}

original_code:
static LIRCChannelData* lirc_channel_new_metadata()
{
  LIRCChannelData* channel = safe_malloc(sizeof(LIRCChannelData));
  channel->name = ((void *)0);
  channel->client_list = make_empty_list();
  return channel;
}

canonical_original_code:
static struct LIRCChannelData_struct *lirc_channel_new_metadata()
{
  struct LIRCChannelData_struct *channel = safe_malloc(sizeof(LIRCChannelData));
  channel->name = ((void *)0);
  channel->client_list = make_empty_list();
  return channel;
}

return_type: struct LIRCChannelData_struct { char *name; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *client_list; } *


decompiled_code:
int __fastcall lirc_channel_join(__int64 a1, __int64 a2, const char *a3)
{
_QWORD *v4; // rbx
__int64 v5; // rbx
int result; // eax
size_t v7; // rax
char v8[552]; // [rsp+0h] [rbp-228h] BYREF

v4 = (_QWORD *)find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( !v4 )
{
v4 = lirc_channel_new_metadata();
*v4 = safe_strdup(a3);
insert_at_front(*(_QWORD *)(a1 + 32), v4, 8LL);
}
insert_at_front(v4[1], a2, 8LL);
insert_at_front(*(_QWORD *)(a2 + 24), v4, 8LL);
v5 = *(_QWORD *)v4[1];
for ( result = sprintf(v8, ":%s!~%s@anon.com JOIN %s\r\n", *(const char **)(a2 + 8), *(const char **)(a2 + 16), a3);
v5;
v5 = *(_QWORD *)(v5 + 16) )
{
v7 = strlen(v8);
result = send(**(_DWORD **)(v5 + 8), v8, v7, 0);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2, const char *a3)
{
_QWORD *v4; // rbx
__int64 v5; // rbx
int result; // eax
size_t v7; // rax
char v8[552]; // [rsp+0h] [rbp-228h] BYREF

v4 = (_QWORD *)find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( !v4 )
{
v4 = func2();
*v4 = safe_strdup(a3);
insert_at_front(*(_QWORD *)(a1 + 32), v4, 8LL);
}
insert_at_front(v4[1], a2, 8LL);
insert_at_front(*(_QWORD *)(a2 + 24), v4, 8LL);
v5 = *(_QWORD *)v4[1];
for ( result = sprintf(v8, ":%s!~%s@anon.com JOIN %s\r\n", *(const char **)(a2 + 8), *(const char **)(a2 + 16), a3);
v5;
v5 = *(_QWORD *)(v5 + 16) )
{
v7 = strlen(v8);
result = send(**(_DWORD **)(v5 + 8), v8, v7, 0);
}
return result;
}

original_code:
void lirc_channel_join(struct LIRCServer_struct* server,
                       struct LIRCClientData_struct* client,
                       char *channel)
{
  char temp[512];
  dlnode_t* client_node;
  LIRCChannelData* c =
    (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    c = lirc_channel_new_metadata();
    c->name = safe_strdup(channel);
    insert_at_front(server->channel_list, c, sizeof(c));
  }
  insert_at_front(c->client_list, client,
                  sizeof(client));
  insert_at_front(client->channel_list, c, sizeof(c));
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com JOIN %s\r\n", client->nick, client->user,
          channel);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data =
      (struct LIRCClientData_struct *)client_node->data;
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
}

canonical_original_code:
void lirc_channel_join(struct LIRCServer_struct *server, struct LIRCClientData_struct *client, char *channel)
{
  char temp[512];
  struct dlnode *client_node;
  struct LIRCChannelData_struct *c = (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    c = lirc_channel_new_metadata();
    c->name = safe_strdup(channel);
    insert_at_front(server->channel_list, c, sizeof(c));
  }
  insert_at_front(c->client_list, client,
                  sizeof(client));
  insert_at_front(client->channel_list, c, sizeof(c));
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com JOIN %s\r\n", client->nick, client->user,
          channel);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data = (struct LIRCClientData_struct *)client_node->data;
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
}

variable_types: struct LIRCClientData_struct { int socket; char *nick; struct dlist_t *channel_list; } *

variable_types:
channel
char *

variable_types:
temp
char [512]

variable_types: struct LIRCClientData_struct { int socket; char *nick; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *channel_list; } *


decompiled_code:
ssize_t __fastcall lirc_channel_who(__int64 a1, __int64 a2, const char *a3)
{
__int64 v4; // rbx
size_t v5; // rax
size_t v6; // rax
char v8[536]; // [rsp+0h] [rbp-218h] BYREF

v4 = **(_QWORD **)(find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp) + 8);
memset(v8, 0, 0x200uLL);
sprintf(v8, ":lirc.org 353 %s = %s :", *(const char **)(a2 + 8), a3);
for ( ; v4; v4 = *(_QWORD *)(v4 + 16) )
{
strcat(v8, *(const char **)(*(_QWORD *)(v4 + 8) + 8LL));
*(_WORD *)&v8[strlen(v8)] = 32;
}
strcat(v8, "\r\n");
v5 = strlen(v8);
send(*(_DWORD *)a2, v8, v5, 0);
memset(v8, 0, 0x200uLL);
sprintf(v8, ":lirc.org 366 %s %s :End of /NAMES list\r\n", *(const char **)(a2 + 8), a3);
v6 = strlen(v8);
return send(*(_DWORD *)a2, v8, v6, 0);
}

canonical_decompiled_code:
ssize_t __fastcall func4(__int64 a1, __int64 a2, const char *a3)
{
__int64 v4; // rbx
size_t v5; // rax
size_t v6; // rax
char v8[536]; // [rsp+0h] [rbp-218h] BYREF

v4 = **(_QWORD **)(find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp) + 8);
memset(v8, 0, 0x200uLL);
sprintf(v8, ":lirc.org 353 %s = %s :", *(const char **)(a2 + 8), a3);
for ( ; v4; v4 = *(_QWORD *)(v4 + 16) )
{
strcat(v8, *(const char **)(*(_QWORD *)(v4 + 8) + 8LL));
*(_WORD *)&v8[strlen(v8)] = 32;
}
strcat(v8, "\r\n");
v5 = strlen(v8);
send(*(_DWORD *)a2, v8, v5, 0);
memset(v8, 0, 0x200uLL);
sprintf(v8, ":lirc.org 366 %s %s :End of /NAMES list\r\n", *(const char **)(a2 + 8), a3);
v6 = strlen(v8);
return send(*(_DWORD *)a2, v8, v6, 0);
}

original_code:
void lirc_channel_who(struct LIRCServer_struct* server,
                        struct LIRCClientData_struct* client,
                        char *channel)
{
  int size = 0;
  char temp[512];
  LIRCChannelData* c;
  dlnode_t* client_node;
  c = (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  client_node = c->client_list->head;
  memset(temp, '\0', sizeof (char) * 512);
  sprintf(temp, ":lirc.org 353 %s = %s :", client->nick, channel);
  size += strlen(temp);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct* chan_client =
      ((struct LIRCClientData_struct*)(client_node->data));
    strcat(temp, chan_client->nick);
    strcat(temp, " ");
    client_node = client_node->next;
  }
  strcat(temp, "\r\n");
  send(client->socket, temp, strlen(temp), 0);
  memset(temp, '\0', sizeof (char) * 512);
  sprintf(temp, ":lirc.org 366 %s %s :End of /NAMES list\r\n",
          client->nick, channel);
  send(client->socket, temp, strlen(temp), 0);
}

canonical_original_code:
void lirc_channel_who(struct LIRCServer_struct *server, struct LIRCClientData_struct *client, char *channel)
{
  int size = 0;
  char temp[512];
  struct LIRCChannelData_struct *c;
  struct dlnode *client_node;
  c = (struct LIRCChannelData_struct *)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  client_node = c->client_list->head;
  memset(temp, '\0', sizeof (char) * 512);
  sprintf(temp, ":lirc.org 353 %s = %s :", client->nick, channel);
  size += strlen(temp);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *chan_client = ((struct LIRCClientData_struct*)(client_node->data));
    strcat(temp, chan_client->nick);
    strcat(temp, " ");
    client_node = client_node->next;
  }
  strcat(temp, "\r\n");
  send(client->socket, temp, strlen(temp), 0);
  memset(temp, '\0', sizeof (char) * 512);
  sprintf(temp, ":lirc.org 366 %s %s :End of /NAMES list\r\n",
          client->nick, channel);
  send(client->socket, temp, strlen(temp), 0);
}

variable_types: struct LIRCServer_struct { int epoll; int l_socket; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } l_socket_addr; struct dlist_t { struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *head; struct dlnode *foot; int list_len; int size; } *client_list; struct dlist_t *channel_list; } *

variable_types: size int

user_defined_types: struct LIRCClientData_struct { int socket; char *nick; struct dlist_t *channel_list; }


decompiled_code:
int __fastcall lirc_channel_message(__int64 a1, __int64 a2, const char *a3, const char *a4)
{
__int64 v6; // rax
__int64 v7; // rbx
int *v8; // rbp
size_t v9; // rax
char v11[552]; // [rsp+0h] [rbp-228h] BYREF

v6 = find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( v6 )
{
v7 = **(_QWORD **)(v6 + 8);
for ( LODWORD(v6) = sprintf(
v11,
":%s!~%s@anon.com PRIVMSG %s %s\r\n",
*(const char **)(a2 + 8),
*(const char **)(a2 + 16),
a3,
a4); v7; v7 = *(_QWORD *)(v7 + 16) )
{
v8 = *(int **)(v7 + 8);
if ( (int *)a2 != v8 )
{
v9 = strlen(v11);
LODWORD(v6) = send(*v8, v11, v9, 0);
}
}
}
return v6;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, __int64 a2, const char *a3, const char *a4)
{
__int64 v6; // rax
__int64 v7; // rbx
int *v8; // rbp
size_t v9; // rax
char v11[552]; // [rsp+0h] [rbp-228h] BYREF

v6 = find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( v6 )
{
v7 = **(_QWORD **)(v6 + 8);
for ( LODWORD(v6) = sprintf(
v11,
":%s!~%s@anon.com PRIVMSG %s %s\r\n",
*(const char **)(a2 + 8),
*(const char **)(a2 + 16),
a3,
a4); v7; v7 = *(_QWORD *)(v7 + 16) )
{
v8 = *(int **)(v7 + 8);
if ( (int *)a2 != v8 )
{
v9 = strlen(v11);
LODWORD(v6) = send(*v8, v11, v9, 0);
}
}
}
return v6;
}

original_code:
void lirc_channel_message(struct LIRCServer_struct* server,
                        struct LIRCClientData_struct* client,
                        char *channel, char *message)
{
  char temp[512];
  dlnode_t* client_node;
  LIRCChannelData* c =
    (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    return;
  }
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com PRIVMSG %s %s\r\n",
          client->nick, client->user, channel, message);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data =
      (struct LIRCClientData_struct *)client_node->data;
    if (client_node_data == client)
    {
      client_node = client_node->next;
      continue;
    }
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
}

canonical_original_code:
void lirc_channel_message(struct LIRCServer_struct *server, struct LIRCClientData_struct *client, char *channel, char *message)
{
  char temp[512];
  struct dlnode *client_node;
  struct LIRCChannelData_struct *c = (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    return;
  }
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com PRIVMSG %s %s\r\n",
          client->nick, client->user, channel, message);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data = (struct LIRCClientData_struct *)client_node->data;
    if (client_node_data == client)
    {
      client_node = client_node->next;
      continue;
    }
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
}

variable_types:
message
char *

variable_types: struct dlnode { int size; void *data; struct dlnode *next; struct dlnode *prev; } *


decompiled_code:
ssize_t __fastcall lirc_channel_leave(__int64 a1, __int64 a2, const char *a3)
{
ssize_t result; // rax
ssize_t v5; // rbx
__int64 v6; // rbx
size_t v7; // rax
size_t v8; // rax
char v9[536]; // [rsp+0h] [rbp-218h] BYREF

result = find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( result )
{
v5 = result;
remove_element(*(_QWORD *)(a2 + 24), result, lirc_channel_cmp);
remove_element(*(_QWORD *)(v5 + 8), a2, lirc_client_cmp);
v6 = **(_QWORD **)(v5 + 8);
sprintf(v9, ":%s!~%s@anon.com PART %s\r\n", *(const char **)(a2 + 8), *(const char **)(a2 + 16), a3);
for ( ; v6; v6 = *(_QWORD *)(v6 + 16) )
{
v7 = strlen(v9);
send(**(_DWORD **)(v6 + 8), v9, v7, 0);
}
v8 = strlen(v9);
result = send(*(_DWORD *)a2, v9, v8, 0);
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func6(__int64 a1, __int64 a2, const char *a3)
{
ssize_t result; // rax
ssize_t v5; // rbx
__int64 v6; // rbx
size_t v7; // rax
size_t v8; // rax
char v9[536]; // [rsp+0h] [rbp-218h] BYREF

result = find_element(*(_QWORD *)(a1 + 32), a3, lirc_channel_cmp);
if ( result )
{
v5 = result;
remove_element(*(_QWORD *)(a2 + 24), result, lirc_channel_cmp);
remove_element(*(_QWORD *)(v5 + 8), a2, lirc_client_cmp);
v6 = **(_QWORD **)(v5 + 8);
sprintf(v9, ":%s!~%s@anon.com PART %s\r\n", *(const char **)(a2 + 8), *(const char **)(a2 + 16), a3);
for ( ; v6; v6 = *(_QWORD *)(v6 + 16) )
{
v7 = strlen(v9);
send(**(_DWORD **)(v6 + 8), v9, v7, 0);
}
v8 = strlen(v9);
result = send(*(_DWORD *)a2, v9, v8, 0);
}
return result;
}

original_code:
void lirc_channel_leave(struct LIRCServer_struct* server,
                        struct LIRCClientData_struct* client,
                        char *channel)
{
  char temp[512];
  dlnode_t* client_node;
  LIRCChannelData* c =
    (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    return;
  }
  remove_element(client->channel_list, c, lirc_channel_cmp);
  remove_element(c->client_list, client, lirc_client_cmp);
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com PART %s\r\n", client->nick, client->user,
          channel);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data =
      (struct LIRCClientData_struct *)client_node->data;
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
  send(client->socket, temp, strlen(temp), 0);
}

canonical_original_code:
void lirc_channel_leave(struct LIRCServer_struct *server, struct LIRCClientData_struct *client, char *channel)
{
  char temp[512];
  struct dlnode *client_node;
  struct LIRCChannelData_struct *c = (LIRCChannelData*)find_element(server->channel_list,
                                   channel, lirc_channel_cmp);
  if (c == ((void *)0))
  {
    return;
  }
  remove_element(client->channel_list, c, lirc_channel_cmp);
  remove_element(c->client_list, client, lirc_client_cmp);
  client_node = c->client_list->head;
  sprintf(temp, ":%s!~%s@anon.com PART %s\r\n", client->nick, client->user,
          channel);
  while (client_node != ((void *)0))
  {
    struct LIRCClientData_struct *client_node_data = (struct LIRCClientData_struct *)client_node->data;
    send(client_node_data->socket, temp, strlen(temp), 0);
    client_node = client_node->next;
  }
  send(client->socket, temp, strlen(temp), 0);
}