main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v5; // rsi
char *v6; // rax
const char *v7; // r12
size_t v8; // rax
int v9; // er12
int v10; // er13
__int64 v11; // r15
const char *v12; // r14
int v13; // eax
int v14; // eax
int v15; // eax
char v16; // dl
const char *v17; // rax
char v18; // dl
__int64 v19; // rax
__int64 v20; // rax
int v21; // er13
int v23; // eax
int v24; // eax
__int64 v25; // rax
struct tm *v26; // rax
int v27; // ecx
__int64 v28; // rsi
unsigned int v29; // ecx
char *v30; // rdi
unsigned __int8 *v31; // rax
_BYTE *i; // rax
char v33; // dl
struct timespec *v34; // rdi
char *v35; // rax
unsigned int v36; // [rsp-30h] [rbp-138h]
unsigned int v37; // [rsp+8h] [rbp-100h]
unsigned int v38; // [rsp+Ch] [rbp-FCh]
unsigned int v39; // [rsp+1Ch] [rbp-ECh] BYREF
unsigned __int64 v40; // [rsp+20h] [rbp-E8h] BYREF
unsigned int v41; // [rsp+28h] [rbp-E0h] BYREF
unsigned int v42; // [rsp+2Ch] [rbp-DCh] BYREF
unsigned int v43; // [rsp+30h] [rbp-D8h] BYREF
unsigned int v44; // [rsp+34h] [rbp-D4h] BYREF
time_t v45; // [rsp+38h] [rbp-D0h] BYREF
struct stat timer; // [rsp+40h] [rbp-C8h] BYREF

v5 = *argv;
v44 = 1;
v43 = 0;
v42 = 0;
v41 = 0;
v40 = 0LL;
v39 = 0;
strcpy(execpath, v5);
v6 = strrchr(execpath, 47);
if ( v6 || (v6 = strrchr(execpath, 92)) != 0LL )
*v6 = 0;
else
strcpy(execpath, ".");
v7 = *argv;
v8 = strlen(*argv);
if ( v8 <= 3 || (v9 = strcmp(&v7[v8 - 4], ".cgi")) != 0 )
{
v10 = 0;
if ( argc > 1 )
{
LABEL_6:
v38 = 1;
v11 = 1LL;
v9 = 0;
v37 = 0;
while ( 1 )
{
v12 = argv[v11];
if ( *v12 == 45 )
{
while ( 2 )
{
switch ( v12[1] )
{
case '?':
case 'h':
goto LABEL_29;
case 'A':
case 'a':
v37 = 1;
goto LABEL_19;
case 'J':
v37 = 1;
goto LABEL_20;
case 'M':
v10 = 1;
if ( v12[2] == 45 )
{
*((_BYTE *)v12 + 1) = 45;
for ( i = v12 + 2; *i; *(i - 1) = v33 )
v33 = *++i;
v38 = 0;
v12 = argv[v11];
v10 = 1;
}
goto LABEL_20;
case 'T':
LABEL_19:
v9 = 1;
goto LABEL_20;
case 'd':
v44 = 0;
LABEL_20:
v16 = v12[2];
v17 = v12 + 2;
*((_BYTE *)v12 + 1) = v16;
if ( v16 )
{
do
{
v18 = *++v17;
*((_BYTE *)v17 - 1) = v18;
}
while ( v18 );
}
v12 = argv[v11];
if ( v12[1] )
continue;
goto LABEL_8;
case 'v':
version();
return 255;
default:
version();
LABEL_29:
usage();
return 255;
}
}
}
if ( (unsigned __int8)(*v12 - 48) > 9u )
goto LABEL_8;
v13 = strlen(argv[v11]);
if ( v13 == 6 )
break;
if ( v13 <= 6 )
{
if ( v13 <= 2 )
{
if ( v13 > 0 )
{
v23 = count_0++;
switch ( v23 )
{
case 0:
v39 = atoi(v12) + 1900;
break;
case 1:
LODWORD(v40) = atoi(v12);
break;
case 2:
HIDWORD(v40) = atoi(v12);
break;
case 3:
v41 = atoi(v12);
break;
case 4:
v42 = atoi(v12);
break;
case 5:
v43 = atoi(v12);
break;
default:
goto LABEL_8;
}
}
}
else if ( v13 == 4 )
{
v14 = count_0 + 1;
count_0 = v14;
if ( v14 == 1 )
{
v39 = atoi(v12);
}
else if ( v14 == 2 )
{
LODWORD(v40) = atoi(v12) / 100;
v15 = atoi(v12);
count_0 = 3;
HIDWORD(v40) = v15 % 100;
}
}
goto LABEL_8;
}
if ( v13 == 8 && ++count_0 == 1 )
{
v19 = atol(v12) / 10000;
LABEL_27:
v39 = v19;
LODWORD(v40) = atol(v12) / 100 % 100;
v20 = atol(v12);
count_0 = 3;
HIDWORD(v40) = v20 % 100;
}
LABEL_8:
if ( argc <= (int)++v11 )
goto LABEL_47;
}
v24 = count_0 + 1;
count_0 = v24;
if ( v24 != 1 )
{
if ( v24 == 4 )
{
v41 = atol(v12) / 10000;
v42 = atol(v12) / 100 % 100;
v25 = atol(v12);
count_0 = 6;
v43 = v25 % 100;
}
goto LABEL_8;
}
LODWORD(v19) = atol(v12) / 10000 + 1900;
goto LABEL_27;
}
v37 = 0;
v9 = 0;
v38 = 1;
LABEL_38:
time((time_t *)&timer);
v26 = localtime((const time_t *)&timer);
v27 = v26->tm_mon;
v39 = v26->tm_year + 1900;
v40 = __PAIR64__(v26->tm_mday, v27 + 1);
v28 = (unsigned int)(v27 + 1);
v41 = v26->tm_hour;
v29 = v26->tm_min;
LODWORD(v26) = v26->tm_sec;
v42 = v29;
v43 = (unsigned int)v26;
if ( v10 )
v44 = 1;
LABEL_40:
v36 = v10;
v21 = 0;
koyomi(v39, v28, HIDWORD(v40), v41, v42, v43, v36, v38, v44, v37, v9);
return v21;
}
v30 = getenv("REQUEST_METHOD");
if ( !v30 || (v21 = strcmp(v30, "HEAD")) != 0 )
{
fwrite("Content-type: text/html\n\n", 1uLL, 0x19uLL, stdout);
v31 = (unsigned __int8 *)getenv("QUERY_STRING");
if ( v31 )
setParameter(v31, (int *)&v39, (int *)&v40, (int *)&v40 + 1, (int *)&v41, (int *)&v42, (int *)&v43, (int *)&v44);
if ( argc > 1 )
{
v10 = 1;
goto LABEL_6;
}
v37 = 0;
v10 = 1;
v38 = 1;
LABEL_47:
v28 = (unsigned int)v40;
if ( v39 || v40 )
goto LABEL_40;
goto LABEL_38;
}
v34 = &timer.st_ctim;
if ( stat(*argv, &timer) )
{
v34 = (struct timespec *)&v45;
v45 = time(0LL);
}
v35 = ctime(&v34->tv_sec);
printf("Last-Modified: %s", v35);
fwrite("Content-type: text/html\n\n", 1uLL, 0x19uLL, stdout);
return v21;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v5; // rsi
char *v6; // rax
const char *v7; // r12
size_t v8; // rax
int v9; // er12
int v10; // er13
__int64 v11; // r15
const char *v12; // r14
int v13; // eax
int v14; // eax
int v15; // eax
char v16; // dl
const char *v17; // rax
char v18; // dl
__int64 v19; // rax
__int64 v20; // rax
int v21; // er13
int v23; // eax
int v24; // eax
__int64 v25; // rax
struct tm *v26; // rax
int v27; // ecx
__int64 v28; // rsi
unsigned int v29; // ecx
char *v30; // rdi
unsigned __int8 *v31; // rax
_BYTE *i; // rax
char v33; // dl
struct timespec *v34; // rdi
char *v35; // rax
unsigned int v36; // [rsp-30h] [rbp-138h]
unsigned int v37; // [rsp+8h] [rbp-100h]
unsigned int v38; // [rsp+Ch] [rbp-FCh]
unsigned int v39; // [rsp+1Ch] [rbp-ECh] BYREF
unsigned __int64 v40; // [rsp+20h] [rbp-E8h] BYREF
unsigned int v41; // [rsp+28h] [rbp-E0h] BYREF
unsigned int v42; // [rsp+2Ch] [rbp-DCh] BYREF
unsigned int v43; // [rsp+30h] [rbp-D8h] BYREF
unsigned int v44; // [rsp+34h] [rbp-D4h] BYREF
time_t v45; // [rsp+38h] [rbp-D0h] BYREF
struct stat timer; // [rsp+40h] [rbp-C8h] BYREF

v5 = *argv;
v44 = 1;
v43 = 0;
v42 = 0;
v41 = 0;
v40 = 0LL;
v39 = 0;
strcpy(execpath, v5);
v6 = strrchr(execpath, 47);
if ( v6 || (v6 = strrchr(execpath, 92)) != 0LL )
*v6 = 0;
else
strcpy(execpath, ".");
v7 = *argv;
v8 = strlen(*argv);
if ( v8 <= 3 || (v9 = strcmp(&v7[v8 - 4], ".cgi")) != 0 )
{
v10 = 0;
if ( argc > 1 )
{
LABEL_6:
v38 = 1;
v11 = 1LL;
v9 = 0;
v37 = 0;
while ( 1 )
{
v12 = argv[v11];
if ( *v12 == 45 )
{
while ( 2 )
{
switch ( v12[1] )
{
case '?':
case 'h':
goto LABEL_29;
case 'A':
case 'a':
v37 = 1;
goto LABEL_19;
case 'J':
v37 = 1;
goto LABEL_20;
case 'M':
v10 = 1;
if ( v12[2] == 45 )
{
*((_BYTE *)v12 + 1) = 45;
for ( i = v12 + 2; *i; *(i - 1) = v33 )
v33 = *++i;
v38 = 0;
v12 = argv[v11];
v10 = 1;
}
goto LABEL_20;
case 'T':
LABEL_19:
v9 = 1;
goto LABEL_20;
case 'd':
v44 = 0;
LABEL_20:
v16 = v12[2];
v17 = v12 + 2;
*((_BYTE *)v12 + 1) = v16;
if ( v16 )
{
do
{
v18 = *++v17;
*((_BYTE *)v17 - 1) = v18;
}
while ( v18 );
}
v12 = argv[v11];
if ( v12[1] )
continue;
goto LABEL_8;
case 'v':
func1();
return 255;
default:
func1();
LABEL_29:
func2();
return 255;
}
}
}
if ( (unsigned __int8)(*v12 - 48) > 9u )
goto LABEL_8;
v13 = strlen(argv[v11]);
if ( v13 == 6 )
break;
if ( v13 <= 6 )
{
if ( v13 <= 2 )
{
if ( v13 > 0 )
{
v23 = count_0++;
switch ( v23 )
{
case 0:
v39 = atoi(v12) + 1900;
break;
case 1:
LODWORD(v40) = atoi(v12);
break;
case 2:
HIDWORD(v40) = atoi(v12);
break;
case 3:
v41 = atoi(v12);
break;
case 4:
v42 = atoi(v12);
break;
case 5:
v43 = atoi(v12);
break;
default:
goto LABEL_8;
}
}
}
else if ( v13 == 4 )
{
v14 = count_0 + 1;
count_0 = v14;
if ( v14 == 1 )
{
v39 = atoi(v12);
}
else if ( v14 == 2 )
{
LODWORD(v40) = atoi(v12) / 100;
v15 = atoi(v12);
count_0 = 3;
HIDWORD(v40) = v15 % 100;
}
}
goto LABEL_8;
}
if ( v13 == 8 && ++count_0 == 1 )
{
v19 = atol(v12) / 10000;
LABEL_27:
v39 = v19;
LODWORD(v40) = atol(v12) / 100 % 100;
v20 = atol(v12);
count_0 = 3;
HIDWORD(v40) = v20 % 100;
}
LABEL_8:
if ( argc <= (int)++v11 )
goto LABEL_47;
}
v24 = count_0 + 1;
count_0 = v24;
if ( v24 != 1 )
{
if ( v24 == 4 )
{
v41 = atol(v12) / 10000;
v42 = atol(v12) / 100 % 100;
v25 = atol(v12);
count_0 = 6;
v43 = v25 % 100;
}
goto LABEL_8;
}
LODWORD(v19) = atol(v12) / 10000 + 1900;
goto LABEL_27;
}
v37 = 0;
v9 = 0;
v38 = 1;
LABEL_38:
time((time_t *)&timer);
v26 = localtime((const time_t *)&timer);
v27 = v26->tm_mon;
v39 = v26->tm_year + 1900;
v40 = __PAIR64__(v26->tm_mday, v27 + 1);
v28 = (unsigned int)(v27 + 1);
v41 = v26->tm_hour;
v29 = v26->tm_min;
LODWORD(v26) = v26->tm_sec;
v42 = v29;
v43 = (unsigned int)v26;
if ( v10 )
v44 = 1;
LABEL_40:
v36 = v10;
v21 = 0;
func3(v39, v28, HIDWORD(v40), v41, v42, v43, v36, v38, v44, v37, v9);
return v21;
}
v30 = getenv("REQUEST_METHOD");
if ( !v30 || (v21 = strcmp(v30, "HEAD")) != 0 )
{
fwrite("Content-type: text/html\n\n", 1uLL, 0x19uLL, stdout);
v31 = (unsigned __int8 *)getenv("QUERY_STRING");
if ( v31 )
func0(v31, (int *)&v39, (int *)&v40, (int *)&v40 + 1, (int *)&v41, (int *)&v42, (int *)&v43, (int *)&v44);
if ( argc > 1 )
{
v10 = 1;
goto LABEL_6;
}
v37 = 0;
v10 = 1;
v38 = 1;
LABEL_47:
v28 = (unsigned int)v40;
if ( v39 || v40 )
goto LABEL_40;
goto LABEL_38;
}
v34 = &timer.st_ctim;
if ( stat(*argv, &timer) )
{
v34 = (struct timespec *)&v45;
v45 = time(0LL);
}
v35 = ctime(&v34->tv_sec);
printf("Last-Modified: %s", v35);
fwrite("Content-type: text/html\n\n", 1uLL, 0x19uLL, stdout);
return v21;
}

original_code:
int
main( int argc, char *argv[] )
{
    int yy, mm, dd, HH, MM, SS;
    int printTsupo = 0;
    int printTime = 1;
    int printTrain = 0;
    int htmlMode = 0;
    int withHeader = 1;
    char *p;
    yy = mm = dd = HH = MM = SS = 0;
    strcpy( execpath, argv[0] );
    if ( ( p = strrchr( execpath, '/' ) ) != ((void *)0) )
        *p = '\0';
    else if ( ( p = strrchr( execpath, '\\' ) ) != ((void *)0) )
        *p = '\0';
    else
        strcpy( execpath, "." );
    if ( (strlen(argv[0]) >= 4) &&
         !strcmp( &argv[0][strlen(argv[0]) - 4], ".cgi" ) ) {
        if ( ( p = getenv( "REQUEST_METHOD" ) ) != ((void *)0) ) {
            if ( !strcmp( p, "HEAD" ) ) {
                struct stat s;
                if ( !stat( argv[0], &s ) ) {
                    printf( "Last-Modified: %s", ctime( &(s.st_ctim.tv_sec) ) );
                }
                else {
                    time_t t = time( ((void *)0) );
                    printf( "Last-Modified: %s", ctime( &t ) );
                }
                fputs( "Content-type: text/html\n\n", stdout );
                return ( 0 );
            }
        }
        htmlMode = 1;
        withHeader = 1;
        fputs( "Content-type: text/html\n\n", stdout );
        if ( ( p = getenv( "QUERY_STRING" ) ) != ((void *)0) )
            setParameter( p, &yy, &mm, &dd, &HH, &MM, &SS, &printTime );
    }
    if ( argc > 1 ) {
        int i;
        for ( i = 1; i < argc; i++ ) {
            if ( argv[i][0] == '-' ) {
                do {
                    switch ( argv[i][1] ) {
                      case 'v' :
                        version();
                        return ( 255 );
                        break;
                      case 'h' :
                      case '?' :
                        usage();
                        return ( 255 );
                        break;
                      case 'd' :
                        printTime = 0;
                        break;
                      case 'T' :
                        printTsupo = 1;
                        break;
                      case 'J' :
                        printTrain = 1;
                        break;
                      case 'a' :
                      case 'A' :
                        printTsupo = 1;
                        printTrain = 1;
                        break;
                      case 'M':
                        htmlMode = 1;
                        if ( (argv[i][2] == '-') || (argv[i][2] == '-') ) {
                            char *p = &argv[i][1];
                            char *q = &argv[i][2];
                            withHeader = (argv[i][2] == '-') ? 0 : 1;
                            *p = *q;
                            while ( *q )
                                *++p = *++q;
                        }
                        break;
                      default :
                        version();
                        usage();
                        return ( 255 );
                        break;
                    }
                    {
                        char *p = &argv[i][1];
                        char *q = &argv[i][2];
                        *p = *q;
                        while ( *q )
                            *++p = *++q;
                    }
                } while ( argv[i][1] != '\0' );
                continue;
            }
            if ( ( argv[i][0] >= '0' ) && ( argv[i][0] <= '9' ) ) {
                int len = strlen( argv[i] );
                static int count = 0;
                switch ( len ) {
                  case 1 :
                  case 2 :
                    switch ( ++count ) {
                      case 1 :
                        yy = atoi( argv[i] ) + 1900;
                        break;
                      case 2 :
                        mm = atoi( argv[i] );
                        break;
                      case 3 :
                        dd = atoi( argv[i] );
                        break;
                      case 4 :
                        HH = atoi( argv[i] );
                        break;
                      case 5 :
                        MM = atoi( argv[i] );
                        break;
                      case 6 :
                        SS = atoi( argv[i] );
                        break;
                    }
                    break;
                  case 4 :
                    switch ( ++count ) {
                      case 1 :
                        yy = atoi( argv[i] );
                        break;
                      case 2 :
                        mm = atoi( argv[i] ) / 100;
                        dd = atoi( argv[i] ) % 100;
                        count++;
                        break;
                    }
                    break;
                  case 6 :
                    switch ( ++count ) {
                      case 1 :
                        yy = (int)( atol( argv[i] ) / 10000L ) + 1900;
                        mm = (int)( atol( argv[i] ) / 100L % 100L );
                        dd = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                      case 4 :
                        HH = (int)( atol( argv[i] ) / 10000L );
                        MM = (int)( atol( argv[i] ) / 100L % 100L );
                        SS = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                    }
                    break;
                  case 8 :
                    switch ( ++count ) {
                      case 1 :
                        yy = (int)( atol( argv[i] ) / 10000L );
                        mm = (int)( atol( argv[i] ) / 100L % 100L );
                        dd = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                    }
                    break;
                }
            }
        }
    }
    if ( ( yy == 00 ) && ( mm == 00 ) && ( dd == 00 ) ) {
        time_t t;
        struct tm *tm;
        int _mm = 0;
        time( &t );
        tm = localtime( &t );
        yy = tm->tm_year + 1900;
        mm = tm->tm_mon + 1;
        dd = tm->tm_mday;
        HH = tm->tm_hour;
        MM = tm->tm_min;
        SS = tm->tm_sec;
        if ( htmlMode )
            printTime = 1;
    }
    koyomi( yy, mm, dd, HH, MM, SS,
            htmlMode, withHeader, printTime, printTrain, printTsupo );
    return ( 0 );
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int yy; int mm; int dd; int HH; int MM; int SS;
    int printTsupo = 0;
    int printTime = 1;
    int printTrain = 0;
    int htmlMode = 0;
    int withHeader = 1;
    char *p;
    yy = mm = dd = HH = MM = SS = 0;
    strcpy( execpath, argv[0] );
    if ( ( p = strrchr( execpath, '/' ) ) != ((void *)0) )
        *p = '\0';
    else if ( ( p = strrchr( execpath, '\\' ) ) != ((void *)0) )
        *p = '\0';
    else
        strcpy( execpath, "." );
    if ( (strlen(argv[0]) >= 4) &&
         !strcmp( &argv[0][strlen(argv[0]) - 4], ".cgi" ) ) {
        if ( ( p = getenv( "REQUEST_METHOD" ) ) != ((void *)0) ) {
            if ( !strcmp( p, "HEAD" ) ) {
                struct stat s;
                if ( !stat( argv[0], &s ) ) {
                    printf( "Last-Modified: %s", ctime( &(s.st_ctim.tv_sec) ) );
                }
                else {
                    long t = time( ((void *)0) );
                    printf( "Last-Modified: %s", ctime( &t ) );
                }
                fputs( "Content-type: text/html\n\n", stdout );
                return ( 0 );
            }
        }
        htmlMode = 1;
        withHeader = 1;
        fputs( "Content-type: text/html\n\n", stdout );
        if ( ( p = getenv( "QUERY_STRING" ) ) != ((void *)0) )
            setParameter( p, &yy, &mm, &dd, &HH, &MM, &SS, &printTime );
    }
    if ( argc > 1 ) {
        int i;
        for ( i = 1; i < argc; i++ ) {
            if ( argv[i][0] == '-' ) {
                do {
                    switch ( argv[i][1] ) {
                      case 'v' :
                        version();
                        return ( 255 );
                        break;
                      case 'h' :
                      case '?' :
                        usage();
                        return ( 255 );
                        break;
                      case 'd' :
                        printTime = 0;
                        break;
                      case 'T' :
                        printTsupo = 1;
                        break;
                      case 'J' :
                        printTrain = 1;
                        break;
                      case 'a' :
                      case 'A' :
                        printTsupo = 1;
                        printTrain = 1;
                        break;
                      case 'M':
                        htmlMode = 1;
                        if ( (argv[i][2] == '-') || (argv[i][2] == '-') ) {
                            char *p = &argv[i][1];
                            char *q = &argv[i][2];
                            withHeader = (argv[i][2] == '-') ? 0 : 1;
                            *p = *q;
                            while ( *q )
                                *++p = *++q;
                        }
                        break;
                      default :
                        version();
                        usage();
                        return ( 255 );
                        break;
                    }
                    {
                        char *p = &argv[i][1];
                        char *q = &argv[i][2];
                        *p = *q;
                        while ( *q )
                            *++p = *++q;
                    }
                } while ( argv[i][1] != '\0' );
                continue;
            }
            if ( ( argv[i][0] >= '0' ) && ( argv[i][0] <= '9' ) ) {
                int len = strlen( argv[i] );
                static int count = 0;
                switch ( len ) {
                  case 1 :
                  case 2 :
                    switch ( ++count ) {
                      case 1 :
                        yy = atoi( argv[i] ) + 1900;
                        break;
                      case 2 :
                        mm = atoi( argv[i] );
                        break;
                      case 3 :
                        dd = atoi( argv[i] );
                        break;
                      case 4 :
                        HH = atoi( argv[i] );
                        break;
                      case 5 :
                        MM = atoi( argv[i] );
                        break;
                      case 6 :
                        SS = atoi( argv[i] );
                        break;
                    }
                    break;
                  case 4 :
                    switch ( ++count ) {
                      case 1 :
                        yy = atoi( argv[i] );
                        break;
                      case 2 :
                        mm = atoi( argv[i] ) / 100;
                        dd = atoi( argv[i] ) % 100;
                        count++;
                        break;
                    }
                    break;
                  case 6 :
                    switch ( ++count ) {
                      case 1 :
                        yy = (int)( atol( argv[i] ) / 10000L ) + 1900;
                        mm = (int)( atol( argv[i] ) / 100L % 100L );
                        dd = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                      case 4 :
                        HH = (int)( atol( argv[i] ) / 10000L );
                        MM = (int)( atol( argv[i] ) / 100L % 100L );
                        SS = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                    }
                    break;
                  case 8 :
                    switch ( ++count ) {
                      case 1 :
                        yy = (int)( atol( argv[i] ) / 10000L );
                        mm = (int)( atol( argv[i] ) / 100L % 100L );
                        dd = (int)( atol( argv[i] ) % 100L );
                        count += 2;
                        break;
                    }
                    break;
                }
            }
        }
    }
    if ( ( yy == 00 ) && ( mm == 00 ) && ( dd == 00 ) ) {
        long t;
        struct tm *tm;
        int _mm = 0;
        time( &t );
        tm = localtime( &t );
        yy = tm->tm_year + 1900;
        mm = tm->tm_mon + 1;
        dd = tm->tm_mday;
        HH = tm->tm_hour;
        MM = tm->tm_min;
        SS = tm->tm_sec;
        if ( htmlMode )
            printTime = 1;
    }
    koyomi( yy, mm, dd, HH, MM, SS,
            htmlMode, withHeader, printTime, printTrain, printTsupo );
    return ( 0 );
}

variable_types:
argv
char *[]

variable_types:
p
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: t long

variable_types: i int

variable_types:
q
char *

variable_types: len int

variable_types: count int

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


beatFromAbsolute

repo: tsupo/tamo

original_code:
char *
beatFromAbsolute( int HH, int MM, int SS )
{
    static char dateString[16];
    long gmt = ((HH * 60 + MM) * 60 + SS) - 9 * 60 * 60;
    long bmt = (gmt < 0 ? gmt + 24 * 60 * 60 : gmt) + 1 * 60 * 60;
    long beat = bmt * 1000 / (24 * 60 * 60);
    sprintf( dateString, "@%03d", beat % 1000 );
    return ( dateString );
}

canonical_original_code:
char *beatFromAbsolute(int HH, int MM, int SS)
{
    static char dateString[16];
    long gmt = ((HH * 60 + MM) * 60 + SS) - 9 * 60 * 60;
    long bmt = (gmt < 0 ? gmt + 24 * 60 * 60 : gmt) + 1 * 60 * 60;
    long beat = bmt * 1000 / (24 * 60 * 60);
    sprintf( dateString, "@%03d", beat % 1000 );
    return ( dateString );
}

variable_types: HH int

variable_types: MM int

variable_types: SS int

variable_types:
dateString
char [16]

variable_types: gmt long

variable_types: bmt long

variable_types: beat long

return_type: char *


original_code:
char *
ten2twenty( long i )
{
 static char buf[8192];
 char tmp[4];
 long num[20];
 int j = 0;
 while ( i >= 20 ) {
  num[ j++ ] = i % 20;
  i /= 20;
 }
 num[ j++ ] = i;
 buf[ 0 ] = '\0';
 while ( j-- ) {
  sprintf( tmp, "%ld.", num[ j ] );
  strcat( buf, tmp );
 }
 buf[ strlen( buf ) - 1 ] = '\0';
 return ( buf );
}

canonical_original_code:
char *ten2twenty(long i)
{
 static char buf[8192];
 char tmp[4];
 long num[20];
 int j = 0;
 while ( i >= 20 ) {
  num[ j++ ] = i % 20;
  i /= 20;
 }
 num[ j++ ] = i;
 buf[ 0 ] = '\0';
 while ( j-- ) {
  sprintf( tmp, "%ld.", num[ j ] );
  strcat( buf, tmp );
 }
 buf[ strlen( buf ) - 1 ] = '\0';
 return ( buf );
}

variable_types: i long

variable_types:
buf
char [8192]

variable_types:
tmp
char [4]

variable_types:
num
long [20]

variable_types: j int


decompiled_code:
__int64 __fastcall twenty2ten(char *a1)
{
char v1; // al
char *v2; // rbx
__int64 v3; // rdx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rbx
char nptr[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = *a1;
nptr[0] = 0;
if ( v1 )
{
v2 = a1;
v3 = 0LL;
v4 = 0LL;
do
{
while ( 1 )
{
++v2;
if ( v1 == 46 )
break;
nptr[v3] = v1;
v1 = *v2;
++v3;
if ( !*v2 )
goto LABEL_6;
}
nptr[v3] = 0;
v5 = atol(nptr);
nptr[0] = 0;
v4 = v5 + 20 * v4;
v1 = *v2;
v3 = 0LL;
}
while ( *v2 );
LABEL_6:
v6 = 20 * v4;
}
else
{
v6 = 0LL;
v3 = 0LL;
}
nptr[v3] = 0;
return v6 + atol(nptr);
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
char v1; // al
char *v2; // rbx
__int64 v3; // rdx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rbx
char nptr[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = *a1;
nptr[0] = 0;
if ( v1 )
{
v2 = a1;
v3 = 0LL;
v4 = 0LL;
do
{
while ( 1 )
{
++v2;
if ( v1 == 46 )
break;
nptr[v3] = v1;
v1 = *v2;
++v3;
if ( !*v2 )
goto LABEL_6;
}
nptr[v3] = 0;
v5 = atol(nptr);
nptr[0] = 0;
v4 = v5 + 20 * v4;
v1 = *v2;
v3 = 0LL;
}
while ( *v2 );
LABEL_6:
v6 = 20 * v4;
}
else
{
v6 = 0LL;
v3 = 0LL;
}
nptr[v3] = 0;
return v6 + atol(nptr);
}

variable_types:
s
char *

variable_types: j long

return_type: long


original_code:
char *
ten2twentyForCal( long i )
{
 static char buf[8192];
 char tmp[5];
 long num[20];
 long mod[2];
 int j = 0;
 mod[0] = 20; mod[1] = 18;
 while ( ( j < 2 ) && ( i >= mod[j] ) ) {
  num[j] = i % mod[j];
  i /= mod[j]; j++;
 }
 while ( i >= 20 ) {
  num[ j++ ] = i % 20;
  i /= 20;
 }
 num[ j++ ] = i;
 while ( j < 5 )
  num[ j++ ] = 0;
 buf[ 0 ] = '\0';
 while ( j-- ) {
  sprintf( tmp, "%ld.", num[ j ] );
  strcat( buf, tmp );
 }
 buf[ strlen( buf ) - 1 ] = '\0';
 return ( buf );
}

canonical_original_code:
char *ten2twentyForCal(long i)
{
 static char buf[8192];
 char tmp[5];
 long num[20];
 long mod[2];
 int j = 0;
 mod[0] = 20; mod[1] = 18;
 while ( ( j < 2 ) && ( i >= mod[j] ) ) {
  num[j] = i % mod[j];
  i /= mod[j]; j++;
 }
 while ( i >= 20 ) {
  num[ j++ ] = i % 20;
  i /= 20;
 }
 num[ j++ ] = i;
 while ( j < 5 )
  num[ j++ ] = 0;
 buf[ 0 ] = '\0';
 while ( j-- ) {
  sprintf( tmp, "%ld.", num[ j ] );
  strcat( buf, tmp );
 }
 buf[ strlen( buf ) - 1 ] = '\0';
 return ( buf );
}

variable_types:
tmp
char [5]

variable_types:
mod
long [2]


canonical_original_code:
long twenty2tenForCal(char *s)
{
 long l = 0;
 int i = 0; int j = 0;
 long num[20]; long mod[2];
 char tmp[4];
 mod[0] = 18; mod[1] = 20;
 tmp[0] = '\0';
 while ( *s ) {
  if ( *s == '.' ) {
   tmp[j] = '\0';
   num[i++] = atol( tmp );
   j = 0; tmp[0] = 0; s++;
   continue;
  }
  tmp[j++] = *s++;
 }
 tmp[j] = '\0';
 num[i++] = atol( tmp );
 j = 0;
 while ( j < i - 2 ) {
  l = l * 20 + num[j++];
 }
 while ( j < i ) {
  l = l * mod[2-(i-j)] + num[j++];
 }
 return ( l );
}

variable_types: l long

variable_types: i int


mayaFromAbsolute

decompiled_code:
char *__fastcall mayaFromAbsolute(__int64 a1)
{
return ten2twentyForCal(a1 + 1137142);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1)
{
return func2(a1 + 1137142);
}

original_code:
char *
mayaFromAbsolute( long date )
{
 return ( ten2twentyForCal( date + 1137142L ) );
}

canonical_original_code:
char *mayaFromAbsolute(long date)
{
 return ( ten2twentyForCal( date + 1137142L ) );
}

variable_types: date long


absoluteFromMaya

decompiled_code:
__int64 __fastcall absoluteFromMaya(char *a1)
{
return twenty2tenForCal(a1) - 1137142;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1)
{
return func3(a1) - 1137142;
}

original_code:
long
absoluteFromMaya( const char *s )
{
 return ( twenty2tenForCal( s ) - 1137142L );
}

canonical_original_code:
long absoluteFromMaya(char *s)
{
 return ( twenty2tenForCal( s ) - 1137142L );
}


tsolkinFromAbsolute

decompiled_code:
char *__fastcall tsolkinFromAbsolute(__int64 a1)
{
for ( ; a1 <= 3; a1 += 260LL )
;
sprintf(buf_2, "%2ld%s", (a1 - 4) % 0xDuLL + 1, (const char *)*(&tsolkin + (a1 + 1) % 0x14uLL));
return buf_2;
}

canonical_decompiled_code:
char *__fastcall func6(__int64 a1)
{
for ( ; a1 <= 3; a1 += 260LL )
;
sprintf(buf_2, "%2ld%s", (a1 - 4) % 0xDuLL + 1, (const char *)*(&tsolkin + (a1 + 1) % 0x14uLL));
return buf_2;
}

original_code:
char *
tsolkinFromAbsolute( long date )
{
    static char buf[16];
    while ( date - 4 < 0 )
        date += 13 * 20;
    sprintf( buf, "%2ld%s", (date-4) % 13 + 1, tsolkin[(date+1) % 20] );
    return ( buf );
}

canonical_original_code:
char *tsolkinFromAbsolute(long date)
{
    static char buf[16];
    while ( date - 4 < 0 )
        date += 13 * 20;
    sprintf( buf, "%2ld%s", (date-4) % 13 + 1, tsolkin[(date+1) % 20] );
    return ( buf );
}

variable_types:
buf
char [16]


haabuFromAbsolute

decompiled_code:
char *__fastcall haabuFromAbsolute(__int64 a1)
{
for ( ; a1 < -150; a1 += 7300LL )
;
sprintf(buf_1, "%2ld%s", (a1 + 150) % 365 % 0x14uLL, (const char *)*(&haabu + (a1 + 150) % 365 / 0x14uLL));
return buf_1;
}

original_code:
char *
haabuFromAbsolute( long date )
{
    static char buf[16];
    while ( date + 150 < 0 )
        date += 20 * 365;
    date = ( date + 150 ) % 365;
    sprintf( buf, "%2ld%s", date % 20, haabu[ date / 20 ] );
    return ( buf );
}

canonical_original_code:
char *haabuFromAbsolute(long date)
{
    static char buf[16];
    while ( date + 150 < 0 )
        date += 20 * 365;
    date = ( date + 150 ) % 365;
    sprintf( buf, "%2ld%s", date % 20, haabu[ date / 20 ] );
    return ( buf );
}


copDaysOfYear

decompiled_code:
__int64 __fastcall copDaysOfYear(int a1)
{
int v1; // edi
__int64 result; // rax
int v3; // edi

v1 = a1 + 9;
result = 365LL;
if ( (v1 & 3) == 0 )
{
result = 366LL;
v3 = -1030792151 * v1 + 85899344;
if ( __ROR4__(v3, 2) <= 0x28F5C28u )
result = (unsigned int)(__ROR4__(v3, 4) < 0xA3D70Bu) + 365;
}
return result;
}

variable_types: cY int

variable_types: y int

return_type: int


jdate

canonical_original_code:
static long jdate(long yy, long mm, long dd)
{
    long c; long m; long y;
    y = yy;
    m = mm;
    if (m > 2)
        m = m - 3;
    else {
        m = m + 9;
        y--;
    }
    c = y / 100L;
    y -= 100L * c;
    return dd + (c * 146097L) / 4 + (y * 1461L) / 4 +
               (m * 153L + 2) / 5 + 1721119L;
}

variable_types: yy long

variable_types: mm long

variable_types: dd long

variable_types: c long

variable_types: m long

variable_types: y long


jtime

original_code:
static double
jtime( long yy, long mm, long dd, long HH, long MM, long SS )
{
    return (jdate(yy, mm, dd) - 0.5) +
               (SS + 60 * (MM + 60 * HH)) / 86400.0;
}

canonical_original_code:
static double jtime(long yy, long mm, long dd, long HH, long MM, long SS)
{
    return (jdate(yy, mm, dd) - 0.5) +
               (SS + 60 * (MM + 60 * HH)) / 86400.0;
}

variable_types: HH long

variable_types: MM long

variable_types: SS long

return_type: double


truephase

variable_types: k double

variable_types: phase double

variable_types: t double

variable_types: pt double

variable_types: m double

variable_types: mprime double

variable_types: f double

variable_types: apcor int


phasehunt

decompiled_code:
double __fastcall phasehunt(double a1)
{
double v1; // xmm1_8
double v2; // xmm0_8
double v4; // [rsp+8h] [rbp-40h]
int v6; // [rsp+2Ch] [rbp-1Ch] BYREF
double v7; // [rsp+30h] [rbp-18h] BYREF
double v8[2]; // [rsp+38h] [rbp-10h] BYREF

v6 = 0;
meanphase_constprop_0(&v7, &v6, a1 - 45.0);
v1 = a1 - 45.0;
v4 = a1 - 45.0;
while ( 1 )
{
v2 = v1 + 29.53058868;
meanphase_constprop_0(v8, &v6, v1 + 29.53058868);
v1 = v1 + 29.53058868;
if ( a1 >= v4 && v2 > a1 )
break;
v4 = v2;
v7 = v8[0];
}
return truephase(v7);
}

original_code:
static void
phasehunt( double sdate, double phases[5] )
{
    double adate, k1, k2, nt1, nt2;
    int cnt = 0;
    adate = sdate - 45.0;
    nt1 = meanphase(adate, 0.0, &k1, &cnt);
    while (1) {
        adate += 29.53058868;
        nt2 = meanphase(adate, 0.0, &k2, &cnt);
        if ((nt1 <= sdate) && (nt2 > sdate))
            break;
        nt1 = nt2;
        k1 = k2;
    }
    if (k2 - k1 >= 2.0)
        k2 = k1 + 1.0;
    phases[0] = truephase(k1, 0.0);
    phases[1] = truephase(k1, 0.25);
    phases[2] = truephase(k1, 0.5);
    phases[3] = truephase(k1, 0.75);
    phases[4] = truephase(k2, 0.0);
}

canonical_original_code:
static void phasehunt(double sdate, double phases[5])
{
    double adate; double k1; double k2; double nt1; double nt2;
    int cnt = 0;
    adate = sdate - 45.0;
    nt1 = meanphase(adate, 0.0, &k1, &cnt);
    while (1) {
        adate += 29.53058868;
        nt2 = meanphase(adate, 0.0, &k2, &cnt);
        if ((nt1 <= sdate) && (nt2 > sdate))
            break;
        nt1 = nt2;
        k1 = k2;
    }
    if (k2 - k1 >= 2.0)
        k2 = k1 + 1.0;
    phases[0] = truephase(k1, 0.0);
    phases[1] = truephase(k1, 0.25);
    phases[2] = truephase(k1, 0.5);
    phases[3] = truephase(k1, 0.75);
    phases[4] = truephase(k2, 0.0);
}

variable_types: sdate double

variable_types:
phases
double [5]

variable_types: adate double

variable_types: cnt int

return_type: void


original_code:
double
qpom3( double now, double epoch_near )
{
    double diff, howfar;
    diff = (double) now - epoch_near;
    howfar = diff / ((double)2551442.9);
    return ((double)2551442.9) * (howfar - (long) howfar) / 86400.0;
}

canonical_original_code:
double qpom3(double now, double epoch_near)
{
    double diff; double howfar;
    diff = (double) now - epoch_near;
    howfar = diff / ((double)2551442.9);
    return ((double)2551442.9) * (howfar - (long) howfar) / 86400.0;
}

variable_types: now double

variable_types: diff double

variable_types: howfar double


decompiled_code:
double year_sum()
{
return ((double)(int)(absoluteFromGregorian() - 720988) - 0.375) / 365.25;
}

canonical_decompiled_code:
double func0()
{
return ((double)(int)(absoluteFromGregorian() - 720988) - 0.375) / 365.25;
}

original_code:
static double
year_sum( int d, int m, int y )
{
    int tmp;
    tmp = absoluteFromGregorian(d,m,y)-720988L;
    return (((double)tmp + (-9.0 / 24.0)) / 365.25);
}

canonical_original_code:
static double year_sum(int d, int m, int y)
{
    int tmp;
    tmp = absoluteFromGregorian(d,m,y)-720988L;
    return (((double)tmp + (-9.0 / 24.0)) / 365.25);
}

variable_types: d int

variable_types: m int

variable_types: y int

variable_types: tmp int


original_code:
static double
moon_cel( double yrs )
{
    register int i;
    double moon_cel_val;
    moon_cel_val = mn[0].ph + mn[0].sc * yrs;
    for (i = 1; i <= 13; i++) {
        moon_cel_val +=
                    mn[i].ef * sin((3.14159265358979323846 * 2.0 / 360.0) * (mn[i].ph + mn[i].sc * yrs));
    }
    return ( fmod( moon_cel_val, 360.0 ) );
}

canonical_original_code:
static double moon_cel(double yrs)
{
    register int i;
    double moon_cel_val;
    moon_cel_val = mn[0].ph + mn[0].sc * yrs;
    for (i = 1; i <= 13; i++) {
        moon_cel_val +=
                    mn[i].ef * sin((3.14159265358979323846 * 2.0 / 360.0) * (mn[i].ph + mn[i].sc * yrs));
    }
    return ( fmod( moon_cel_val, 360.0 ) );
}

variable_types: yrs double

variable_types: i int


original_code:
static int
calc_new_moon( double yrs, double *mn_kk, double *sn_kk )
{
    int new_moon_flag;
    double sn_kk1, mn_kk1;
    double sn_kk2, mn_kk2;
    mn_kk1 = moon_cel(yrs);
    sn_kk1 = sun_cel(yrs);
    mn_kk2 = moon_cel(yrs + (1.0 / 365.25));
    sn_kk2 = sun_cel(yrs + (1.0 / 365.25));
    if (mn_kk2 < mn_kk1)
        mn_kk2 += 360.0;
    if (sn_kk2 < sn_kk1)
        sn_kk2 += 360.0;
    new_moon_flag = 0;
    if ((mn_kk1 < sn_kk1) && (mn_kk2 > sn_kk2))
        new_moon_flag = 1;
    if ((mn_kk1 < (sn_kk1 + 360.0)) && ((sn_kk2 + 360.0) < mn_kk2)) {
        new_moon_flag = 1;
        sn_kk1 += 360.0;
    }
    *mn_kk = mn_kk1;
    *sn_kk = sn_kk1;
    return (new_moon_flag);
}

canonical_original_code:
static int calc_new_moon(double yrs, double *mn_kk, double *sn_kk)
{
    int new_moon_flag;
    double sn_kk1; double mn_kk1;
    double sn_kk2; double mn_kk2;
    mn_kk1 = moon_cel(yrs);
    sn_kk1 = sun_cel(yrs);
    mn_kk2 = moon_cel(yrs + (1.0 / 365.25));
    sn_kk2 = sun_cel(yrs + (1.0 / 365.25));
    if (mn_kk2 < mn_kk1)
        mn_kk2 += 360.0;
    if (sn_kk2 < sn_kk1)
        sn_kk2 += 360.0;
    new_moon_flag = 0;
    if ((mn_kk1 < sn_kk1) && (mn_kk2 > sn_kk2))
        new_moon_flag = 1;
    if ((mn_kk1 < (sn_kk1 + 360.0)) && ((sn_kk2 + 360.0) < mn_kk2)) {
        new_moon_flag = 1;
        sn_kk1 += 360.0;
    }
    *mn_kk = mn_kk1;
    *sn_kk = sn_kk1;
    return (new_moon_flag);
}


decompiled_code:
__int64 __fastcall back_new_moon(int *a1, double a2)
{
int v2; // eax
_BOOL4 v3; // er8
double v5; // [rsp+0h] [rbp-28h] BYREF
double v6[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = *a1 + 28;
*a1 = v2;
do
{
v3 = calc_new_moon(v6, (unsigned __int64 *)&v5, a2 - (double)v2 * 0.002737850787132101);
v2 = *a1 + 1;
*a1 = v2;
}
while ( !v3 );
return (unsigned int)((int)v5 / 30);
}

canonical_decompiled_code:
__int64 __fastcall func4(int *a1, double a2)
{
int v2; // eax
_BOOL4 v3; // er8
double v5; // [rsp+0h] [rbp-28h] BYREF
double v6[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = *a1 + 28;
*a1 = v2;
do
{
v3 = func3(v6, (unsigned __int64 *)&v5, a2 - (double)v2 * 0.002737850787132101);
v2 = *a1 + 1;
*a1 = v2;
}
while ( !v3 );
return (unsigned int)((int)v5 / 30);
}

original_code:
static int
back_new_moon( double yrs, int *day_before )
{
    int new_moon_flag;
    double sn_kk, tmp;
    (*day_before) += 28;
    do {
        new_moon_flag =
                calc_new_moon(yrs - (1.0 / 365.25) * (*day_before),&tmp,&sn_kk);
        (*day_before)++;
    } while (new_moon_flag == 0);
    return ((int)sn_kk / 30);
}

canonical_original_code:
static int back_new_moon(double yrs, int *day_before)
{
    int new_moon_flag;
    double sn_kk; double tmp;
    (*day_before) += 28;
    do {
        new_moon_flag =
                calc_new_moon(yrs - (1.0 / 365.25) * (*day_before),&tmp,&sn_kk);
        (*day_before)++;
    } while (new_moon_flag == 0);
    return ((int)sn_kk / 30);
}

variable_types: tmp double


decompiled_code:
__int64 __fastcall next_new_moon(int *a1, double a2)
{
int v2; // eax
_BOOL4 v3; // er8
double v5; // [rsp+10h] [rbp-18h] BYREF
double v6[2]; // [rsp+18h] [rbp-10h] BYREF

v2 = *a1 + 28;
*a1 = v2;
do
{
v3 = calc_new_moon(v6, (unsigned __int64 *)&v5, (double)v2 * 0.002737850787132101 + a2);
v2 = *a1 + 1;
*a1 = v2;
}
while ( !v3 );
return (unsigned int)((int)v5 / 30);
}

original_code:
static int
next_new_moon( double yrs, int *day_after )
{
    int new_moon_flag;
    double sn_kk, tmp;
    (*day_after) += 28;
    do {
        new_moon_flag =
                calc_new_moon(yrs + (1.0 / 365.25) * (*day_after),&tmp,&sn_kk);
        (*day_after)++;
    } while (new_moon_flag == 0);
    return ((int)sn_kk / 30);
}

canonical_original_code:
static int next_new_moon(double yrs, int *day_after)
{
    int new_moon_flag;
    double sn_kk; double tmp;
    (*day_after) += 28;
    do {
        new_moon_flag =
                calc_new_moon(yrs + (1.0 / 365.25) * (*day_after),&tmp,&sn_kk);
        (*day_after)++;
    } while (new_moon_flag == 0);
    return ((int)sn_kk / 30);
}


julcen

decompiled_code:
double __fastcall julcen(int a1)
{
return ((double)a1 - 15019.5) / 36525.0;
}

canonical_decompiled_code:
double __fastcall func6(int a1)
{
return ((double)a1 - 15019.5) / 36525.0;
}

original_code:
double
julcen( long ld )
{
    return((ld - 15019.5) / 36525);
}

canonical_original_code:
double julcen(long ld)
{
    return((ld - 15019.5) / 36525);
}

variable_types: ld long


geturei

variable_types: l long

variable_types: a double

variable_types: b double

variable_types: rikaku double


getSekkiDate

original_code:
long
getSekkiDate( int day, int month, int year )
{
    long d = absoluteFromGregorian( day, month, year ) - 1;
    double sun_cel1, sun_cel2, yrs;
    double sekki, sekki1, sekki2, tmp;
    tmp = d - 720987.0;
    do {
        yrs = (tmp + (-9.0 / 24.0)) / 365.25;
        tmp += 1.0;
        d++;
        sun_cel1 = sun_cel(yrs);
        sun_cel2 = sun_cel(yrs + (1.0 / 365.25));
        if (sun_cel2 < sun_cel1)
            sun_cel2 += 360.0;
        sekki = -1.0;
        sekki1 = sun_cel1 / 15.0;
        sekki2 = sun_cel2 / 15.0;
        if (sekki1 < sekki2)
            sekki = sekki2;
        if (sekki >= 24.0)
            sekki -= 24.0;
    } while ( sekki - floor(sekki) > 0.1 );
    return ( d );
}

canonical_original_code:
long getSekkiDate(int day, int month, int year)
{
    long d = absoluteFromGregorian( day, month, year ) - 1;
    double sun_cel1; double sun_cel2; double yrs;
    double sekki; double sekki1; double sekki2; double tmp;
    tmp = d - 720987.0;
    do {
        yrs = (tmp + (-9.0 / 24.0)) / 365.25;
        tmp += 1.0;
        d++;
        sun_cel1 = sun_cel(yrs);
        sun_cel2 = sun_cel(yrs + (1.0 / 365.25));
        if (sun_cel2 < sun_cel1)
            sun_cel2 += 360.0;
        sekki = -1.0;
        sekki1 = sun_cel1 / 15.0;
        sekki2 = sun_cel2 / 15.0;
        if (sekki1 < sekki2)
            sekki = sekki2;
        if (sekki >= 24.0)
            sekki -= 24.0;
    } while ( sekki - floor(sekki) > 0.1 );
    return ( d );
}

variable_types: day int

variable_types: month int

variable_types: year int

variable_types: d long

variable_types: sekki double


springStartDay

decompiled_code:
__int64 __fastcall springStartDay(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return getSekkiDate(2LL, 2LL, a1, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return func9(2LL, 2LL, a1, a4, a5);
}

original_code:
long
springStartDay( int y )
{
    return ( getSekkiDate( 2, 2, y ) );
}

canonical_original_code:
long springStartDay(int y)
{
    return ( getSekkiDate( 2, 2, y ) );
}


midSpringDay

decompiled_code:
__int64 __fastcall midSpringDay(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return getSekkiDate(19LL, 3LL, a1, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return func9(19LL, 3LL, a1, a4, a5);
}

original_code:
long
midSpringDay( int y )
{
    return ( getSekkiDate( 19, 3, y ) );
}

canonical_original_code:
long midSpringDay(int y)
{
    return ( getSekkiDate( 19, 3, y ) );
}


midSummerDay

decompiled_code:
__int64 __fastcall midSummerDay(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return getSekkiDate(20LL, 6LL, a1, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return func9(20LL, 6LL, a1, a4, a5);
}

original_code:
long
midSummerDay( int y )
{
    return ( getSekkiDate( 19, 6, y ) );
}

canonical_original_code:
long midSummerDay(int y)
{
    return ( getSekkiDate( 19, 6, y ) );
}


autumnStartDay

decompiled_code:
__int64 __fastcall autumnStartDay(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return getSekkiDate(6LL, 8LL, a1, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return func9(6LL, 8LL, a1, a4, a5);
}

original_code:
long
autumnStartDay( int y )
{
    return ( getSekkiDate( 5, 8, y ) );
}

canonical_original_code:
long autumnStartDay(int y)
{
    return ( getSekkiDate( 5, 8, y ) );
}


midAutumnDay

decompiled_code:
__int64 __fastcall midAutumnDay(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return getSekkiDate(22LL, 9LL, a1, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
return func9(22LL, 9LL, a1, a4, a5);
}

original_code:
long
midAutumnDay( int y )
{
    return ( getSekkiDate( 21, 9, y ) );
}

canonical_original_code:
long midAutumnDay(int y)
{
    return ( getSekkiDate( 21, 9, y ) );
}


setsuStartDay

decompiled_code:
__int64 __fastcall setsuStartDay(unsigned int a1, unsigned int a2)
{
return getSekkiDate((unsigned int)day_0[(int)(a1 - 1) % 12], a1, a2, (unsigned int)((int)(a1 - 1) >> 31), a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int a1, unsigned int a2)
{
return func9((unsigned int)day_0[(int)(a1 - 1) % 12], a1, a2, (unsigned int)((int)(a1 - 1) >> 31), a1);
}

original_code:
long
setsuStartDay( int mm, int yy )
{
    static int day[] = {
        2,
        5,
        4,
        5,
        5,
        6,
        6,
        7,
        8,
        7,
        6,
        5
    };
    return ( getSekkiDate( day[(mm-1)%12], mm, yy ) );
}

canonical_original_code:
long setsuStartDay(int mm, int yy)
{
    static int day[] = {
        2,
        5,
        4,
        5,
        5,
        6,
        6,
        7,
        8,
        7,
        6,
        5
    };
    return ( getSekkiDate( day[(mm-1)%12], mm, yy ) );
}

variable_types: mm int

variable_types: yy int

variable_types:
day
int []


getLunarCalendar

original_code:
void
getLunarCalendar( int *day, int *month, int *year, int *uruu )
{
    int day_before;
    int day_after;
    int year_up;
    int lc_month0;
    int sk_month0;
    int moon_before;
    int moon_after;
    int new_moon_flag;
    int new_moon_before;
    int new_moon_after;
    double yrs;
    double cel_mn, cel_sn;
    int yyyy = *year, mm = *month, dd = *day;
    yrs = year_sum( *day, *month, *year );
    day_before = 1;
    year_up = 0;
    new_moon_flag = calc_new_moon(yrs, &cel_mn, &cel_sn);
    new_moon_before = (int)cel_sn / 30;
    if (cel_mn < cel_sn)
        cel_mn += 360.0;
    if (new_moon_flag == 0) {
        day_before = (int)(cel_mn - cel_sn) / 13 - 28;
        new_moon_before = back_new_moon(yrs, &day_before);
    }
    *day = day_before;
    lc_month0 = new_moon_before + 2;
    day_after = -day_before;
    new_moon_after = next_new_moon(yrs, &day_after);
    if (new_moon_after < new_moon_before) {
        new_moon_after += 12;
    }
    sk_month0 = (int)new_moon_after / 3 * 3;
    *month = new_moon_after + 2;
    *uruu = 0;
    if (lc_month0 == *month)
        *uruu = 1;
    *year = 1975 + (int)yrs - 1;
    if ((sun_cel_val(yrs) - (double)((long)(yrs) * 360L)) > 360.0)
        year_up = 1;
    moon_before = 0;
    if (new_moon_before > (sk_month0 + 2)) {
        moon_before = new_moon_before - sk_month0 - 2;
        day_before += 29 * moon_before;
    }
    while (new_moon_before >= sk_month0) {
        moon_before++;
        new_moon_before = back_new_moon(yrs, &day_before);
        if (new_moon_before > new_moon_after)
            new_moon_before -= 12;
    }
    moon_after = 3 - moon_before - 1;
    if (moon_after < 0)
        moon_after = 0;
    day_after += 29 * moon_after;
    while (new_moon_after < (sk_month0 + 3)) {
        moon_after++;
        new_moon_after = next_new_moon(yrs, &day_after);
        if (new_moon_after < new_moon_before)
            new_moon_after += 12;
    }
    if ((moon_before + moon_after) == 3) {
        *month = sk_month0 + 2 + moon_before;
        *uruu = 0;
    }
    if (*month > 12) {
        (*month) -= 12;
        year_up = 2;
    }
    if (year_up > 0)
        (*year)++;
    if (((yyyy == 2033) && ((mm > 8) ||
                            ((mm == 8) && (dd >= 25)) )) ||
        ((yyyy == 2034) && ((mm < 3) ||
                            ((mm == 3) && (dd < 20)) )) ) {
        if (*uruu == 1)
        {
            if (*month == 7) {
                (*month)++;
                *uruu = 0;
            }
            else if (*month == 1) {
                *uruu = 0;
            }
        }
        else if ((*month == 8) || (*month == 9)) {
            (*month)++;
        }
        else if (*month == 1) {
            (*year)--;
            (*month)--;
        }
    }
}

canonical_original_code:
void getLunarCalendar(int *day, int *month, int *year, int *uruu)
{
    int day_before;
    int day_after;
    int year_up;
    int lc_month0;
    int sk_month0;
    int moon_before;
    int moon_after;
    int new_moon_flag;
    int new_moon_before;
    int new_moon_after;
    double yrs;
    double cel_mn; double cel_sn;
    int yyyy = *year; int mm = *month; int dd = *day;
    yrs = year_sum( *day, *month, *year );
    day_before = 1;
    year_up = 0;
    new_moon_flag = calc_new_moon(yrs, &cel_mn, &cel_sn);
    new_moon_before = (int)cel_sn / 30;
    if (cel_mn < cel_sn)
        cel_mn += 360.0;
    if (new_moon_flag == 0) {
        day_before = (int)(cel_mn - cel_sn) / 13 - 28;
        new_moon_before = back_new_moon(yrs, &day_before);
    }
    *day = day_before;
    lc_month0 = new_moon_before + 2;
    day_after = -day_before;
    new_moon_after = next_new_moon(yrs, &day_after);
    if (new_moon_after < new_moon_before) {
        new_moon_after += 12;
    }
    sk_month0 = (int)new_moon_after / 3 * 3;
    *month = new_moon_after + 2;
    *uruu = 0;
    if (lc_month0 == *month)
        *uruu = 1;
    *year = 1975 + (int)yrs - 1;
    if ((sun_cel_val(yrs) - (double)((long)(yrs) * 360L)) > 360.0)
        year_up = 1;
    moon_before = 0;
    if (new_moon_before > (sk_month0 + 2)) {
        moon_before = new_moon_before - sk_month0 - 2;
        day_before += 29 * moon_before;
    }
    while (new_moon_before >= sk_month0) {
        moon_before++;
        new_moon_before = back_new_moon(yrs, &day_before);
        if (new_moon_before > new_moon_after)
            new_moon_before -= 12;
    }
    moon_after = 3 - moon_before - 1;
    if (moon_after < 0)
        moon_after = 0;
    day_after += 29 * moon_after;
    while (new_moon_after < (sk_month0 + 3)) {
        moon_after++;
        new_moon_after = next_new_moon(yrs, &day_after);
        if (new_moon_after < new_moon_before)
            new_moon_after += 12;
    }
    if ((moon_before + moon_after) == 3) {
        *month = sk_month0 + 2 + moon_before;
        *uruu = 0;
    }
    if (*month > 12) {
        (*month) -= 12;
        year_up = 2;
    }
    if (year_up > 0)
        (*year)++;
    if (((yyyy == 2033) && ((mm > 8) ||
                            ((mm == 8) && (dd >= 25)) )) ||
        ((yyyy == 2034) && ((mm < 3) ||
                            ((mm == 3) && (dd < 20)) )) ) {
        if (*uruu == 1)
        {
            if (*month == 7) {
                (*month)++;
                *uruu = 0;
            }
            else if (*month == 1) {
                *uruu = 0;
            }
        }
        else if ((*month == 8) || (*month == 9)) {
            (*month)++;
        }
        else if (*month == 1) {
            (*year)--;
            (*month)--;
        }
    }
}

variable_types:
day
int *

variable_types:
month
int *

variable_types:
year
int *

variable_types:
uruu
int *

variable_types: yyyy int

variable_types: dd int


checkKyureki

decompiled_code:
int __fastcall checkKyureki(unsigned int a1, int a2, __int64 a3, __int64 a4, const char *a5)
{
__int64 v6; // rax
int result; // eax

printf(" %s", (const char *)*(&rk + (int)(a1 + a2 - 2) % 6));
if ( a5 )
printf(" %s", a5);
if ( a1 == 10 || a1 == 25 )
printf(asc_D84);
if ( a1 == 11 || a1 == 26 )
printf(asc_D8B);
if ( a1 > 0x1C )
goto LABEL_12;
v6 = 406597752LL;
if ( _bittest64(&v6, a1) )
printf(asc_D92);
if ( a1 - 14 <= 3 || a1 - 3 > 0x19 )
LABEL_12:
printf(asc_D99);
if ( a1 - 7 <= 2 || (result = a1 - 22, a1 - 22 <= 2) )
result = printf(asc_DA0);
if ( a2 == 1 && a1 == 1 )
{
result = printf(asc_DA7);
LABEL_23:
if ( (((_BYTE)a1 + 5) & 7) == 0 )
return printf(asc_DC7);
}
else if ( a2 == 8 && a1 == 15 )
{
result = printf(asc_DB0);
LABEL_20:
if ( (((_BYTE)a1 + 6) & 7) == 0 )
return printf(asc_DC7);
}
else if ( a2 == 9 && a1 == 13 )
{
result = printf(asc_DB8);
}
else if ( a2 == 12 && a1 == 8 )
{
result = printf(asc_DC0);
}
else
{
switch ( a2 )
{
case 1:
case 7:
goto LABEL_23;
case 2:
case 8:
goto LABEL_20;
case 3:
case 9:
if ( (((_BYTE)a1 + 7) & 7) == 0 )
return printf(asc_DC7);
break;
case 4:
case 10:
if ( (((_BYTE)a1 + 4) & 7) == 0 )
return printf(asc_DC7);
break;
case 5:
case 11:
if ( (((_BYTE)a1 + 3) & 7) == 0 )
return printf(asc_DC7);
break;
case 6:
case 12:
if ( (((_BYTE)a1 + 2) & 7) == 0 )
return printf(asc_DC7);
break;
default:
return result;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func18(unsigned int a1, int a2, __int64 a3, __int64 a4, const char *a5)
{
__int64 v6; // rax
int result; // eax

printf(" %s", (const char *)*(&rk + (int)(a1 + a2 - 2) % 6));
if ( a5 )
printf(" %s", a5);
if ( a1 == 10 || a1 == 25 )
printf(asc_D84);
if ( a1 == 11 || a1 == 26 )
printf(asc_D8B);
if ( a1 > 0x1C )
goto LABEL_12;
v6 = 406597752LL;
if ( _bittest64(&v6, a1) )
printf(asc_D92);
if ( a1 - 14 <= 3 || a1 - 3 > 0x19 )
LABEL_12:
printf(asc_D99);
if ( a1 - 7 <= 2 || (result = a1 - 22, a1 - 22 <= 2) )
result = printf(asc_DA0);
if ( a2 == 1 && a1 == 1 )
{
result = printf(asc_DA7);
LABEL_23:
if ( (((_BYTE)a1 + 5) & 7) == 0 )
return printf(asc_DC7);
}
else if ( a2 == 8 && a1 == 15 )
{
result = printf(asc_DB0);
LABEL_20:
if ( (((_BYTE)a1 + 6) & 7) == 0 )
return printf(asc_DC7);
}
else if ( a2 == 9 && a1 == 13 )
{
result = printf(asc_DB8);
}
else if ( a2 == 12 && a1 == 8 )
{
result = printf(asc_DC0);
}
else
{
switch ( a2 )
{
case 1:
case 7:
goto LABEL_23;
case 2:
case 8:
goto LABEL_20;
case 3:
case 9:
if ( (((_BYTE)a1 + 7) & 7) == 0 )
return printf(asc_DC7);
break;
case 4:
case 10:
if ( (((_BYTE)a1 + 4) & 7) == 0 )
return printf(asc_DC7);
break;
case 5:
case 11:
if ( (((_BYTE)a1 + 3) & 7) == 0 )
return printf(asc_DC7);
break;
case 6:
case 12:
if ( (((_BYTE)a1 + 2) & 7) == 0 )
return printf(asc_DC7);
break;
default:
return result;
}
}
return result;
}

original_code:
void
checkKyureki( long g, int d, int m, int y, int u, int htmlMode )
{
    int reset = 1;
    int yearEto = ( y + 8 ) % 12;
    int ks = ( g + 14 ) % 60;
    char *p;
 char *d0 = "  %s";
 char *d1 = "不成就日";
 char *d2 = "歳下食";
    tprintf( htmlMode, &reset, d0, rk[(m + d - 2) % 6] );
    if ( ( d == 10 ) || ( d == 25 ) )
        tprintf( htmlMode, &reset, "  長潮" );
    if ( ( d == 11 ) || ( d == 26 ) )
        tprintf( htmlMode, &reset, "  若潮" );
    if ( ( ( d >= 3 ) && ( d <= 6 ) ) ||
         ( ( d >= 12 ) && ( d <= 13 ) ) ||
         ( ( d >= 18 ) && ( d <= 21 ) ) ||
         ( ( d >= 27 ) && ( d <= 28 ) ) )
        tprintf( htmlMode, &reset, "  中潮" );
    if ( ( d <= 2 ) ||
         ( ( d >= 14 ) && ( d <= 17 ) ) ||
           ( d >= 29 ) )
        tprintf( htmlMode, &reset, "  大潮" );
    if ( ( ( d >= 7 ) && ( d <= 9 ) ) ||
         ( ( d >= 22 ) && ( d <= 24 ) ) )
        tprintf( htmlMode, &reset, "  小潮" );
    if ( m == 1 ) {
        if ( d == 1 )
            tprintf( htmlMode, &reset, "  旧正月" );
        if ( d == 7 )
            tprintf( htmlMode, &reset, "  旧七草" );
        if ( (d >= 3) && (d <= 9) )
            tprintf( htmlMode, &reset, "  春節(中国)" );
        if ( d == 15 )
            tprintf( htmlMode, &reset, "  元宵節(中国)" );
        if ( d == 20 )
            tprintf( htmlMode, &reset, "  二十日正月" );
    }
    if ( ( m == 2 ) && ( d == 2 ) )
        tprintf( htmlMode, &reset, "  二日灸" );
    if ( ( m == 3 ) && ( d == 3 ) )
        tprintf( htmlMode, &reset, "  旧ひな祭" );
    if ( ( m == 4 ) && ( d == 8 ) )
        tprintf( htmlMode, &reset, "  旧潅仏" );
    if ( m == 5 ) {
        if ( d == 5 ) {
            tprintf( htmlMode, &reset, "  旧端午の節句" );
            tprintf( htmlMode, &reset, "  端午節(中国)" );
        }
        if ( d == 29 )
            tprintf( htmlMode, &reset, "  達努節(中国)" );
    }
    if ( m == 6 ) {
        if ( (d == 24) || (d == 25) )
            tprintf( htmlMode, &reset, "  火把節(中国)" );
    }
    if ( m == 7 ) {
        if ( d == 7 )
            tprintf( htmlMode, &reset, "  旧七夕" );
        if ( d == 15 )
            tprintf( htmlMode, &reset, "  旧盆" );
        if ( d == 24 )
            tprintf( htmlMode, &reset, "  旧地蔵盆" );
    }
    if ( m == 8 ) {
        if ( d == 1 )
            tprintf( htmlMode, &reset, "  旧八朔" );
        if ( d == 14 )
            tprintf( htmlMode, &reset, "  待宵月" );
        if ( d == 15 ) {
            tprintf( htmlMode, &reset, "  十五夜" );
            tprintf( htmlMode, &reset, "  中秋節(中国)" );
        }
        if ( d == 16 )
            tprintf( htmlMode, &reset, "  十六夜" );
        if ( d == 17 )
            tprintf( htmlMode, &reset, "  立待月" );
        if ( d == 18 )
            tprintf( htmlMode, &reset, "  居待月" );
        if ( d == 19 )
            tprintf( htmlMode, &reset, "  臥待月" );
        if ( d == 20 )
            tprintf( htmlMode, &reset, "  更待月" );
    }
    if ( m == 9 ) {
        if ( d == 9 ) {
            tprintf( htmlMode, &reset, "  御九日" );
            tprintf( htmlMode, &reset, "  重陽節(中国)" );
        }
        if ( d == 13 )
            tprintf( htmlMode, &reset, "  十三夜" );
        if ( d == 28 )
            tprintf( htmlMode, &reset, "  孔子祭(中国)" );
    }
    if ( m == 10 ) {
        if ( d <= 12 ) {
            if ( ( ( (g) + 2 ) % 12 ) == 11 )
                tprintf( htmlMode, &reset, "  炉開き" );
        }
        if ( d == 5 )
            tprintf( htmlMode, &reset, "  残菊の宴" );
        if ( d == 10 )
            tprintf( htmlMode, &reset, "  十日夜" );
        if ( ( ( (g) + 2 ) % 12 ) == 11 )
            tprintf( htmlMode, &reset, "  亥の子" );
    }
    if ( ( m == 12 ) && ( d == 8 ) )
        tprintf( htmlMode, &reset, "  臘日" );
    switch ( m ) {
    case 1 :
    case 7 :
        if ( (d + 5) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 2 :
    case 8 :
        if ( (d + 6) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 3 :
    case 9 :
        if ( (d + 7) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 4 :
    case 10 :
        if ( (d + 4) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 5 :
    case 11 :
        if ( (d + 3) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 6 :
    case 12 :
        if ( (d + 2) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    }
    switch ( yearEto ) {
    case 0:
        if ( ks == 13 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 1:
        if ( ks == 26 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 2:
        if ( ks == 3 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 3:
        if ( ks == 28 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 4:
        if ( ks == 53 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 5:
        if ( ks == 42 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 6:
        if ( ks == 43 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 7:
        if ( ks == 56 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 8:
        if ( ks == 33 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 9:
        if ( ks == 22 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 10:
        if ( ks == 47 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 11:
        if ( ks == 36 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    }
    if ( ( p = kuenichi( g, m ) ) != ((void *)0) )
        tprintf( htmlMode, &reset, d0, p );
}

canonical_original_code:
void checkKyureki(long g, int d, int m, int y, int u, int htmlMode)
{
    int reset = 1;
    int yearEto = ( y + 8 ) % 12;
    int ks = ( g + 14 ) % 60;
    char *p;
 char *d0 = "  %s";
 char *d1 = "不成就日";
 char *d2 = "歳下食";
    tprintf( htmlMode, &reset, d0, rk[(m + d - 2) % 6] );
    if ( ( d == 10 ) || ( d == 25 ) )
        tprintf( htmlMode, &reset, "  長潮" );
    if ( ( d == 11 ) || ( d == 26 ) )
        tprintf( htmlMode, &reset, "  若潮" );
    if ( ( ( d >= 3 ) && ( d <= 6 ) ) ||
         ( ( d >= 12 ) && ( d <= 13 ) ) ||
         ( ( d >= 18 ) && ( d <= 21 ) ) ||
         ( ( d >= 27 ) && ( d <= 28 ) ) )
        tprintf( htmlMode, &reset, "  中潮" );
    if ( ( d <= 2 ) ||
         ( ( d >= 14 ) && ( d <= 17 ) ) ||
           ( d >= 29 ) )
        tprintf( htmlMode, &reset, "  大潮" );
    if ( ( ( d >= 7 ) && ( d <= 9 ) ) ||
         ( ( d >= 22 ) && ( d <= 24 ) ) )
        tprintf( htmlMode, &reset, "  小潮" );
    if ( m == 1 ) {
        if ( d == 1 )
            tprintf( htmlMode, &reset, "  旧正月" );
        if ( d == 7 )
            tprintf( htmlMode, &reset, "  旧七草" );
        if ( (d >= 3) && (d <= 9) )
            tprintf( htmlMode, &reset, "  春節(中国)" );
        if ( d == 15 )
            tprintf( htmlMode, &reset, "  元宵節(中国)" );
        if ( d == 20 )
            tprintf( htmlMode, &reset, "  二十日正月" );
    }
    if ( ( m == 2 ) && ( d == 2 ) )
        tprintf( htmlMode, &reset, "  二日灸" );
    if ( ( m == 3 ) && ( d == 3 ) )
        tprintf( htmlMode, &reset, "  旧ひな祭" );
    if ( ( m == 4 ) && ( d == 8 ) )
        tprintf( htmlMode, &reset, "  旧潅仏" );
    if ( m == 5 ) {
        if ( d == 5 ) {
            tprintf( htmlMode, &reset, "  旧端午の節句" );
            tprintf( htmlMode, &reset, "  端午節(中国)" );
        }
        if ( d == 29 )
            tprintf( htmlMode, &reset, "  達努節(中国)" );
    }
    if ( m == 6 ) {
        if ( (d == 24) || (d == 25) )
            tprintf( htmlMode, &reset, "  火把節(中国)" );
    }
    if ( m == 7 ) {
        if ( d == 7 )
            tprintf( htmlMode, &reset, "  旧七夕" );
        if ( d == 15 )
            tprintf( htmlMode, &reset, "  旧盆" );
        if ( d == 24 )
            tprintf( htmlMode, &reset, "  旧地蔵盆" );
    }
    if ( m == 8 ) {
        if ( d == 1 )
            tprintf( htmlMode, &reset, "  旧八朔" );
        if ( d == 14 )
            tprintf( htmlMode, &reset, "  待宵月" );
        if ( d == 15 ) {
            tprintf( htmlMode, &reset, "  十五夜" );
            tprintf( htmlMode, &reset, "  中秋節(中国)" );
        }
        if ( d == 16 )
            tprintf( htmlMode, &reset, "  十六夜" );
        if ( d == 17 )
            tprintf( htmlMode, &reset, "  立待月" );
        if ( d == 18 )
            tprintf( htmlMode, &reset, "  居待月" );
        if ( d == 19 )
            tprintf( htmlMode, &reset, "  臥待月" );
        if ( d == 20 )
            tprintf( htmlMode, &reset, "  更待月" );
    }
    if ( m == 9 ) {
        if ( d == 9 ) {
            tprintf( htmlMode, &reset, "  御九日" );
            tprintf( htmlMode, &reset, "  重陽節(中国)" );
        }
        if ( d == 13 )
            tprintf( htmlMode, &reset, "  十三夜" );
        if ( d == 28 )
            tprintf( htmlMode, &reset, "  孔子祭(中国)" );
    }
    if ( m == 10 ) {
        if ( d <= 12 ) {
            if ( ( ( (g) + 2 ) % 12 ) == 11 )
                tprintf( htmlMode, &reset, "  炉開き" );
        }
        if ( d == 5 )
            tprintf( htmlMode, &reset, "  残菊の宴" );
        if ( d == 10 )
            tprintf( htmlMode, &reset, "  十日夜" );
        if ( ( ( (g) + 2 ) % 12 ) == 11 )
            tprintf( htmlMode, &reset, "  亥の子" );
    }
    if ( ( m == 12 ) && ( d == 8 ) )
        tprintf( htmlMode, &reset, "  臘日" );
    switch ( m ) {
    case 1 :
    case 7 :
        if ( (d + 5) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 2 :
    case 8 :
        if ( (d + 6) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 3 :
    case 9 :
        if ( (d + 7) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 4 :
    case 10 :
        if ( (d + 4) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 5 :
    case 11 :
        if ( (d + 3) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    case 6 :
    case 12 :
        if ( (d + 2) % 8 == 0 )
            tprintf( htmlMode, &reset, d0, d1 );
        break;
    }
    switch ( yearEto ) {
    case 0:
        if ( ks == 13 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 1:
        if ( ks == 26 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 2:
        if ( ks == 3 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 3:
        if ( ks == 28 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 4:
        if ( ks == 53 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 5:
        if ( ks == 42 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 6:
        if ( ks == 43 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 7:
        if ( ks == 56 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 8:
        if ( ks == 33 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 9:
        if ( ks == 22 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 10:
        if ( ks == 47 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    case 11:
        if ( ks == 36 )
            tprintf( htmlMode, &reset, d0, d2 );
        break;
    }
    if ( ( p = kuenichi( g, m ) ) != ((void *)0) )
        tprintf( htmlMode, &reset, d0, p );
}

variable_types: g long

variable_types: d int

variable_types: m int

variable_types: y int

variable_types: u int

variable_types: htmlMode int

variable_types: reset int

variable_types: yearEto int

variable_types: ks int

variable_types:
p
char *


decompiled_code:
__int64 __fastcall zen2hanf(const char *a1, char a2)
{
__int64 v4; // r12
char *v5; // r9
char *v6; // rdi
char v7; // al
char *v8; // rsi
char *v9; // rdi

v4 = getString();
v5 = (char *)(v4 + 1);
while ( 1 )
{
v7 = *a1;
v8 = v5 - 1;
if ( !*a1 )
break;
if ( v7 >= 0 )
{
*(v5 - 1) = v7;
++a1;
v6 = v5;
}
else
{
v9 = (char *)a1;
a1 += 2;
if ( (unsigned int)zen2han(v9, v8, 1) )
{
v6 = v5 + 1;
LABEL_8:
strcpy(v6, a1);
return v4;
}
v6 = v5;
}
++v5;
if ( *(v6 - 1) == a2 )
goto LABEL_8;
}
*v8 = 0;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, char a2)
{
__int64 v4; // r12
char *v5; // r9
char *v6; // rdi
char v7; // al
char *v8; // rsi
char *v9; // rdi

v4 = getString();
v5 = (char *)(v4 + 1);
while ( 1 )
{
v7 = *a1;
v8 = v5 - 1;
if ( !*a1 )
break;
if ( v7 >= 0 )
{
*(v5 - 1) = v7;
++a1;
v6 = v5;
}
else
{
v9 = (char *)a1;
a1 += 2;
if ( (unsigned int)func0(v9, v8, 1) )
{
v6 = v5 + 1;
LABEL_8:
strcpy(v6, a1);
return v4;
}
v6 = v5;
}
++v5;
if ( *(v6 - 1) == a2 )
goto LABEL_8;
}
*v8 = 0;
return v4;
}

original_code:
char *
zen2hanf( char *s, char stopper )
{
 char *p = getString();
 char *t;
 int flag = 0;
 t = p;
 while ( *s ) {
  if ( (unsigned char)*s < 0x80 ) {
   *t++ = *s++;
  }
  else {
   flag = _zen2han( s, t, 1 );
   if ( flag )
    t += 2;
   else
    t++;
   s += 2;
  }
  if ( flag || ( *( t - 1 ) == stopper ) ) {
   strcpy( t, s );
   goto EXIT;
  }
 }
 *t = '\0';
EXIT:
 return ( p );
}

canonical_original_code:
char *zen2hanf(char *s, char stopper)
{
 char *p = getString();
 char *t;
 int flag = 0;
 t = p;
 while ( *s ) {
  if ( (unsigned char)*s < 0x80 ) {
   *t++ = *s++;
  }
  else {
   flag = _zen2han( s, t, 1 );
   if ( flag )
    t += 2;
   else
    t++;
   s += 2;
  }
  if ( flag || ( *( t - 1 ) == stopper ) ) {
   strcpy( t, s );
   goto EXIT;
  }
 }
 *t = '\0';
EXIT:
 return ( p );
}

variable_types:
s
char *

variable_types: stopper char

variable_types:
t
char *

variable_types: flag int


getString

decompiled_code:
char *getString()
{
char *v0; // r8
int v1; // edx

v0 = (char *)&buf + 0x2000 * (__int64)count;
v1 = (count + 1) % 30;
memset(v0, 0, 0x2000uLL);
count = v1;
return v0;
}

canonical_decompiled_code:
char *func0()
{
char *v0; // r8
int v1; // edx

v0 = (char *)&buf + 0x2000 * (__int64)count;
v1 = (count + 1) % 30;
memset(v0, 0, 0x2000uLL);
count = v1;
return v0;
}

original_code:
char *
getString()
{
    char *p, *q;
    int i;
    p = q = buf[count];
    count = (count + 1) % 30;
    for ( i = 0; i < 8192; i++ )
        *q++ = '\0';
    return ( p );
}

canonical_original_code:
char *getString()
{
    char *p; char *q;
    int i;
    p = q = buf[count];
    count = (count + 1) % 30;
    for ( i = 0; i < 8192; i++ )
        *q++ = '\0';
    return ( p );
}

variable_types:
q
char *

variable_types: i int


decompiled_code:
_BOOL8 __fastcall is_world_regdom(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == 48 )
result = a1[1] == 48;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == 48 )
result = a1[1] == 48;
return result;
}

original_code:
static inline int is_world_regdom(const char *alpha2)
{
 if (alpha2[0] == '0' && alpha2[1] == '0')
  return 1;
 return 0;
}

canonical_original_code:
static inline int is_world_regdom(char *alpha2)
{
 if (alpha2[0] == '0' && alpha2[1] == '0')
  return 1;
 return 0;
}


max

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

result = a1;
if ( a2 >= a1 )
result = a2;
return result;
}

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

result = a1;
if ( a2 >= a1 )
result = a2;
return result;
}

original_code:
static inline uint32_t max(uint32_t a, uint32_t b)
{
 return (a > b) ? a : b;
}

canonical_original_code:
static inline unsigned int max(unsigned int a, unsigned int b)
{
 return (a > b) ? a : b;
}

variable_types:
a
unsigned int

variable_types:
b
unsigned int

return_type: unsigned int


min

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

result = a2;
if ( a1 <= a2 )
result = a1;
return result;
}

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

result = a2;
if ( a1 <= a2 )
result = a1;
return result;
}

original_code:
static inline uint32_t min(uint32_t a, uint32_t b)
{
 return (a > b) ? b : a;
}

canonical_original_code:
static inline unsigned int min(unsigned int a, unsigned int b)
{
 return (a > b) ? b : a;
}


decompiled_code:
_BOOL8 __fastcall is_valid_reg_rule(unsigned int *a1)
{
unsigned int v1; // eax
_BOOL4 v2; // er8
unsigned int v3; // edx
unsigned int v4; // edx

v1 = *a1;
v2 = 0;
if ( !*a1 )
return v2;
v3 = a1[1];
if ( v3 && v1 <= v3 )
{
v4 = v3 - v1;
if ( v4 )
v2 = a1[2] <= v4;
return v2;
}
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(unsigned int *a1)
{
unsigned int v1; // eax
_BOOL4 v2; // er8
unsigned int v3; // edx
unsigned int v4; // edx

v1 = *a1;
v2 = 0;
if ( !*a1 )
return v2;
v3 = a1[1];
if ( v3 && v1 <= v3 )
{
v4 = v3 - v1;
if ( v4 )
v2 = a1[2] <= v4;
return v2;
}
return 0LL;
}

original_code:
static int is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
{
 const struct ieee80211_freq_range *freq_range = &rule->freq_range;
 uint32_t freq_diff;
 if (freq_range->start_freq_khz == 0 || freq_range->end_freq_khz == 0)
  return 0;
 if (freq_range->start_freq_khz > freq_range->end_freq_khz)
  return 0;
 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
 if (freq_diff == 0 || freq_range->max_bandwidth_khz > freq_diff)
  return 0;
 return 1;
}

canonical_original_code:
static int is_valid_reg_rule(struct ieee80211_reg_rule *rule)
{
 struct ieee80211_freq_range *freq_range = &rule->freq_range;
 unsigned int freq_diff;
 if (freq_range->start_freq_khz == 0 || freq_range->end_freq_khz == 0)
  return 0;
 if (freq_range->start_freq_khz > freq_range->end_freq_khz)
  return 0;
 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
 if (freq_diff == 0 || freq_range->max_bandwidth_khz > freq_diff)
  return 0;
 return 1;
}

variable_types: struct ieee80211_reg_rule { struct ieee80211_freq_range { unsigned int start_freq_khz; unsigned int end_freq_khz; unsigned int max_bandwidth_khz; } freq_range; struct ieee80211_power_rule { unsigned int max_antenna_gain; unsigned int max_eirp; } power_rule; unsigned int flags; } *

variable_types: struct ieee80211_freq_range { unsigned int start_freq_khz; unsigned int end_freq_khz; unsigned int max_bandwidth_khz; } *

user_defined_types: struct ieee80211_reg_rule { struct ieee80211_freq_range freq_range; struct ieee80211_power_rule power_rule; unsigned int flags; }


original_code:
static int reg_rules_intersect(
 struct ieee80211_reg_rule *rule1,
 struct ieee80211_reg_rule *rule2,
 struct ieee80211_reg_rule *intersected_rule)
{
 struct ieee80211_freq_range *freq_range1, *freq_range2, *freq_range;
 struct ieee80211_power_rule *power_rule1, *power_rule2, *power_rule;
 uint32_t freq_diff;
 freq_range1 = &rule1->freq_range;
 freq_range2 = &rule2->freq_range;
 freq_range = &intersected_rule->freq_range;
 power_rule1 = &rule1->power_rule;
 power_rule2 = &rule2->power_rule;
 power_rule = &intersected_rule->power_rule;
 freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
  freq_range2->start_freq_khz);
 freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
  freq_range2->end_freq_khz);
 freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz,
  freq_range2->max_bandwidth_khz);
 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
 if (freq_range->max_bandwidth_khz > freq_diff)
  freq_range->max_bandwidth_khz = freq_diff;
 power_rule->max_eirp = min(power_rule1->max_eirp,
  power_rule2->max_eirp);
 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain,
  power_rule2->max_antenna_gain);
 intersected_rule->flags = (rule1->flags | rule2->flags);
 if (!is_valid_reg_rule(intersected_rule))
  return -22;
 return 0;
}

canonical_original_code:
static int reg_rules_intersect(struct ieee80211_reg_rule *rule1, struct ieee80211_reg_rule *rule2, struct ieee80211_reg_rule *intersected_rule)
{
 struct ieee80211_freq_range *freq_range1; struct ieee80211_freq_range *freq_range2; struct ieee80211_freq_range *freq_range;
 struct ieee80211_power_rule *power_rule1; struct ieee80211_power_rule *power_rule2; struct ieee80211_power_rule *power_rule;
 unsigned int freq_diff;
 freq_range1 = &rule1->freq_range;
 freq_range2 = &rule2->freq_range;
 freq_range = &intersected_rule->freq_range;
 power_rule1 = &rule1->power_rule;
 power_rule2 = &rule2->power_rule;
 power_rule = &intersected_rule->power_rule;
 freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
  freq_range2->start_freq_khz);
 freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
  freq_range2->end_freq_khz);
 freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz,
  freq_range2->max_bandwidth_khz);
 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
 if (freq_range->max_bandwidth_khz > freq_diff)
  freq_range->max_bandwidth_khz = freq_diff;
 power_rule->max_eirp = min(power_rule1->max_eirp,
  power_rule2->max_eirp);
 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain,
  power_rule2->max_antenna_gain);
 intersected_rule->flags = (rule1->flags | rule2->flags);
 if (!is_valid_reg_rule(intersected_rule))
  return -22;
 return 0;
}

variable_types: struct ieee80211_power_rule { unsigned int max_antenna_gain; unsigned int max_eirp; } *

user_defined_types: struct ieee80211_freq_range { unsigned int start_freq_khz; unsigned int end_freq_khz; unsigned int max_bandwidth_khz; }


decompiled_code:
_BOOL8 __fastcall isalpha_upper(char a1)
{
return (unsigned __int8)(a1 - 65) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(char a1)
{
return (unsigned __int8)(a1 - 65) <= 0x19u;
}

original_code:
static inline int isalpha_upper(char letter)
{
 if (letter >= 'A' && letter <= 'Z')
  return 1;
 return 0;
}

variable_types: letter char


decompiled_code:
_BOOL8 __fastcall is_alpha2(char *a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx

result = isalpha_upper(*a1);
if ( result )
result = isalpha_upper(*(_BYTE *)(v2 + 1));
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char *a1)
{
_BOOL8 result; // rax
__int64 v2; // rdx

result = func1(*a1);
if ( result )
result = func1(*(_BYTE *)(v2 + 1));
return result;
}

original_code:
static inline int is_alpha2(const char *alpha2)
{
 if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
  return 1;
 return 0;
}

canonical_original_code:
static inline int is_alpha2(char *alpha2)
{
 if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
  return 1;
 return 0;
}


decompiled_code:
_BOOL8 __fastcall is_valid_regdom(char *a1)
{
_BYTE *v1; // r8
_BOOL4 v2; // er9
_BOOL8 result; // rax

v2 = is_alpha2(a1);
result = 1LL;
if ( !v2 )
result = is_world_regdom(v1);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(char *a1)
{
_BYTE *v1; // r8
_BOOL4 v2; // er9
_BOOL8 result; // rax

v2 = func2(a1);
result = 1LL;
if ( !v2 )
result = func0(v1);
return result;
}

original_code:
static inline int is_valid_regdom(const char *alpha2)
{
 if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
  return 0;
 return 1;
}

canonical_original_code:
static inline int is_valid_regdom(char *alpha2)
{
 if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
  return 0;
 return 1;
}


decompiled_code:
void __fastcall __noreturn error_handler(__int64 a1, int *a2)
{
fprintf(stderr, "nl80211 error %d\n", (unsigned int)*a2);
exit(*a2);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(__int64 a1, int *a2)
{
fprintf(stderr, "nl80211 error %d\n", (unsigned int)*a2);
exit(*a2);
}

original_code:
static int error_handler(struct sockaddr_nl __attribute__((unused)) *nla,
       struct nlmsgerr *err,
       void __attribute__((unused)) *arg)
{
 fprintf(stderr, "nl80211 error %d\n", err->error);
 exit(err->error);
}

canonical_original_code:
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
{
 fprintf(stderr, "nl80211 error %d\n", err->error);
 exit(err->error);
}

variable_types: struct sockaddr_nl { unsigned short nl_family; unsigned short nl_pad; unsigned int nl_pid; unsigned int nl_groups; } *

variable_types: struct nlmsgerr { int error; struct nlmsghdr { unsigned int nlmsg_len; unsigned short nlmsg_type; unsigned short nlmsg_flags; unsigned int nlmsg_seq; unsigned int nlmsg_pid; } msg; } *

variable_types:
arg
void *

user_defined_types: struct nlmsgerr { int error; struct nlmsghdr msg; }


original_code:
static void print_reg_rule(struct ieee80211_reg_rule *rule)
{
 struct ieee80211_freq_range *freq;
 struct ieee80211_power_rule *power;
 freq = &rule->freq_range;
 power = &rule->power_rule;
 printf("\t(%.3f - %.3f @ %.3f), ",
        ((float)(freq->start_freq_khz))/1000.0,
        ((float)(freq->end_freq_khz))/1000.0,
        ((float)(freq->max_bandwidth_khz))/1000.0);
 printf("(");
 if (power->max_antenna_gain)
  printf("%.2f, ", ((float)(power->max_antenna_gain)/100.0));
 else
  printf("N/A, ");
 if (power->max_eirp)
  printf("%.2f)", ((float)(power->max_eirp)/100.0));
 else
  printf("N/A)");
 if (rule->flags & NL80211_RRF_NO_OFDM)
  printf(", NO-OFDM");
 if (rule->flags & NL80211_RRF_NO_CCK)
  printf(", NO-CCK");
 if (rule->flags & NL80211_RRF_NO_INDOOR)
  printf(", NO-INDOOR");
 if (rule->flags & NL80211_RRF_NO_OUTDOOR)
  printf(", NO-OUTDOOR");
 if (rule->flags & NL80211_RRF_DFS)
  printf(", DFS");
 if (rule->flags & NL80211_RRF_PTP_ONLY)
  printf(", PTP-ONLY");
 if (rule->flags & NL80211_RRF_PTMP_ONLY)
  printf(", PTMP-ONLY");
 if (rule->flags & NL80211_RRF_PASSIVE_SCAN)
  printf(", PASSIVE-SCAN");
 if (rule->flags & NL80211_RRF_NO_IBSS)
  printf(", NO-IBSS");
 printf("\n");
}

user_defined_types: struct ieee80211_power_rule { unsigned int max_antenna_gain; unsigned int max_eirp; }


decompiled_code:
int __fastcall print_regdom(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // rax

printf("country %.2s:\n", (const char *)(a1 + 4));
if ( *(_DWORD *)a1 )
{
v1 = 0;
do
{
v2 = v1++;
print_reg_rule((int *)(a1 + 24 * v2 + 8));
}
while ( *(_DWORD *)a1 > v1 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // rax

printf("country %.2s:\n", (const char *)(a1 + 4));
if ( *(_DWORD *)a1 )
{
v1 = 0;
do
{
v2 = v1++;
func0((int *)(a1 + 24 * v2 + 8));
}
while ( *(_DWORD *)a1 > v1 );
}
return putchar(10);
}

original_code:
void print_regdom(struct ieee80211_regdomain *rd)
{
 unsigned int i;
 printf("country %.2s:\n", rd->alpha2);
 for (i = 0; i < rd->n_reg_rules; i++)
  print_reg_rule(&rd->reg_rules[i]);
 printf("\n");
}

variable_types: struct ieee80211_regdomain { unsigned int n_reg_rules; char alpha2[2]; unsigned char dfs_region; struct ieee80211_reg_rule { struct ieee80211_freq_range { unsigned int start_freq_khz; unsigned int end_freq_khz; unsigned int max_bandwidth_khz; } freq_range; struct ieee80211_power_rule { unsigned int max_antenna_gain; unsigned int max_eirp; } power_rule; unsigned int flags; } reg_rules[]; } *

variable_types:
i
unsigned int

user_defined_types: struct ieee80211_regdomain { unsigned int n_reg_rules; char alpha2[2]; unsigned char dfs_region; struct ieee80211_reg_rule reg_rules[]; }


decompiled_code:
void printf_null()
{
++_gcov0_printf_null;
}

canonical_decompiled_code:
void func0()
{
++_gcov0_printf_null;
}

original_code:
static void printf_null()
{
}

canonical_original_code:
static void printf_null()
{
}


decompiled_code:
void printf_null_char()
{
++_gcov0_printf_null_char;
}

canonical_decompiled_code:
void func1()
{
++_gcov0_printf_null_char;
}

original_code:
static void printf_null_char(const char* s)
{
    (void)s;
}

canonical_original_code:
static void printf_null_char(char *s)
{
    (void)s;
}

variable_types:
s
char *


decompiled_code:
int __fastcall printf_message(const char *a1)
{
int result; // eax

++_gcov0_printf_message;
result = puts(a1);
++qword_308;
return result;
}

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

++_gcov0_printf_message;
result = puts(a1);
++qword_308;
return result;
}

original_code:
static void printf_message(const char* message)
{
    printf("%s\n", message);
}

canonical_original_code:
static void printf_message(char *message)
{
    printf("%s\n", message);
}

variable_types:
message
char *


decompiled_code:
int __fastcall printf_tests_passed(unsigned int a1)
{
int result; // eax

++_gcov0_printf_tests_passed;
result = printf("All test cases (%d) run successfully.\n", a1);
++qword_2E8;
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1)
{
int result; // eax

++_gcov0_printf_tests_passed;
result = printf("All test cases (%d) run successfully.\n", a1);
++qword_2E8;
return result;
}

original_code:
static void printf_tests_passed(int testCount)
{
    printf("All test cases (%d) run successfully.\n", testCount);
}

variable_types: testCount int


decompiled_code:
int __fastcall printf_tests_failed(unsigned int a1, __int64 a2)
{
int result; // eax

++_gcov0_printf_tests_failed;
result = printf("%d out of %d failed.\n", a2, a1);
++qword_2D8;
return result;
}

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

++_gcov0_printf_tests_failed;
result = printf("%d out of %d failed.\n", a2, a1);
++qword_2D8;
return result;
}

original_code:
static void printf_tests_failed(int testCount, int failedCount)
{
    printf("%d out of %d failed.\n", failedCount, testCount);
}

variable_types: failedCount int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4[11]; // [rsp+0h] [rbp-58h] BYREF

++_gcov0_main;
v4[0] = (__int64)printf_tests_failed;
v4[1] = (__int64)printf_tests_passed;
v4[2] = (__int64)printf_null;
v4[3] = (__int64)printf_null;
v4[4] = (__int64)printf_null_char;
v4[5] = (__int64)printf_null;
v4[6] = (__int64)printf_null;
v4[7] = (__int64)printf_null;
v4[8] = (__int64)printf_message;
result = asn1scc_run_generated_testsuite(v4, argv, envp);
++qword_318;
return result;
}

original_code:
int main(int argc, char* argv[])
{
    (void)argc;
    (void)argv;
    TestOutput output = {
               .report_tests_failed = printf_tests_failed,
               .report_all_tests_passed = printf_tests_passed,
               .report_suite_begin = printf_null,
               .report_suite_end = printf_null,
               .report_case_begin = printf_null_char,
               .report_case_end = printf_null,
               .report_failure_begin = printf_null,
               .report_failure_end = printf_null,
               .report_failure_message = printf_message
    };
    return asn1scc_run_generated_testsuite(&output);
}

canonical_original_code:
int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;
    struct TestOutput output = {
               .report_tests_failed = printf_tests_failed,
               .report_all_tests_passed = printf_tests_passed,
               .report_suite_begin = printf_null,
               .report_suite_end = printf_null,
               .report_case_begin = printf_null_char,
               .report_case_end = printf_null,
               .report_failure_begin = printf_null,
               .report_failure_end = printf_null,
               .report_failure_message = printf_message
    };
    return asn1scc_run_generated_testsuite(&output);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct TestOutput { void (*report_tests_failed)(int testsCount, int failedCount); void (*report_all_tests_passed)(int testsCount); void (*report_suite_begin)(); void (*report_suite_end)(); void (*report_case_begin)(char *caseName); void (*report_case_end)(); void (*report_failure_begin)(); void (*report_failure_end)(); void (*report_failure_message)(char *message); }


original_code:
asn1SccUint calc_crc_32(byte* buf, long size) {
 (void) buf;
 (void)size;
 return 314159265l;
}

canonical_original_code:
unsigned long long calc_crc_32(unsigned char *buf, long size) {
 (void) buf;
 (void)size;
 return 314159265l;
}

variable_types:
buf
unsigned char *

variable_types: size long

return_type: unsigned long long


decompiled_code:
__int64 __fastcall my_encoding_patcher(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdx
__int64 v5; // rax
__int64 v6; // rsi
__int64 v7; // rdi
__int64 v8; // rax
__int64 v9; // rdx
__int64 result; // rax

v4 = *(_QWORD *)(a3 + 48);
v5 = *(int *)(a3 + 56);
++_gcov0_my_encoding_patcher;
Acn_Enc_Int_PositiveInteger_ConstSize(
a3,
(unsigned __int64)(v5 + 8 * v4 - 16 - (*(int *)(a3 + 24) + 8LL * *(_QWORD *)(a3 + 16))) >> 3,
16LL);
v6 = *(_QWORD *)(a3 + 48);
v7 = *(_QWORD *)(a3 + 32);
++qword_2F8;
v8 = calc_crc_32(v7, v6, 32LL);
result = Acn_Enc_Int_PositiveInteger_ConstSize(a3 + 32, v8, v9);
++qword_300;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdx
__int64 v5; // rax
__int64 v6; // rsi
__int64 v7; // rdi
__int64 v8; // rax
__int64 v9; // rdx
__int64 result; // rax

v4 = *(_QWORD *)(a3 + 48);
v5 = *(int *)(a3 + 56);
++_gcov0_my_encoding_patcher;
Acn_Enc_Int_PositiveInteger_ConstSize(
a3,
(unsigned __int64)(v5 + 8 * v4 - 16 - (*(int *)(a3 + 24) + 8LL * *(_QWORD *)(a3 + 16))) >> 3,
16LL);
v6 = *(_QWORD *)(a3 + 48);
v7 = *(_QWORD *)(a3 + 32);
++qword_2F8;
v8 = func0(v7, v6, 32LL);
result = Acn_Enc_Int_PositiveInteger_ConstSize(a3 + 32, v8, v9);
++qword_300;
return result;
}

original_code:
void my_encoding_patcher(const Packet * pPacket, BitStream* pStartBitStrm, Packet_extension_function_positions* pNullPos, BitStream* pEndBitStrm) {
 (void)pPacket;
 (void)pStartBitStrm;
 (void)pEndBitStrm;
    asn1SccUint startPosInBits =
        pNullPos->Packet_body_length_in_bytes.currentByte * 8 + pNullPos->Packet_body_length_in_bytes.currentBit;
    asn1SccUint endPosIBits =
        pNullPos->Packet_packet_crc32.currentByte * 8 + pNullPos->Packet_packet_crc32.currentBit;
    asn1SccUint lengthInBytes = (endPosIBits - startPosInBits - 16)/8;
    Acn_Enc_Int_PositiveInteger_ConstSize(&pNullPos->Packet_body_length_in_bytes, lengthInBytes, 16);
 asn1SccUint crc32 = calc_crc_32(pNullPos->Packet_packet_crc32.buf, pNullPos->Packet_packet_crc32.currentByte);
 Acn_Enc_Int_PositiveInteger_ConstSize(&pNullPos->Packet_packet_crc32, crc32, 32);
}

canonical_original_code:
void my_encoding_patcher(struct Packet *pPacket, struct BitStream *pStartBitStrm, struct Packet_extension_function_positions *pNullPos, struct BitStream *pEndBitStrm) {
 (void)pPacket;
 (void)pStartBitStrm;
 (void)pEndBitStrm;
    unsigned long long startPosInBits = pNullPos->Packet_body_length_in_bytes.currentByte * 8 + pNullPos->Packet_body_length_in_bytes.currentBit;
    unsigned long long endPosIBits = pNullPos->Packet_packet_crc32.currentByte * 8 + pNullPos->Packet_packet_crc32.currentBit;
    unsigned long long lengthInBytes = (endPosIBits - startPosInBits - 16)/8;
    Acn_Enc_Int_PositiveInteger_ConstSize(&pNullPos->Packet_body_length_in_bytes, lengthInBytes, 16);
 unsigned long long crc32 = calc_crc_32(pNullPos->Packet_packet_crc32.buf, pNullPos->Packet_packet_crc32.currentByte);
 Acn_Enc_Int_PositiveInteger_ConstSize(&pNullPos->Packet_packet_crc32, crc32, 32);
}

variable_types: struct Packet { struct PacketHeader { unsigned long long version; unsigned long long release; struct PacketHeader_varSizeArray { int nCount; unsigned long long arr[20]; } varSizeArray; } p_header; struct PacketBody { enum PacketBody_selection { PacketBody_NONE=0, aReal_PRESENT=1, anInteger_PRESENT=2, anotherSizeArray_PRESENT=3 } kind; union { double aReal; unsigned long long anInteger; struct PacketBody_anotherSizeArray { int nCount; unsigned long long arr[100]; } anotherSizeArray; } u; } p_body; } *

variable_types: struct BitStream { unsigned char *buf; long count; long currentByte; int currentBit; } *

variable_types: struct Packet_extension_function_positions { struct BitStream Packet_body_length_in_bytes; struct BitStream Packet_packet_crc32; } *

variable_types:
pEndBitStrm
struct BitStream *

variable_types:
startPosInBits
unsigned long long

variable_types:
endPosIBits
unsigned long long

variable_types:
lengthInBytes
unsigned long long

user_defined_types: struct Packet { struct PacketHeader p_header; struct PacketBody p_body; }

user_defined_types: struct PacketHeader { unsigned long long version; unsigned long long release; struct PacketHeader_varSizeArray varSizeArray; }

user_defined_types: struct PacketBody { enum PacketBody_selection kind; union { double aReal; unsigned long long anInteger; struct PacketBody_anotherSizeArray anotherSizeArray; } u; }


original_code:
flag crc_validator(const Packet * pPacket, BitStream* pStartBitStrm, Packet_extension_function_positions* pNullPos, BitStream* pEndBitStrm, int* pErrCode) {
 (void)pPacket;
 (void)pStartBitStrm;
 (void)pEndBitStrm;
 flag ret1;
 flag ret2;
    asn1SccUint startPosInBits =
        pNullPos->Packet_body_length_in_bytes.currentByte * 8 + pNullPos->Packet_body_length_in_bytes.currentBit;
    asn1SccUint endPosIBits =
        pNullPos->Packet_packet_crc32.currentByte * 8 + pNullPos->Packet_packet_crc32.currentBit;
    asn1SccUint lengthInBytes = (endPosIBits - startPosInBits - 16)/8;
 asn1SccUint decodeLengthInBytes=0;
    ret1 = Acn_Dec_Int_PositiveInteger_ConstSize(&pNullPos->Packet_body_length_in_bytes, &decodeLengthInBytes, 16);
 asn1SccUint crc32 = calc_crc_32(pNullPos->Packet_packet_crc32.buf, pNullPos->Packet_packet_crc32.currentByte);
 asn1SccUint decodeCrc32;
 ret2 = Acn_Dec_Int_PositiveInteger_ConstSize(&pNullPos->Packet_packet_crc32, &decodeCrc32, 32);
 flag ret = ret1 && ret2 && (lengthInBytes == decodeLengthInBytes) && (crc32 == decodeCrc32);
 *pErrCode = ret ? 0 : 99999;
    return ret;
}

canonical_original_code:
_Bool crc_validator(struct Packet *pPacket, struct BitStream *pStartBitStrm, struct Packet_extension_function_positions *pNullPos, struct BitStream *pEndBitStrm, int *pErrCode) {
 (void)pPacket;
 (void)pStartBitStrm;
 (void)pEndBitStrm;
 _Bool ret1;
 _Bool ret2;
    unsigned long long startPosInBits = pNullPos->Packet_body_length_in_bytes.currentByte * 8 + pNullPos->Packet_body_length_in_bytes.currentBit;
    unsigned long long endPosIBits = pNullPos->Packet_packet_crc32.currentByte * 8 + pNullPos->Packet_packet_crc32.currentBit;
    unsigned long long lengthInBytes = (endPosIBits - startPosInBits - 16)/8;
 unsigned long long decodeLengthInBytes = 0;
    ret1 = Acn_Dec_Int_PositiveInteger_ConstSize(&pNullPos->Packet_body_length_in_bytes, &decodeLengthInBytes, 16);
 unsigned long long crc32 = calc_crc_32(pNullPos->Packet_packet_crc32.buf, pNullPos->Packet_packet_crc32.currentByte);
 unsigned long long decodeCrc32;
 ret2 = Acn_Dec_Int_PositiveInteger_ConstSize(&pNullPos->Packet_packet_crc32, &decodeCrc32, 32);
 _Bool ret = ret1 && ret2 && (lengthInBytes == decodeLengthInBytes) && (crc32 == decodeCrc32);
 *pErrCode = ret ? 0 : 99999;
    return ret;
}

variable_types:
pErrCode
int *

variable_types:
decodeLengthInBytes
unsigned long long

user_defined_types: struct BitStream { unsigned char *buf; long count; long currentByte; int currentBit; }

user_defined_types: struct Packet_extension_function_positions { struct BitStream Packet_body_length_in_bytes; struct BitStream Packet_packet_crc32; }

user_defined_types: struct PacketHeader_varSizeArray { int nCount; unsigned long long arr[20]; }

user_defined_types: enum PacketBody_selection { PacketBody_NONE=0, aReal_PRESENT=1, anInteger_PRESENT=2, anotherSizeArray_PRESENT=3 }

user_defined_types: struct PacketBody_anotherSizeArray { int nCount; unsigned long long arr[100]; }


decompiled_code:
__int64 __fastcall OOO_Equal(__int64 a1, __int64 a2)
{
unsigned __int8 v2; // dl
unsigned __int8 v3; // al
__int64 result; // rax

if ( *(_WORD *)a1 == *(_WORD *)a2
&& (v2 = *(_BYTE *)(a1 + 2), v3 = *(_BYTE *)(a2 + 2), ++_gcov0_OOO_Equal, v2 >> 4 == v3 >> 4) )
{
++qword_278;
result = 1LL;
}
else
{
++qword_280;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
unsigned __int8 v2; // dl
unsigned __int8 v3; // al
__int64 result; // rax

if ( *(_WORD *)a1 == *(_WORD *)a2
&& (v2 = *(_BYTE *)(a1 + 2), v3 = *(_BYTE *)(a2 + 2), ++_gcov0_OOO_Equal, v2 >> 4 == v3 >> 4) )
{
++qword_278;
result = 1LL;
}
else
{
++qword_280;
result = 0LL;
}
return result;
}


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

result = 0LL;
++_gcov0_OOO_Initialize;
*(_WORD *)a1 = 0;
*(_BYTE *)(a1 + 2) = 0;
return result;
}

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

result = 0LL;
++_gcov0_OOO_Initialize;
*(_WORD *)a1 = 0;
*(_BYTE *)(a1 + 2) = 0;
return result;
}

original_code:
void OOO_Initialize(OOO* pVal)
{
 memset(pVal->arr, 0x0, 24/8);
}

canonical_original_code:
void OOO_Initialize(struct OOO *pVal)
{
 memset(pVal->arr, 0x0, 24/8);
}

variable_types:
pVal
struct OOO { unsigned char arr[3]; } *


decompiled_code:
__int64 __fastcall OOO_Encode(__int64 a1, __int64 a2, _DWORD *a3)
{
*a3 = 0;
++_gcov0_OOO_Encode;
BitStream_AppendBits(a2, a1, 20LL);
++qword_298;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, _DWORD *a3)
{
*a3 = 0;
++_gcov0_OOO_Encode;
BitStream_AppendBits(a2, a1, 20LL);
++qword_298;
return 1LL;
}

original_code:
flag OOO_Encode(const OOO* pVal, BitStream* pBitStrm, int* pErrCode, flag bCheckConstraints)
{
    flag ret = 1;
    *pErrCode = 0;
    bCheckConstraints=bCheckConstraints;
    BitStream_AppendBits(pBitStrm, pVal->arr, 20);
    return ret;
}

canonical_original_code:
_Bool OOO_Encode(struct OOO *pVal, struct BitStream *pBitStrm, int *pErrCode, _Bool bCheckConstraints)
{
    _Bool ret = 1;
    *pErrCode = 0;
    bCheckConstraints=bCheckConstraints;
    BitStream_AppendBits(pBitStrm, pVal->arr, 20);
    return ret;
}


decompiled_code:
__int64 __fastcall OOO_Decode(__int64 a1, __int64 a2, int *a3)
{
__int64 result; // rax
int v5; // edx

++_gcov0_OOO_Decode;
result = BitStream_ReadBits(a2, a1, 20LL);
++qword_2A8;
v5 = 0;
if ( !(_BYTE)result )
{
++qword_2B0;
v5 = 2;
}
*a3 = v5;
return result;
}

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

++_gcov0_OOO_Decode;
result = BitStream_ReadBits(a2, a1, 20LL);
++qword_2A8;
v5 = 0;
if ( !(_BYTE)result )
{
++qword_2B0;
v5 = 2;
}
*a3 = v5;
return result;
}

original_code:
flag OOO_Decode(OOO* pVal, BitStream* pBitStrm, int* pErrCode)
{
    flag ret = 1;
 ret = BitStream_ReadBits(pBitStrm, pVal->arr, 20);
 *pErrCode = ret ? 0 : 2;
 return ret ;
}

canonical_original_code:
_Bool OOO_Decode(struct OOO *pVal, struct BitStream *pBitStrm, int *pErrCode)
{
    _Bool ret = 1;
 ret = BitStream_ReadBits(pBitStrm, pVal->arr, 20);
 *pErrCode = ret ? 0 : 2;
 return ret ;
}