original_code:
void construct_lon_bounds_array( int ny, float *lon ) {
     int i, j, k, ind;
     double tlat, tlon, tol, degtorad, sock, cpart, t1, t2, longitude, latitude;
     double pseudolat, pseudolon, cos_pseudolat, sin_pseudolat, factor;
     if ( header[3]<99 ) {
        for ( j=0; j<ny; j++ ) {
        for ( i=0; i<int_constants[5]; i++ ) {
            tlon = real_constants[3] + real_constants[0]*((double ) i);
            t1 = tlon - 0.5*real_constants[0];
            ind = j*int_constants[5] + i;
            lon[ind] = (float ) t1;
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
            t1 = tlon + 0.5*real_constants[0];
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
        }
        }
     } else {
        degtorad=3.1415926535898/180.0;
        pseudolat = real_constants[4] * degtorad;
        pseudolon = real_constants[5] * degtorad;
        cos_pseudolat = cos( pseudolat );
        sin_pseudolat = sin( pseudolat );
        if ( pseudolon==0 ) { sock = 0.0; }
        else { sock = pseudolon - 3.1415926535898; }
        for ( i=0; i<int_constants[5]; i++) {
        for ( j=0; j<ny; j++) {
        for ( k=1; k<5; k++ ) {
            switch( k ){
                  case 1:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 2:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 3:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 4:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
            }
            factor = 1.0;
            if ( (tlon>-1.0e-20) && (tlon<3.14159265358001) ) { factor = -1.0; }
            tlon = cos( tlon );
            cpart = tlon*cos(tlat);
            latitude = asin( cos_pseudolat*cpart + sin_pseudolat*sin(tlat) );
            t1 = -cos_pseudolat*sin(tlat);
            t2 = sin_pseudolat*cpart;
            tol = (cos(latitude)+t1+t2) * (cos(latitude)+t1+t2);
            if ( tol<=1.0e-16 ) { longitude = 3.1415926535898; }
            else { longitude = -acos((t1+t2)/cos(latitude)); }
            longitude = factor*longitude + sock;
            if ( longitude<0.0 ) { longitude += 2.0*3.1415926535898; }
            ind = (k-1)*ny*int_constants[5] + int_constants[5]*j + i;
            lon[ind] = (float ) (longitude / degtorad);
        }
        }
        }
     }
     return;
}

canonical_original_code:
void construct_lon_bounds_array(int ny, float *lon) {
     int i; int j; int k; int ind;
     double tlat; double tlon; double tol; double degtorad; double sock; double cpart; double t1; double t2; double longitude; double latitude;
     double pseudolat; double pseudolon; double cos_pseudolat; double sin_pseudolat; double factor;
     if ( header[3]<99 ) {
        for ( j=0; j<ny; j++ ) {
        for ( i=0; i<int_constants[5]; i++ ) {
            tlon = real_constants[3] + real_constants[0]*((double ) i);
            t1 = tlon - 0.5*real_constants[0];
            ind = j*int_constants[5] + i;
            lon[ind] = (float ) t1;
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
            t1 = tlon + 0.5*real_constants[0];
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
            ind += int_constants[5]*ny;
            lon[ind] = (float ) t1;
        }
        }
     } else {
        degtorad=3.1415926535898/180.0;
        pseudolat = real_constants[4] * degtorad;
        pseudolon = real_constants[5] * degtorad;
        cos_pseudolat = cos( pseudolat );
        sin_pseudolat = sin( pseudolat );
        if ( pseudolon==0 ) { sock = 0.0; }
        else { sock = pseudolon - 3.1415926535898; }
        for ( i=0; i<int_constants[5]; i++) {
        for ( j=0; j<ny; j++) {
        for ( k=1; k<5; k++ ) {
            switch( k ){
                  case 1:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 2:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 3:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 4:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
            }
            factor = 1.0;
            if ( (tlon>-1.0e-20) && (tlon<3.14159265358001) ) { factor = -1.0; }
            tlon = cos( tlon );
            cpart = tlon*cos(tlat);
            latitude = asin( cos_pseudolat*cpart + sin_pseudolat*sin(tlat) );
            t1 = -cos_pseudolat*sin(tlat);
            t2 = sin_pseudolat*cpart;
            tol = (cos(latitude)+t1+t2) * (cos(latitude)+t1+t2);
            if ( tol<=1.0e-16 ) { longitude = 3.1415926535898; }
            else { longitude = -acos((t1+t2)/cos(latitude)); }
            longitude = factor*longitude + sock;
            if ( longitude<0.0 ) { longitude += 2.0*3.1415926535898; }
            ind = (k-1)*ny*int_constants[5] + int_constants[5]*j + i;
            lon[ind] = (float ) (longitude / degtorad);
        }
        }
        }
     }
     return;
}

variable_types: i int

variable_types: k int

variable_types: factor double


decompiled_code:
void __fastcall construct_lat_bounds_array(int a1, __int64 a2)
{
int i; // esi
double v4; // xmm0_8
double v5; // xmm2_8
double v6; // xmm0_8
double v7; // xmm1_8
double v8; // xmm0_8
__int64 v9; // rax
__int64 v10; // rcx
float v11; // xmm1_4
float v12; // xmm0_4
int v13; // eax
int v14; // edx
int v15; // edx
float v16; // xmm0_4
int j; // ebx
int v18; // ebp
int v19; // er14
double v20; // [rsp+0h] [rbp-78h]
double x; // [rsp+8h] [rbp-70h]
double v22; // [rsp+10h] [rbp-68h]
double v23; // [rsp+18h] [rbp-60h]
__int64 v24; // [rsp+28h] [rbp-50h]
double cosx; // [rsp+30h] [rbp-48h] BYREF
double sinx[8]; // [rsp+38h] [rbp-40h] BYREF

if ( header[3] <= 98 )
{
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
v4 = real_constants[1];
v5 = (double)i * v4 + real_constants[2];
v6 = v4 * 0.5;
v7 = v5 - v6;
v8 = v6 + v5;
v9 = int_constants[5];
if ( v9 > 0 )
{
v10 = 0LL;
v11 = v7;
v12 = v8;
do
{
v13 = v10 + i * v9;
*(float *)(a2 + 4LL * v13) = v11;
v14 = v13 + LODWORD(int_constants[5]) * a1;
*(float *)(a2 + 4LL * v14) = v12;
v15 = LODWORD(int_constants[5]) * a1 + v14;
*(float *)(a2 + 4LL * v15) = v12;
*(float *)(a2 + 4LL * (v15 + LODWORD(int_constants[5]) * a1)) = v11;
v9 = int_constants[5];
++v10;
}
while ( v9 > v10 );
}
}
}
return;
}
sincos(0.01745329251994333 * real_constants[4], sinx, &cosx);
v22 = cosx;
v23 = sinx[0];
v24 = 0LL;
if ( int_constants[5] <= 0 )
return;
while ( 2 )
{
v19 = 0;
if ( a1 <= 0 )
goto LABEL_24;
while ( 2 )
{
v18 = v19;
for ( j = 1; j != 5; ++j )
{
if ( j == 3 )
{
v20 = (((double)(int)v24 + 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 + 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
}
else
{
if ( j > 3 )
{
if ( j == 4 )
{
v20 = (((double)(int)v24 + 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 - 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
goto LABEL_15;
}
goto LABEL_14;
}
if ( j == 1 )
{
v20 = (((double)(int)v24 - 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 - 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
LABEL_14:
sincos(x, sinx, &cosx);
goto LABEL_15;
}
if ( j != 2 )
goto LABEL_14;
v20 = (((double)(int)v24 - 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 + 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
}
LABEL_15:
v20 = cos(v20);
v16 = asin(v20 * cosx * v22 + v23 * sinx[0]) / 0.01745329251994333;
*(float *)(a2 + 4LL * ((int)v24 + LODWORD(int_constants[5]) * v18)) = v16;
v18 += a1;
}
if ( a1 != ++v19 )
continue;
break;
}
LABEL_24:
if ( int_constants[5] > ++v24 )
continue;
break;
}
}

canonical_decompiled_code:
void __fastcall func3(int a1, __int64 a2)
{
int i; // esi
double v4; // xmm0_8
double v5; // xmm2_8
double v6; // xmm0_8
double v7; // xmm1_8
double v8; // xmm0_8
__int64 v9; // rax
__int64 v10; // rcx
float v11; // xmm1_4
float v12; // xmm0_4
int v13; // eax
int v14; // edx
int v15; // edx
float v16; // xmm0_4
int j; // ebx
int v18; // ebp
int v19; // er14
double v20; // [rsp+0h] [rbp-78h]
double x; // [rsp+8h] [rbp-70h]
double v22; // [rsp+10h] [rbp-68h]
double v23; // [rsp+18h] [rbp-60h]
__int64 v24; // [rsp+28h] [rbp-50h]
double cosx; // [rsp+30h] [rbp-48h] BYREF
double sinx[8]; // [rsp+38h] [rbp-40h] BYREF

if ( header[3] <= 98 )
{
if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
{
v4 = real_constants[1];
v5 = (double)i * v4 + real_constants[2];
v6 = v4 * 0.5;
v7 = v5 - v6;
v8 = v6 + v5;
v9 = int_constants[5];
if ( v9 > 0 )
{
v10 = 0LL;
v11 = v7;
v12 = v8;
do
{
v13 = v10 + i * v9;
*(float *)(a2 + 4LL * v13) = v11;
v14 = v13 + LODWORD(int_constants[5]) * a1;
*(float *)(a2 + 4LL * v14) = v12;
v15 = LODWORD(int_constants[5]) * a1 + v14;
*(float *)(a2 + 4LL * v15) = v12;
*(float *)(a2 + 4LL * (v15 + LODWORD(int_constants[5]) * a1)) = v11;
v9 = int_constants[5];
++v10;
}
while ( v9 > v10 );
}
}
}
return;
}
sincos(0.01745329251994333 * real_constants[4], sinx, &cosx);
v22 = cosx;
v23 = sinx[0];
v24 = 0LL;
if ( int_constants[5] <= 0 )
return;
while ( 2 )
{
v19 = 0;
if ( a1 <= 0 )
goto LABEL_24;
while ( 2 )
{
v18 = v19;
for ( j = 1; j != 5; ++j )
{
if ( j == 3 )
{
v20 = (((double)(int)v24 + 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 + 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
}
else
{
if ( j > 3 )
{
if ( j == 4 )
{
v20 = (((double)(int)v24 + 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 - 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
goto LABEL_15;
}
goto LABEL_14;
}
if ( j == 1 )
{
v20 = (((double)(int)v24 - 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 - 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
LABEL_14:
sincos(x, sinx, &cosx);
goto LABEL_15;
}
if ( j != 2 )
goto LABEL_14;
v20 = (((double)(int)v24 - 0.5) * real_constants[0] + real_constants[3]) * 0.01745329251994333;
x = (((double)v19 + 0.5) * real_constants[1] + real_constants[2]) * 0.01745329251994333;
sincos(x, sinx, &cosx);
}
LABEL_15:
v20 = cos(v20);
v16 = asin(v20 * cosx * v22 + v23 * sinx[0]) / 0.01745329251994333;
*(float *)(a2 + 4LL * ((int)v24 + LODWORD(int_constants[5]) * v18)) = v16;
v18 += a1;
}
if ( a1 != ++v19 )
continue;
break;
}
LABEL_24:
if ( int_constants[5] > ++v24 )
continue;
break;
}
}

original_code:
void construct_lat_bounds_array( int ny, float *lat ) {
     int i, j, k, ind;
     double tlat, tlon, degtorad, sock, cpart, t1, t2, latitude;
     double pseudolat, pseudolon, cos_pseudolat, sin_pseudolat;
     if ( header[3]<99 ) {
        for ( j=0; j<ny; j++ ) {
            tlat = real_constants[2] + real_constants[1]*((double ) j);
            t1 = tlat - 0.5*real_constants[1];
            t2 = tlat + 0.5*real_constants[1];
            for ( i=0; i<int_constants[5]; i++ ) {
                ind = j*int_constants[5] + i;
                lat[ind] = (float ) t1;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t2;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t2;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t1;
            }
        }
     } else {
        degtorad=3.1415926535898/180.0;
        pseudolat = real_constants[4] * degtorad;
        pseudolon = real_constants[5] * degtorad;
        cos_pseudolat = cos( pseudolat );
        sin_pseudolat = sin( pseudolat );
        if ( pseudolon==0 ) { sock = 0.0; }
        else { sock = pseudolon - 3.1415926535898; }
        for ( i=0; i<int_constants[5]; i++) {
        for ( j=0; j<ny; j++) {
        for ( k=1; k<5; k++ ) {
            switch( k ){
                  case 1:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 2:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 3:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 4:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
            }
            tlon = cos( tlon );
            cpart = tlon*cos(tlat);
            latitude = asin( cos_pseudolat*cpart + sin_pseudolat*sin(tlat) );
            ind = (k-1)*ny*int_constants[5] + int_constants[5]*j + i;
            lat[ind] = (float ) (latitude / degtorad);
        }
        }
        }
     }
     return;
}

canonical_original_code:
void construct_lat_bounds_array(int ny, float *lat) {
     int i; int j; int k; int ind;
     double tlat; double tlon; double degtorad; double sock; double cpart; double t1; double t2; double latitude;
     double pseudolat; double pseudolon; double cos_pseudolat; double sin_pseudolat;
     if ( header[3]<99 ) {
        for ( j=0; j<ny; j++ ) {
            tlat = real_constants[2] + real_constants[1]*((double ) j);
            t1 = tlat - 0.5*real_constants[1];
            t2 = tlat + 0.5*real_constants[1];
            for ( i=0; i<int_constants[5]; i++ ) {
                ind = j*int_constants[5] + i;
                lat[ind] = (float ) t1;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t2;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t2;
                ind += int_constants[5]*ny;
                lat[ind] = (float ) t1;
            }
        }
     } else {
        degtorad=3.1415926535898/180.0;
        pseudolat = real_constants[4] * degtorad;
        pseudolon = real_constants[5] * degtorad;
        cos_pseudolat = cos( pseudolat );
        sin_pseudolat = sin( pseudolat );
        if ( pseudolon==0 ) { sock = 0.0; }
        else { sock = pseudolon - 3.1415926535898; }
        for ( i=0; i<int_constants[5]; i++) {
        for ( j=0; j<ny; j++) {
        for ( k=1; k<5; k++ ) {
            switch( k ){
                  case 1:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 2:
                       tlon = ( real_constants[3] + ((double ) i - 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 3:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j + 0.5)*real_constants[1] )*degtorad;
                       break;
                  case 4:
                       tlon = ( real_constants[3] + ((double ) i + 0.5)*real_constants[0] )*degtorad;
                       tlat = ( real_constants[2] + ((double ) j - 0.5)*real_constants[1] )*degtorad;
                       break;
            }
            tlon = cos( tlon );
            cpart = tlon*cos(tlat);
            latitude = asin( cos_pseudolat*cpart + sin_pseudolat*sin(tlat) );
            ind = (k-1)*ny*int_constants[5] + int_constants[5]*j + i;
            lat[ind] = (float ) (latitude / degtorad);
        }
        }
        }
     }
     return;
}

variable_types: ny int

variable_types:
lat
float *

variable_types: j int

variable_types: ind int

variable_types: tlat double

variable_types: tlon double

variable_types: degtorad double

variable_types: sock double

variable_types: cpart double

variable_types: latitude double

variable_types: pseudolat double

variable_types: pseudolon double

return_type: void


decompiled_code:
void __fastcall construct_lat_lon_arrays(unsigned int a1)
{
__int64 v1; // r12
void *v2; // rbp
void *v3; // rbp
int v4; // er12
__int64 v5; // r13
void *v6; // rbp
void *v7; // rbp
__int64 v8; // [rsp+0h] [rbp-38h] BYREF
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = int_constants[6];
v2 = malloc(4 * int_constants[5] * (int)v1);
construct_lon_array(v1, (__int64)v2);
nc_inq_varid(a1, "longitude", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v2);
construct_lat_array(v1, (__int64)v2);
nc_inq_varid(a1, "latitude", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v2);
free(v2);
v3 = malloc(16 * int_constants[5] * (int)v1);
construct_lon_bounds_array(v1, (__int64)v3);
nc_inq_varid(a1, "longitude_cell_bnd", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v3);
construct_lat_bounds_array(v1, (__int64)v3);
nc_inq_varid(a1, "latitude_cell_bnd", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v3);
free(v3);
if ( !(unsigned int)nc_inq_dimid(a1, "rlat0", &v9) )
{
nc_inq_dimlen(a1, v9, &v8);
v4 = v8;
v5 = (int)v8;
v6 = malloc(4 * int_constants[5] * (int)v8);
construct_lon_array(v4, (__int64)v6);
nc_inq_varid(a1, "longitude0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v6);
construct_lat_array(v4, (__int64)v6);
nc_inq_varid(a1, "latitude0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v6);
free(v6);
v7 = malloc(16 * int_constants[5] * v5);
construct_lon_bounds_array(v4, (__int64)v7);
nc_inq_varid(a1, "longitude_cell_bnd0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v7);
construct_lat_bounds_array(v4, (__int64)v7);
nc_inq_varid(a1, "latitude_cell_bnd0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v7);
free(v7);
}
}

canonical_decompiled_code:
void __fastcall func4(unsigned int a1)
{
__int64 v1; // r12
void *v2; // rbp
void *v3; // rbp
int v4; // er12
__int64 v5; // r13
void *v6; // rbp
void *v7; // rbp
__int64 v8; // [rsp+0h] [rbp-38h] BYREF
unsigned int v9; // [rsp+8h] [rbp-30h] BYREF
int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = int_constants[6];
v2 = malloc(4 * int_constants[5] * (int)v1);
func0(v1, (__int64)v2);
nc_inq_varid(a1, "longitude", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v2);
func1(v1, (__int64)v2);
nc_inq_varid(a1, "latitude", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v2);
free(v2);
v3 = malloc(16 * int_constants[5] * (int)v1);
func2(v1, (__int64)v3);
nc_inq_varid(a1, "longitude_cell_bnd", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v3);
func3(v1, (__int64)v3);
nc_inq_varid(a1, "latitude_cell_bnd", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v3);
free(v3);
if ( !(unsigned int)nc_inq_dimid(a1, "rlat0", &v9) )
{
nc_inq_dimlen(a1, v9, &v8);
v4 = v8;
v5 = (int)v8;
v6 = malloc(4 * int_constants[5] * (int)v8);
func0(v4, (__int64)v6);
nc_inq_varid(a1, "longitude0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v6);
func1(v4, (__int64)v6);
nc_inq_varid(a1, "latitude0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v6);
free(v6);
v7 = malloc(16 * int_constants[5] * v5);
func2(v4, (__int64)v7);
nc_inq_varid(a1, "longitude_cell_bnd0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v7);
func3(v4, (__int64)v7);
nc_inq_varid(a1, "latitude_cell_bnd0", v10);
nc_put_var_float(a1, (unsigned int)v10[0], v7);
free(v7);
}
}

original_code:
void construct_lat_lon_arrays( int ncid ) {
     int varID, ierr, ny, dimid;
     float *buf;
     size_t dimlength;
     ny = (int ) int_constants[6];
     buf = (float *) malloc( int_constants[5]*ny*sizeof(float) );
     construct_lon_array( ny, buf );
     ierr = nc_inq_varid( ncid, "longitude", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     construct_lat_array( ny, buf );
     ierr = nc_inq_varid( ncid, "latitude", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     free( buf );
     buf = (float *) malloc( 4*int_constants[5]*ny*sizeof(float) );
     construct_lon_bounds_array( ny, buf );
     ierr = nc_inq_varid( ncid, "longitude_cell_bnd", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     construct_lat_bounds_array( ny, buf );
     ierr = nc_inq_varid( ncid, "latitude_cell_bnd", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     free( buf );
     ierr = nc_inq_dimid( ncid, "rlat0", &dimid );
     if ( ierr==0 ) {
        ierr = nc_inq_dimlen( ncid, dimid, &dimlength );
        ny = (int ) dimlength;
        buf = (float *) malloc( int_constants[5]*ny*sizeof(float) );
        construct_lon_array( ny, buf );
        ierr = nc_inq_varid( ncid, "longitude0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        construct_lat_array( ny, buf );
        ierr = nc_inq_varid( ncid, "latitude0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        free( buf );
        buf = (float *) malloc( 4*int_constants[5]*ny*sizeof(float) );
        construct_lon_bounds_array( ny, buf );
        ierr = nc_inq_varid( ncid, "longitude_cell_bnd0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        construct_lat_bounds_array( ny, buf );
        ierr = nc_inq_varid( ncid, "latitude_cell_bnd0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        free( buf );
     }
     return;
}

canonical_original_code:
void construct_lat_lon_arrays(int ncid) {
     int varID; int ierr; int ny; int dimid;
     float *buf;
     unsigned long dimlength;
     ny = (int ) int_constants[6];
     buf = (float *) malloc( int_constants[5]*ny*sizeof(float) );
     construct_lon_array( ny, buf );
     ierr = nc_inq_varid( ncid, "longitude", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     construct_lat_array( ny, buf );
     ierr = nc_inq_varid( ncid, "latitude", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     free( buf );
     buf = (float *) malloc( 4*int_constants[5]*ny*sizeof(float) );
     construct_lon_bounds_array( ny, buf );
     ierr = nc_inq_varid( ncid, "longitude_cell_bnd", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     construct_lat_bounds_array( ny, buf );
     ierr = nc_inq_varid( ncid, "latitude_cell_bnd", &varID );
     ierr = nc_put_var_float( ncid, varID, buf );
     free( buf );
     ierr = nc_inq_dimid( ncid, "rlat0", &dimid );
     if ( ierr==0 ) {
        ierr = nc_inq_dimlen( ncid, dimid, &dimlength );
        ny = (int ) dimlength;
        buf = (float *) malloc( int_constants[5]*ny*sizeof(float) );
        construct_lon_array( ny, buf );
        ierr = nc_inq_varid( ncid, "longitude0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        construct_lat_array( ny, buf );
        ierr = nc_inq_varid( ncid, "latitude0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        free( buf );
        buf = (float *) malloc( 4*int_constants[5]*ny*sizeof(float) );
        construct_lon_bounds_array( ny, buf );
        ierr = nc_inq_varid( ncid, "longitude_cell_bnd0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        construct_lat_bounds_array( ny, buf );
        ierr = nc_inq_varid( ncid, "latitude_cell_bnd0", &varID );
        ierr = nc_put_var_float( ncid, varID, buf );
        free( buf );
     }
     return;
}

variable_types: ncid int

variable_types: varID int

variable_types: ierr int

variable_types: dimid int

variable_types:
buf
float *

variable_types:
dimlength
unsigned long


decompiled_code:
__int64 __fastcall set_soil_levels(unsigned int a1, int a2, int a3)
{
void *v6; // rax
float *v7; // rcx
void *v8; // rbp
__int64 v9; // rdi
__int64 v10; // r9
__int64 v11; // rdx
float v12; // xmm0_4
char s[12]; // [rsp+Ch] [rbp-3Ch] BYREF
unsigned int v14; // [rsp+18h] [rbp-30h] BYREF
unsigned int v15[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "soil_level%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v14) )
return v14;
nc_def_dim(a1, s, a2, &v14);
nc_def_var(a1, s, 5LL, 1LL, &v14, v15);
nc_put_att_text(a1, v15[0], "standard_name", 5LL, "depth");
nc_put_att_text(a1, v15[0], "units", 6LL, "meters");
nc_put_att_text(a1, v15[0], "positive", 4LL, "down");
nc_put_att_text(a1, v15[0], "axis", 1LL, "Z");
nc_enddef(a1);
v6 = calloc(a2, 4uLL);
v8 = v6;
if ( a2 > 0 )
{
v9 = stored_um_vars + 144LL * a3;
v10 = level_constants;
v7 = (float *)v6;
v11 = 0LL;
do
{
v12 = *(double *)(*(_QWORD *)(v10 + 24) + 8LL * (*(unsigned __int16 *)(**(_QWORD **)(v9 + 128) + v11 + 2) - 1));
*v7 = v12;
v11 += 160LL;
++v7;
}
while ( v11 != 160LL * (unsigned int)a2 );
}
nc_put_var_float(a1, v15[0], v6, v7);
free(v8);
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2, int a3)
{
void *v6; // rax
float *v7; // rcx
void *v8; // rbp
__int64 v9; // rdi
__int64 v10; // r9
__int64 v11; // rdx
float v12; // xmm0_4
char s[12]; // [rsp+Ch] [rbp-3Ch] BYREF
unsigned int v14; // [rsp+18h] [rbp-30h] BYREF
unsigned int v15[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "soil_level%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v14) )
return v14;
nc_def_dim(a1, s, a2, &v14);
nc_def_var(a1, s, 5LL, 1LL, &v14, v15);
nc_put_att_text(a1, v15[0], "standard_name", 5LL, "depth");
nc_put_att_text(a1, v15[0], "units", 6LL, "meters");
nc_put_att_text(a1, v15[0], "positive", 4LL, "down");
nc_put_att_text(a1, v15[0], "axis", 1LL, "Z");
nc_enddef(a1);
v6 = calloc(a2, 4uLL);
v8 = v6;
if ( a2 > 0 )
{
v9 = stored_um_vars + 144LL * a3;
v10 = level_constants;
v7 = (float *)v6;
v11 = 0LL;
do
{
v12 = *(double *)(*(_QWORD *)(v10 + 24) + 8LL * (*(unsigned __int16 *)(**(_QWORD **)(v9 + 128) + v11 + 2) - 1));
*v7 = v12;
v11 += 160LL;
++v7;
}
while ( v11 != 160LL * (unsigned int)a2 );
}
nc_put_var_float(a1, v15[0], v6, v7);
free(v8);
return v14;
}

original_code:
int set_soil_levels( int ncid, int n, int id ) {
     int ierr, i, var_id, dim_id[1], nn;
     char dim_name[12];
     float *buf;
     sprintf( dim_name, "soil_level%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr == 0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 5, "depth" );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 4, "down" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) calloc( n,sizeof(float) );
     for ( i=0; i<n; i++ ) {
         nn = (int ) (stored_um_vars[id].slices[0][i].level - 1);
         buf[i] = (float ) level_constants[3][nn];
     }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}

canonical_original_code:
int set_soil_levels(int ncid, int n, int id) {
     int ierr; int i; int var_id; int dim_id[1]; int nn;
     char dim_name[12];
     float *buf;
     sprintf( dim_name, "soil_level%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr == 0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 5, "depth" );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 4, "down" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) calloc( n,sizeof(float) );
     for ( i=0; i<n; i++ ) {
         nn = (int ) (stored_um_vars[id].slices[0][i].level - 1);
         buf[i] = (float ) level_constants[3][nn];
     }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}

variable_types: n int

variable_types: id int

variable_types: i int

variable_types: nn int

return_type: int


decompiled_code:
__int64 __fastcall set_pressure_levels(unsigned int a1, int a2, int a3)
{
__int64 v5; // r13
__int64 i; // rbx
__int64 v7; // [rsp+0h] [rbp-48h] BYREF
float v8; // [rsp+8h] [rbp-40h] BYREF
char s[10]; // [rsp+Eh] [rbp-3Ah] BYREF
unsigned int v10; // [rsp+18h] [rbp-30h] BYREF
unsigned int v11[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "pressure%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v10) )
return v10;
nc_def_dim(a1, s, a2, &v10);
nc_def_var(a1, s, 5LL, 1LL, &v10, v11);
nc_put_att_text(a1, v11[0], "units", 2LL, "Pa");
nc_put_att_text(a1, v11[0], "axis", 1LL, "Z");
nc_put_att_text(a1, v11[0], "standard_name", 12LL, "air_pressure");
nc_put_att_text(a1, v11[0], "positive", 4LL, "down");
nc_put_att_text(a1, v11[0], "long_name", 23LL, "standard level pressure");
nc_enddef(a1);
if ( a2 > 0 )
{
v5 = 144LL * a3;
for ( i = 0LL; i != a2; ++i )
{
v8 = (float)*(unsigned __int16 *)(**(_QWORD **)(stored_um_vars + v5 + 128) + 160 * i + 2);
v7 = i;
nc_put_var1_float(a1, v11[0], &v7, &v8);
}
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, int a2, int a3)
{
__int64 v5; // r13
__int64 i; // rbx
__int64 v7; // [rsp+0h] [rbp-48h] BYREF
float v8; // [rsp+8h] [rbp-40h] BYREF
char s[10]; // [rsp+Eh] [rbp-3Ah] BYREF
unsigned int v10; // [rsp+18h] [rbp-30h] BYREF
unsigned int v11[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "pressure%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v10) )
return v10;
nc_def_dim(a1, s, a2, &v10);
nc_def_var(a1, s, 5LL, 1LL, &v10, v11);
nc_put_att_text(a1, v11[0], "units", 2LL, "Pa");
nc_put_att_text(a1, v11[0], "axis", 1LL, "Z");
nc_put_att_text(a1, v11[0], "standard_name", 12LL, "air_pressure");
nc_put_att_text(a1, v11[0], "positive", 4LL, "down");
nc_put_att_text(a1, v11[0], "long_name", 23LL, "standard level pressure");
nc_enddef(a1);
if ( a2 > 0 )
{
v5 = 144LL * a3;
for ( i = 0LL; i != a2; ++i )
{
v8 = (float)*(unsigned __int16 *)(**(_QWORD **)(stored_um_vars + v5 + 128) + 160 * i + 2);
v7 = i;
nc_put_var1_float(a1, v11[0], &v7, &v8);
}
}
return v10;
}

original_code:
int set_pressure_levels( int ncid, int n, int id ) {
     int i, ierr, var_id, dim_id[1];
     char dim_name[10];
     float pressure;
     size_t nc_index[1];
     sprintf( dim_name, "pressure%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 2, "Pa" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 12, "air_pressure" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 4, "down" );
     ierr = nc_put_att_text( ncid, var_id, "long_name", 23, "standard level pressure" );
     ierr = nc_enddef( ncid );
     for ( i=0; i<n; i++ ) {
         pressure = (float ) stored_um_vars[id].slices[0][i].level;
         nc_index[0] = (size_t) i;
         ierr = nc_put_var1_float( ncid, var_id, nc_index, &pressure );
     }
     return dim_id[0];
}

canonical_original_code:
int set_pressure_levels(int ncid, int n, int id) {
     int i; int ierr; int var_id; int dim_id[1];
     char dim_name[10];
     float pressure;
     unsigned long nc_index[1];
     sprintf( dim_name, "pressure%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 2, "Pa" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 12, "air_pressure" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 4, "down" );
     ierr = nc_put_att_text( ncid, var_id, "long_name", 23, "standard level pressure" );
     ierr = nc_enddef( ncid );
     for ( i=0; i<n; i++ ) {
         pressure = (float ) stored_um_vars[id].slices[0][i].level;
         nc_index[0] = (unsigned long) i;
         ierr = nc_put_var1_float( ncid, var_id, nc_index, &pressure );
     }
     return dim_id[0];
}

variable_types: pressure float


decompiled_code:
__int64 __fastcall set_altitude(unsigned int a1, int a2, int a3)
{
__int64 v5; // r13
__int64 i; // rbx
__int64 v7; // [rsp+0h] [rbp-48h] BYREF
float v8; // [rsp+8h] [rbp-40h] BYREF
char s[10]; // [rsp+Eh] [rbp-3Ah] BYREF
unsigned int v10; // [rsp+18h] [rbp-30h] BYREF
unsigned int v11[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "altitude%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v10) )
return v10;
nc_def_dim(a1, s, a2, &v10);
nc_def_var(a1, s, 5LL, 1LL, &v10, v11);
nc_put_att_text(a1, v11[0], "units", 1LL, "m");
nc_put_att_text(a1, v11[0], "axis", 1LL, "Z");
nc_put_att_text(a1, v11[0], "standard_name", 8LL, "altitude");
nc_put_att_text(a1, v11[0], "positive", 2LL, "up");
nc_put_att_text(a1, v11[0], "long_name", 22LL, "height above sea level");
nc_enddef(a1);
if ( a2 > 0 )
{
v5 = 144LL * a3;
for ( i = 0LL; i != a2; ++i )
{
v8 = (float)*(unsigned __int16 *)(**(_QWORD **)(stored_um_vars + v5 + 128) + 160 * i + 2);
v7 = i;
nc_put_var1_float(a1, v11[0], &v7, &v8);
}
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, int a2, int a3)
{
__int64 v5; // r13
__int64 i; // rbx
__int64 v7; // [rsp+0h] [rbp-48h] BYREF
float v8; // [rsp+8h] [rbp-40h] BYREF
char s[10]; // [rsp+Eh] [rbp-3Ah] BYREF
unsigned int v10; // [rsp+18h] [rbp-30h] BYREF
unsigned int v11[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

sprintf(s, "altitude%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v10) )
return v10;
nc_def_dim(a1, s, a2, &v10);
nc_def_var(a1, s, 5LL, 1LL, &v10, v11);
nc_put_att_text(a1, v11[0], "units", 1LL, "m");
nc_put_att_text(a1, v11[0], "axis", 1LL, "Z");
nc_put_att_text(a1, v11[0], "standard_name", 8LL, "altitude");
nc_put_att_text(a1, v11[0], "positive", 2LL, "up");
nc_put_att_text(a1, v11[0], "long_name", 22LL, "height above sea level");
nc_enddef(a1);
if ( a2 > 0 )
{
v5 = 144LL * a3;
for ( i = 0LL; i != a2; ++i )
{
v8 = (float)*(unsigned __int16 *)(**(_QWORD **)(stored_um_vars + v5 + 128) + 160 * i + 2);
v7 = i;
nc_put_var1_float(a1, v11[0], &v7, &v8);
}
}
return v10;
}

original_code:
int set_altitude( int ncid, int n, int id ) {
     int i, ierr, var_id, dim_id[1];
     char dim_name[10];
     float height;
     size_t nc_index[1];
     sprintf( dim_name, "altitude%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 1, "m" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 8, "altitude" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "long_name", 22, "height above sea level" );
     ierr = nc_enddef( ncid );
     for ( i=0; i<n; i++ ) {
         height = (float ) stored_um_vars[id].slices[0][i].level;
         nc_index[0] = (size_t) i;
         ierr = nc_put_var1_float( ncid, var_id, nc_index, &height );
     }
     return dim_id[0];
}

canonical_original_code:
int set_altitude(int ncid, int n, int id) {
     int i; int ierr; int var_id; int dim_id[1];
     char dim_name[10];
     float height;
     unsigned long nc_index[1];
     sprintf( dim_name, "altitude%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 1, "m" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_put_att_text( ncid, var_id,"standard_name", 8, "altitude" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "long_name", 22, "height above sea level" );
     ierr = nc_enddef( ncid );
     for ( i=0; i<n; i++ ) {
         height = (float ) stored_um_vars[id].slices[0][i].level;
         nc_index[0] = (unsigned long) i;
         ierr = nc_put_var1_float( ncid, var_id, nc_index, &height );
     }
     return dim_id[0];
}

variable_types: height float


decompiled_code:
__int64 __fastcall set_hybrid_levels(unsigned int a1, int a2, int a3)
{
__int64 v3; // rbx
float *v5; // r12
__int64 v6; // rbx
__int64 v7; // r8
float *v8; // rdx
__int64 v9; // rax
float v10; // xmm0_4
__int64 v11; // rcx
__int64 v12; // rbx
__int64 v13; // r8
float *v14; // rcx
__int64 v15; // rdx
float v16; // xmm0_4
char s[9]; // [rsp+Fh] [rbp-39h] BYREF
unsigned int v18; // [rsp+18h] [rbp-30h] BYREF
unsigned int v19[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v3 = 144LL * a3;
if ( *(_WORD *)(stored_um_vars + v3 + 88) == 1 )
sprintf(s, "hybridr%d", (unsigned int)a2);
else
sprintf(s, "hybridt%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v18) )
return v18;
nc_def_dim(a1, s, a2, &v18);
nc_def_var(a1, s, 5LL, 1LL, &v18, v19);
nc_put_att_text(a1, v19[0], "units", 6LL, "meters");
nc_put_att_text(a1, v19[0], "positive", 2LL, "up");
nc_put_att_text(a1, v19[0], "axis", 1LL, "Z");
if ( (unsigned __int16)(*(_WORD *)(stored_um_vars + v3 + 88) - 1) > 1u )
{
printf("WARNING: unknown vertical mesh type for STASH_CODE=%hu\n", *(unsigned __int16 *)(stored_um_vars + v3 + 56));
puts(" setting to theta-point mesh by default");
}
v5 = (float *)malloc(4LL * a2);
if ( *(_WORD *)(stored_um_vars + v3 + 88) == 1 )
{
nc_put_att_text(a1, v19[0], "long_name", 40LL, "height above sea level (rho levels used)");
if ( a2 > 0 )
{
v12 = stored_um_vars + v3;
v13 = level_constants;
v14 = v5;
v15 = 0LL;
do
{
v16 = *(double *)(*(_QWORD *)(v13 + 48) + 8LL * (*(unsigned __int16 *)(**(_QWORD **)(v12 + 128) + v15 + 2) - 1));
*v14 = v16;
v15 += 160LL;
++v14;
}
while ( v15 != 160LL * (unsigned int)a2 );
}
}
else
{
nc_put_att_text(a1, v19[0], "long_name", 42LL, "height above sea level (theta levels used)");
if ( a2 > 0 )
{
v6 = stored_um_vars + v3;
v7 = level_constants;
v8 = v5;
v9 = 0LL;
do
{
v10 = *(double *)(*(_QWORD *)(v7 + 32) + 8LL * *(unsigned __int16 *)(**(_QWORD **)(v6 + 128) + v9 + 2));
*v8 = v10;
v9 += 160LL;
++v8;
}
while ( v9 != 160LL * (unsigned int)a2 );
}
}
nc_enddef(a1);
nc_put_var_float(a1, v19[0], v5, v11);
free(v5);
return v18;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, int a2, int a3)
{
__int64 v3; // rbx
float *v5; // r12
__int64 v6; // rbx
__int64 v7; // r8
float *v8; // rdx
__int64 v9; // rax
float v10; // xmm0_4
__int64 v11; // rcx
__int64 v12; // rbx
__int64 v13; // r8
float *v14; // rcx
__int64 v15; // rdx
float v16; // xmm0_4
char s[9]; // [rsp+Fh] [rbp-39h] BYREF
unsigned int v18; // [rsp+18h] [rbp-30h] BYREF
unsigned int v19[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v3 = 144LL * a3;
if ( *(_WORD *)(stored_um_vars + v3 + 88) == 1 )
sprintf(s, "hybridr%d", (unsigned int)a2);
else
sprintf(s, "hybridt%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v18) )
return v18;
nc_def_dim(a1, s, a2, &v18);
nc_def_var(a1, s, 5LL, 1LL, &v18, v19);
nc_put_att_text(a1, v19[0], "units", 6LL, "meters");
nc_put_att_text(a1, v19[0], "positive", 2LL, "up");
nc_put_att_text(a1, v19[0], "axis", 1LL, "Z");
if ( (unsigned __int16)(*(_WORD *)(stored_um_vars + v3 + 88) - 1) > 1u )
{
printf("WARNING: unknown vertical mesh type for STASH_CODE=%hu\n", *(unsigned __int16 *)(stored_um_vars + v3 + 56));
puts(" setting to theta-point mesh by default");
}
v5 = (float *)malloc(4LL * a2);
if ( *(_WORD *)(stored_um_vars + v3 + 88) == 1 )
{
nc_put_att_text(a1, v19[0], "long_name", 40LL, "height above sea level (rho levels used)");
if ( a2 > 0 )
{
v12 = stored_um_vars + v3;
v13 = level_constants;
v14 = v5;
v15 = 0LL;
do
{
v16 = *(double *)(*(_QWORD *)(v13 + 48) + 8LL * (*(unsigned __int16 *)(**(_QWORD **)(v12 + 128) + v15 + 2) - 1));
*v14 = v16;
v15 += 160LL;
++v14;
}
while ( v15 != 160LL * (unsigned int)a2 );
}
}
else
{
nc_put_att_text(a1, v19[0], "long_name", 42LL, "height above sea level (theta levels used)");
if ( a2 > 0 )
{
v6 = stored_um_vars + v3;
v7 = level_constants;
v8 = v5;
v9 = 0LL;
do
{
v10 = *(double *)(*(_QWORD *)(v7 + 32) + 8LL * *(unsigned __int16 *)(**(_QWORD **)(v6 + 128) + v9 + 2));
*v8 = v10;
v9 += 160LL;
++v8;
}
while ( v9 != 160LL * (unsigned int)a2 );
}
}
nc_enddef(a1);
nc_put_var_float(a1, v19[0], v5, v11);
free(v5);
return v18;
}

original_code:
int set_hybrid_levels( int ncid, int n, int id ) {
     int i, ierr, var_id, dim_id[1], z_level;
     char dim_name[9];
     float *height;
     if ( stored_um_vars[id].level_type==1 ) { sprintf( dim_name, "hybridr%d", n ); }
     else { sprintf( dim_name, "hybridt%d", n ); }
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
    if ( (stored_um_vars[id].level_type!=1)&&(stored_um_vars[id].level_type!=2) ) {
       printf( "WARNING: unknown vertical mesh type for STASH_CODE=%hu\n", stored_um_vars[id].stash_code );
       printf( "         setting to theta-point mesh by default\n" );
    }
     height = (float *) malloc( n*sizeof(float) );
     if ( stored_um_vars[id].level_type==1 ) {
        ierr = nc_put_att_text( ncid, var_id, "long_name", 40, "height above sea level (rho levels used)" );
        for ( i=0; i<n; i++ ) {
            z_level = (int ) stored_um_vars[id].slices[0][i].level - 1;
            height[i] = (float ) level_constants[6][z_level];
         }
     }
     else {
        ierr = nc_put_att_text( ncid, var_id, "long_name", 42, "height above sea level (theta levels used)" );
        for ( i=0; i<n; i++ ) {
            z_level = (int ) stored_um_vars[id].slices[0][i].level;
            height[i] = (float ) level_constants[4][z_level];
         }
     }
     ierr = nc_enddef( ncid );
     ierr = nc_put_var_float( ncid, var_id, height );
     free( height );
     return dim_id[0];
}

canonical_original_code:
int set_hybrid_levels(int ncid, int n, int id) {
     int i; int ierr; int var_id; int dim_id[1]; int z_level;
     char dim_name[9];
     float *height;
     if ( stored_um_vars[id].level_type==1 ) { sprintf( dim_name, "hybridr%d", n ); }
     else { sprintf( dim_name, "hybridt%d", n ); }
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
    if ( (stored_um_vars[id].level_type!=1)&&(stored_um_vars[id].level_type!=2) ) {
       printf( "WARNING: unknown vertical mesh type for STASH_CODE=%hu\n", stored_um_vars[id].stash_code );
       printf( "         setting to theta-point mesh by default\n" );
    }
     height = (float *) malloc( n*sizeof(float) );
     if ( stored_um_vars[id].level_type==1 ) {
        ierr = nc_put_att_text( ncid, var_id, "long_name", 40, "height above sea level (rho levels used)" );
        for ( i=0; i<n; i++ ) {
            z_level = (int ) stored_um_vars[id].slices[0][i].level - 1;
            height[i] = (float ) level_constants[6][z_level];
         }
     }
     else {
        ierr = nc_put_att_text( ncid, var_id, "long_name", 42, "height above sea level (theta levels used)" );
        for ( i=0; i<n; i++ ) {
            z_level = (int ) stored_um_vars[id].slices[0][i].level;
            height[i] = (float ) level_constants[4][z_level];
         }
     }
     ierr = nc_enddef( ncid );
     ierr = nc_put_var_float( ncid, var_id, height );
     free( height );
     return dim_id[0];
}

variable_types:
height
float *


decompiled_code:
__int64 __fastcall set_surface_levels(unsigned int a1, int a2)
{
__int64 v3; // rcx
float *v4; // r12
__int64 i; // rax
char s[9]; // [rsp+Fh] [rbp-29h] BYREF
unsigned int v7; // [rsp+18h] [rbp-20h] BYREF
unsigned int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

sprintf(s, "surface%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v7) )
return v7;
nc_def_dim(a1, s, a2, &v7);
nc_def_var(a1, s, 5LL, 1LL, &v7, v8);
nc_put_att_text(a1, v8[0], "axis", 1LL, "Z");
nc_enddef(a1);
v4 = (float *)malloc(4LL * a2);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = (float)(int)i;
}
nc_put_var_float(a1, v8[0], v4, v3);
free(v4);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, int a2)
{
__int64 v3; // rcx
float *v4; // r12
__int64 i; // rax
char s[9]; // [rsp+Fh] [rbp-29h] BYREF
unsigned int v7; // [rsp+18h] [rbp-20h] BYREF
unsigned int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

sprintf(s, "surface%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v7) )
return v7;
nc_def_dim(a1, s, a2, &v7);
nc_def_var(a1, s, 5LL, 1LL, &v7, v8);
nc_put_att_text(a1, v8[0], "axis", 1LL, "Z");
nc_enddef(a1);
v4 = (float *)malloc(4LL * a2);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = (float)(int)i;
}
nc_put_var_float(a1, v8[0], v4, v3);
free(v4);
return v7;
}

original_code:
int set_surface_levels( int ncid, int n, int id ) {
     int i, ierr, var_id, dim_id[1];
     char dim_name[9];
     float *buf;
     sprintf( dim_name, "surface%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) malloc( n*sizeof(float) );
     for ( i=0; i<n; i++ ) { buf[i] = (float ) i; }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}

canonical_original_code:
int set_surface_levels(int ncid, int n, int id) {
     int i; int ierr; int var_id; int dim_id[1];
     char dim_name[9];
     float *buf;
     sprintf( dim_name, "surface%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) malloc( n*sizeof(float) );
     for ( i=0; i<n; i++ ) { buf[i] = (float ) i; }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}


decompiled_code:
__int64 __fastcall set_sea_surface_levels(unsigned int a1, int a2)
{
__int64 v3; // rcx
float *v4; // r12
__int64 i; // rax
char s[13]; // [rsp+Bh] [rbp-2Dh] BYREF
unsigned int v7; // [rsp+18h] [rbp-20h] BYREF
unsigned int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

sprintf(s, "sea_surface%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v7) )
return v7;
nc_def_dim(a1, s, a2, &v7);
nc_def_var(a1, s, 5LL, 1LL, &v7, v8);
nc_put_att_text(a1, v8[0], "units", 6LL, "meters");
nc_put_att_text(a1, v8[0], "positive", 2LL, "up");
nc_put_att_text(a1, v8[0], "axis", 1LL, "Z");
nc_enddef(a1);
v4 = (float *)malloc(4LL * a2);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = (float)(int)i;
}
nc_put_var_float(a1, v8[0], v4, v3);
free(v4);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, int a2)
{
__int64 v3; // rcx
float *v4; // r12
__int64 i; // rax
char s[13]; // [rsp+Bh] [rbp-2Dh] BYREF
unsigned int v7; // [rsp+18h] [rbp-20h] BYREF
unsigned int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

sprintf(s, "sea_surface%d", (unsigned int)a2);
if ( !(unsigned int)nc_inq_dimid(a1, s, &v7) )
return v7;
nc_def_dim(a1, s, a2, &v7);
nc_def_var(a1, s, 5LL, 1LL, &v7, v8);
nc_put_att_text(a1, v8[0], "units", 6LL, "meters");
nc_put_att_text(a1, v8[0], "positive", 2LL, "up");
nc_put_att_text(a1, v8[0], "axis", 1LL, "Z");
nc_enddef(a1);
v4 = (float *)malloc(4LL * a2);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
v4[i] = (float)(int)i;
}
nc_put_var_float(a1, v8[0], v4, v3);
free(v4);
return v7;
}

original_code:
int set_sea_surface_levels( int ncid, int n, int id ) {
     int i, ierr, var_id, dim_id[1];
     char dim_name[13];
     float *buf;
     sprintf( dim_name, "sea_surface%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) malloc( n*sizeof(float) );
     for ( i=0; i<n; i++ ) { buf[i] = (float ) i; }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}

canonical_original_code:
int set_sea_surface_levels(int ncid, int n, int id) {
     int i; int ierr; int var_id; int dim_id[1];
     char dim_name[13];
     float *buf;
     sprintf( dim_name, "sea_surface%d", n );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_id[0] );
     if ( ierr==0 ) { return dim_id[0]; }
     ierr = nc_def_dim( ncid, dim_name, n, &dim_id[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dim_id, &var_id );
     ierr = nc_put_att_text( ncid, var_id, "units", 6, "meters" );
     ierr = nc_put_att_text( ncid, var_id, "positive", 2, "up" );
     ierr = nc_put_att_text( ncid, var_id, "axis", 1, "Z" );
     ierr = nc_enddef( ncid );
     buf = (float *) malloc( n*sizeof(float) );
     for ( i=0; i<n; i++ ) { buf[i] = (float ) i; }
     ierr = nc_put_var_float( ncid, var_id, buf );
     free( buf );
     return dim_id[0];
}


decompiled_code:
__int64 __fastcall set_vertical_dimensions(unsigned int a1)
{
__int64 v1; // rbx
__int16 v2; // r12
unsigned __int16 *v3; // rdx
int v4; // eax
unsigned __int16 v5; // si
int v7[11]; // [rsp+Ch] [rbp-2Ch] BYREF

if ( num_stored_um_fields > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
v3 = (unsigned __int16 *)(stored_um_vars + 144 * v1);
v4 = v3[31];
v7[0] = v4;
if ( v4 <= 1 )
{
v3[41] = 999;
goto LABEL_6;
}
v5 = v3[34];
if ( v5 == 65 )
{
v2 = set_hybrid_levels(a1, v4, v1);
}
else if ( v5 > 0x41u )
{
if ( v5 == 128 )
{
v2 = set_sea_surface_levels(a1, v4);
}
else
{
if ( v5 != 129 )
{
LABEL_19:
printf("ERROR: unknown vertical coordinate (%hu) for STASH CODE=%d\n\n", v5, v3[28]);
goto LABEL_5;
}
v2 = set_surface_levels(a1, v4);
}
}
else
{
switch ( v5 )
{
case 6u:
v2 = set_soil_levels(a1, v4, v1);
break;
case 8u:
v2 = set_pressure_levels(a1, v4, v1);
break;
case 1u:
v2 = set_altitude(a1, v4, v1);
break;
default:
goto LABEL_19;
}
}
LABEL_5:
*(_WORD *)(stored_um_vars + 144 * v1 + 82) = v2;
LABEL_6:
++v1;
}
while ( num_stored_um_fields > (int)v1 );
}
nc_def_dim(a1, "num_etaT_levels", header[110], v7);
return nc_def_dim(a1, "num_etaR_levels", header[110] - 1LL, v7);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
__int64 v1; // rbx
__int16 v2; // r12
unsigned __int16 *v3; // rdx
int v4; // eax
unsigned __int16 v5; // si
int v7[11]; // [rsp+Ch] [rbp-2Ch] BYREF

if ( num_stored_um_fields > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
v3 = (unsigned __int16 *)(stored_um_vars + 144 * v1);
v4 = v3[31];
v7[0] = v4;
if ( v4 <= 1 )
{
v3[41] = 999;
goto LABEL_6;
}
v5 = v3[34];
if ( v5 == 65 )
{
v2 = func3(a1, v4, v1);
}
else if ( v5 > 0x41u )
{
if ( v5 == 128 )
{
v2 = func5(a1, v4);
}
else
{
if ( v5 != 129 )
{
LABEL_19:
printf("ERROR: unknown vertical coordinate (%hu) for STASH CODE=%d\n\n", v5, v3[28]);
goto LABEL_5;
}
v2 = func4(a1, v4);
}
}
else
{
switch ( v5 )
{
case 6u:
v2 = func0(a1, v4, v1);
break;
case 8u:
v2 = func1(a1, v4, v1);
break;
case 1u:
v2 = func2(a1, v4, v1);
break;
default:
goto LABEL_19;
}
}
LABEL_5:
*(_WORD *)(stored_um_vars + 144 * v1 + 82) = v2;
LABEL_6:
++v1;
}
while ( num_stored_um_fields > (int)v1 );
}
nc_def_dim(a1, "num_etaT_levels", header[110], v7);
return nc_def_dim(a1, "num_etaR_levels", header[110] - 1LL, v7);
}

original_code:
void set_vertical_dimensions( int ncid, int rflag ) {
     int i, num_instances, dimID=0;
     for ( i=0; i<num_stored_um_fields; i++ ) {
         num_instances = stored_um_vars[i].nz;
         if ( num_instances>1 ) {
            switch ( stored_um_vars[i].lbvc ) {
                 case 1:
                      dimID = set_altitude( ncid, num_instances, i );
                      break;
                 case 6:
                      dimID = set_soil_levels( ncid, num_instances, i );
                      break;
                 case 8:
                      dimID = set_pressure_levels( ncid, num_instances, i );
                      break;
                 case 65:
                      dimID = set_hybrid_levels( ncid, num_instances, i );
                      break;
                 case 128:
                      dimID = set_sea_surface_levels( ncid, num_instances, i );
                      break;
                 case 129:
                      dimID = set_surface_levels( ncid, num_instances, i );
                      break;
                 default:
                      printf( "ERROR: unknown vertical coordinate (%hu) for STASH CODE=%d\n\n",
                              stored_um_vars[i].lbvc, stored_um_vars[i].stash_code );
                      break;
            }
            stored_um_vars[i].z_dim = (unsigned short int ) dimID;
         } else {
            stored_um_vars[i].z_dim = 999;
         }
     }
     i = nc_def_dim( ncid, "num_etaT_levels", (size_t ) header[110],
                    &num_instances );
     i = nc_def_dim( ncid, "num_etaR_levels", (size_t ) (header[110]-1),
                    &num_instances );
     return;
}

canonical_original_code:
void set_vertical_dimensions(int ncid, int rflag) {
     int i; int num_instances; int dimID = 0;
     for ( i=0; i<num_stored_um_fields; i++ ) {
         num_instances = stored_um_vars[i].nz;
         if ( num_instances>1 ) {
            switch ( stored_um_vars[i].lbvc ) {
                 case 1:
                      dimID = set_altitude( ncid, num_instances, i );
                      break;
                 case 6:
                      dimID = set_soil_levels( ncid, num_instances, i );
                      break;
                 case 8:
                      dimID = set_pressure_levels( ncid, num_instances, i );
                      break;
                 case 65:
                      dimID = set_hybrid_levels( ncid, num_instances, i );
                      break;
                 case 128:
                      dimID = set_sea_surface_levels( ncid, num_instances, i );
                      break;
                 case 129:
                      dimID = set_surface_levels( ncid, num_instances, i );
                      break;
                 default:
                      printf( "ERROR: unknown vertical coordinate (%hu) for STASH CODE=%d\n\n",
                              stored_um_vars[i].lbvc, stored_um_vars[i].stash_code );
                      break;
            }
            stored_um_vars[i].z_dim = (unsigned short ) dimID;
         } else {
            stored_um_vars[i].z_dim = 999;
         }
     }
     i = nc_def_dim( ncid, "num_etaT_levels", (unsigned long ) header[110],
                    &num_instances );
     i = nc_def_dim( ncid, "num_etaR_levels", (unsigned long ) (header[110]-1),
                    &num_instances );
     return;
}

variable_types: rflag int

variable_types: dimID int


decompiled_code:
void __fastcall construct_um_variables(unsigned int a1, int a2)
{
int v2; // eax
size_t v3; // r14
_QWORD *v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
void *v7; // rbp
_DWORD *v8; // r12
unsigned int v9; // er15
__int64 v10; // rax
__int64 v11; // r14
__int16 v12; // ax
__int64 v13; // rax
__int16 v14; // dx
unsigned __int16 v15; // ax
__int64 v16; // rbp
__int64 v17; // rbp
int v18; // [rsp+14h] [rbp-44h] BYREF
unsigned int v19; // [rsp+18h] [rbp-40h] BYREF
int v20[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v20[0] = 0;
if ( num_stored_um_fields > 0 )
{
v2 = 0;
do
{
v17 = stored_um_vars + 144LL * v2;
if ( *(_WORD *)(v17 + 62) <= 1u )
{
v8 = malloc(0xCuLL);
*v8 = *(unsigned __int16 *)(v17 + 80);
v9 = 3;
v10 = 3LL;
v11 = 3LL;
}
else
{
v8 = malloc(0x10uLL);
*v8 = *(unsigned __int16 *)(v17 + 80);
v8[1] = *(unsigned __int16 *)(v17 + 82);
v9 = 4;
v10 = 4LL;
v11 = 4LL;
}
v8[v10 - 2] = *(unsigned __int16 *)(v17 + 84);
v8[v10 - 1] = *(unsigned __int16 *)(v17 + 86);
nc_def_var(a1, v17, *(unsigned int *)(v17 + 136), v9, v8, &v19);
free(v8);
if ( !netcdf3_flag )
{
v3 = v11;
v4 = malloc(v3 * 8);
*v4 = 1LL;
v5 = stored_um_vars + 144LL * v20[0];
v4[v3 - 1] = *(unsigned __int16 *)(v5 + 64);
if ( a2 )
v6 = int_constants[6];
else
v6 = *(unsigned __int16 *)(v5 + 66);
v4[v3 - 2] = v6;
if ( v9 == 4 )
v4[1] = 1LL;
nc_def_var_chunking(a1, v19, 0LL, v4);
free(v4);
nc_def_var_deflate(a1, v19, 1LL, 1LL, 3LL);
}
v12 = *(_WORD *)(stored_um_vars + 144LL * v20[0] + 74);
if ( v12 == 101 )
{
nc_put_att_text(a1, v19, "grid_mapping", 12LL, "rotated_pole");
nc_put_att_text(a1, v19, "coordinates", 18LL, "latitude longitude");
}
else if ( v12 == 1 )
{
nc_put_att_text(a1, v19, "coordinates", 18LL, "latitude longitude");
}
v13 = stored_um_vars + 144LL * v20[0];
v14 = *(_WORD *)(v13 + 78);
if ( v14 )
{
switch ( v14 )
{
case 8:
nc_put_att_text(a1, v19, "cell_method", 20LL, "longitude:derivative");
break;
case 0x10:
nc_put_att_text(a1, v19, "cell_method", 19LL, "latitude:derivative");
break;
case 0x40:
nc_put_att_text(a1, v19, "cell_method", 14LL, "longitude:mean");
break;
case 0x80:
if ( *(_WORD *)(v13 + 72) )
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:sum");
else
nc_put_att_text(a1, v19, "cell_method", 9LL, "time:mean");
break;
case 0x1000:
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:min");
break;
case 0x2000:
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:max");
break;
}
}
v15 = *(_WORD *)(stored_um_vars + 144LL * v20[0] + 58);
if ( v15 == 9999 )
{
v20[0] = 1;
nc_put_att_int(a1, v19, "stash_model", 4LL, 1LL, v20);
v20[0] = *(unsigned __int16 *)(stored_um_vars + 144LL * v20[0] + 56) / 0x3E8u;
nc_put_att_int(a1, v19, "stash_section", 4LL, 1LL, v20);
v20[0] = *(unsigned __int16 *)(stored_um_vars + 144LL * v20[0] + 56) - v20[0];
nc_put_att_int(a1, v19, "stash_item", 4LL, 1LL, v20);
v18 = 1120403456;
nc_put_att_float(a1, v19, "valid_max", 5LL, 1LL, &v18);
v18 = 0;
nc_put_att_float(a1, v19, "valid_min", 5LL, 1LL, &v18);
nc_put_att_text(a1, v19, "long_name", 16LL, "unknown UM field");
nc_put_att_text(a1, v19, "standard_name", 16LL, "unknown_UM_field");
nc_put_att_text(a1, v19, "units", 7LL, "unknown");
}
else
{
v16 = 292LL * v15;
nc_put_att_int(a1, v19, "stash_model", 4LL, 1LL, (char *)um_vars + v16 + 4);
nc_put_att_int(a1, v19, "stash_section", 4LL, 1LL, (char *)um_vars + v16 + 8);
nc_put_att_int(a1, v19, "stash_item", 4LL, 1LL, (char *)um_vars + v16);
nc_put_att_float(a1, v19, "valid_max", 5LL, 1LL, (char *)um_vars + v16 + 24);
nc_put_att_float(a1, v19, "valid_min", 5LL, 1LL, (char *)um_vars + v16 + 28);
nc_put_att_text(a1, v19, "long_name", 100LL, (char *)um_vars + v16 + 89);
nc_put_att_text(a1, v19, "standard_name", 75LL, (char *)um_vars + v16 + 189);
nc_put_att_text(a1, v19, "units", 25LL, (char *)um_vars + v16 + 264);
}
v2 = v20[0] + 1;
v20[0] = v2;
}
while ( v2 < num_stored_um_fields );
}
v7 = malloc(4uLL);
nc_inq_dimid(a1, "num_etaT_levels", v7);
nc_def_var(a1, "eta_theta", 5LL, 1LL, v7, &v19);
nc_inq_dimid(a1, "num_etaR_levels", v7);
nc_def_var(a1, "eta_rho", 5LL, 1LL, v7, &v19);
free(v7);
}

canonical_decompiled_code:
void __fastcall func0(unsigned int a1, int a2)
{
int v2; // eax
size_t v3; // r14
_QWORD *v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
void *v7; // rbp
_DWORD *v8; // r12
unsigned int v9; // er15
__int64 v10; // rax
__int64 v11; // r14
__int16 v12; // ax
__int64 v13; // rax
__int16 v14; // dx
unsigned __int16 v15; // ax
__int64 v16; // rbp
__int64 v17; // rbp
int v18; // [rsp+14h] [rbp-44h] BYREF
unsigned int v19; // [rsp+18h] [rbp-40h] BYREF
int v20[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v20[0] = 0;
if ( num_stored_um_fields > 0 )
{
v2 = 0;
do
{
v17 = stored_um_vars + 144LL * v2;
if ( *(_WORD *)(v17 + 62) <= 1u )
{
v8 = malloc(0xCuLL);
*v8 = *(unsigned __int16 *)(v17 + 80);
v9 = 3;
v10 = 3LL;
v11 = 3LL;
}
else
{
v8 = malloc(0x10uLL);
*v8 = *(unsigned __int16 *)(v17 + 80);
v8[1] = *(unsigned __int16 *)(v17 + 82);
v9 = 4;
v10 = 4LL;
v11 = 4LL;
}
v8[v10 - 2] = *(unsigned __int16 *)(v17 + 84);
v8[v10 - 1] = *(unsigned __int16 *)(v17 + 86);
nc_def_var(a1, v17, *(unsigned int *)(v17 + 136), v9, v8, &v19);
free(v8);
if ( !netcdf3_flag )
{
v3 = v11;
v4 = malloc(v3 * 8);
*v4 = 1LL;
v5 = stored_um_vars + 144LL * v20[0];
v4[v3 - 1] = *(unsigned __int16 *)(v5 + 64);
if ( a2 )
v6 = int_constants[6];
else
v6 = *(unsigned __int16 *)(v5 + 66);
v4[v3 - 2] = v6;
if ( v9 == 4 )
v4[1] = 1LL;
nc_def_var_chunking(a1, v19, 0LL, v4);
free(v4);
nc_def_var_deflate(a1, v19, 1LL, 1LL, 3LL);
}
v12 = *(_WORD *)(stored_um_vars + 144LL * v20[0] + 74);
if ( v12 == 101 )
{
nc_put_att_text(a1, v19, "grid_mapping", 12LL, "rotated_pole");
nc_put_att_text(a1, v19, "coordinates", 18LL, "latitude longitude");
}
else if ( v12 == 1 )
{
nc_put_att_text(a1, v19, "coordinates", 18LL, "latitude longitude");
}
v13 = stored_um_vars + 144LL * v20[0];
v14 = *(_WORD *)(v13 + 78);
if ( v14 )
{
switch ( v14 )
{
case 8:
nc_put_att_text(a1, v19, "cell_method", 20LL, "longitude:derivative");
break;
case 0x10:
nc_put_att_text(a1, v19, "cell_method", 19LL, "latitude:derivative");
break;
case 0x40:
nc_put_att_text(a1, v19, "cell_method", 14LL, "longitude:mean");
break;
case 0x80:
if ( *(_WORD *)(v13 + 72) )
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:sum");
else
nc_put_att_text(a1, v19, "cell_method", 9LL, "time:mean");
break;
case 0x1000:
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:min");
break;
case 0x2000:
nc_put_att_text(a1, v19, "cell_method", 8LL, "time:max");
break;
}
}
v15 = *(_WORD *)(stored_um_vars + 144LL * v20[0] + 58);
if ( v15 == 9999 )
{
v20[0] = 1;
nc_put_att_int(a1, v19, "stash_model", 4LL, 1LL, v20);
v20[0] = *(unsigned __int16 *)(stored_um_vars + 144LL * v20[0] + 56) / 0x3E8u;
nc_put_att_int(a1, v19, "stash_section", 4LL, 1LL, v20);
v20[0] = *(unsigned __int16 *)(stored_um_vars + 144LL * v20[0] + 56) - v20[0];
nc_put_att_int(a1, v19, "stash_item", 4LL, 1LL, v20);
v18 = 1120403456;
nc_put_att_float(a1, v19, "valid_max", 5LL, 1LL, &v18);
v18 = 0;
nc_put_att_float(a1, v19, "valid_min", 5LL, 1LL, &v18);
nc_put_att_text(a1, v19, "long_name", 16LL, "unknown UM field");
nc_put_att_text(a1, v19, "standard_name", 16LL, "unknown_UM_field");
nc_put_att_text(a1, v19, "units", 7LL, "unknown");
}
else
{
v16 = 292LL * v15;
nc_put_att_int(a1, v19, "stash_model", 4LL, 1LL, (char *)um_vars + v16 + 4);
nc_put_att_int(a1, v19, "stash_section", 4LL, 1LL, (char *)um_vars + v16 + 8);
nc_put_att_int(a1, v19, "stash_item", 4LL, 1LL, (char *)um_vars + v16);
nc_put_att_float(a1, v19, "valid_max", 5LL, 1LL, (char *)um_vars + v16 + 24);
nc_put_att_float(a1, v19, "valid_min", 5LL, 1LL, (char *)um_vars + v16 + 28);
nc_put_att_text(a1, v19, "long_name", 100LL, (char *)um_vars + v16 + 89);
nc_put_att_text(a1, v19, "standard_name", 75LL, (char *)um_vars + v16 + 189);
nc_put_att_text(a1, v19, "units", 25LL, (char *)um_vars + v16 + 264);
}
v2 = v20[0] + 1;
v20[0] = v2;
}
while ( v2 < num_stored_um_fields );
}
v7 = malloc(4uLL);
nc_inq_dimid(a1, "num_etaT_levels", v7);
nc_def_var(a1, "eta_theta", 5LL, 1LL, v7, &v19);
nc_inq_dimid(a1, "num_etaR_levels", v7);
nc_def_var(a1, "eta_rho", 5LL, 1LL, v7, &v19);
free(v7);
}

original_code:
void construct_um_variables( int ncid, int iflag ) {
     int i, ierr, *dim_ids, ndim, varID, loc;
     size_t *chunksize;
     float tmp;
     for ( i=0; i<num_stored_um_fields; i++ ) {
         if ( stored_um_vars[i].nz>1 ) { ndim = 4; }
         else { ndim = 3; }
         dim_ids = (int *) malloc( ndim*sizeof(int) );
         dim_ids[0] = stored_um_vars[i].t_dim;
         if ( ndim==4 ) { dim_ids[1] = stored_um_vars[i].z_dim; }
         dim_ids[ndim-2] = stored_um_vars[i].y_dim;
         dim_ids[ndim-1] = stored_um_vars[i].x_dim;
         ierr = nc_def_var( ncid, stored_um_vars[i].name, stored_um_vars[i].vartype,
                            ndim, dim_ids, &varID );
         free( dim_ids );
         if ( netcdf3_flag==0 ) {
            chunksize = (size_t* ) malloc( ndim*sizeof(size_t) );
            chunksize[0] = 1;
            chunksize[ndim-1] = stored_um_vars[i].nx;
            if ( iflag==0 ) { chunksize[ndim-2] = stored_um_vars[i].ny; }
            else { chunksize[ndim-2] = int_constants[6]; }
            if ( ndim==4 ) { chunksize[1] = 1; }
            ierr = nc_def_var_chunking( ncid, varID, 0, chunksize );
            free( chunksize );
            ierr = nc_def_var_deflate( ncid, varID, 1, 1, 3 );
         }
         if ( stored_um_vars[i].coordinates==101 ) {
            ierr = nc_put_att_text( ncid, varID, "grid_mapping", 12, "rotated_pole" );
            ierr = nc_put_att_text( ncid, varID, "coordinates", 18, "latitude longitude" );
         }
         else if ( stored_um_vars[i].coordinates==1 ) {
            ierr = nc_put_att_text( ncid, varID, "coordinates", 18, "latitude longitude" );
         }
        if ( stored_um_vars[i].lbproc>0 ) {
           if ( stored_um_vars[i].lbproc==8 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 20, "longitude:derivative" ); }
           else if ( stored_um_vars[i].lbproc==16 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 19, "latitude:derivative" ); }
           else if ( stored_um_vars[i].lbproc==64 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 14, "longitude:mean" ); }
           else if ( stored_um_vars[i].lbproc==128 ) {
                if ( stored_um_vars[i].accum==0 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 9, "time:mean" ); }
                else { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:sum" ); }
           }
           else if ( stored_um_vars[i].lbproc==4096 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:min" ); }
           else if ( stored_um_vars[i].lbproc==8192 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:max" ); }
        }
        if ( stored_um_vars[i].xml_index!=9999 ) {
           loc = stored_um_vars[i].xml_index;
           ierr = nc_put_att_int( ncid, varID, "stash_model", 4, 1, &
                                  um_vars[loc].model );
           ierr = nc_put_att_int( ncid, varID, "stash_section", 4, 1, &
                                  um_vars[loc].section );
           ierr = nc_put_att_int( ncid, varID, "stash_item", 4, 1, &
                                  um_vars[loc].code );
           ierr = nc_put_att_float( ncid, varID, "valid_max", 5, 1, &
                                    um_vars[loc].validmax );
           ierr = nc_put_att_float( ncid, varID, "valid_min", 5, 1, &
                                    um_vars[loc].validmin );
           ierr = nc_put_att_text( ncid, varID, "long_name", 100, um_vars[loc].longname );
           ierr = nc_put_att_text( ncid, varID, "standard_name", 75, um_vars[loc].stdname );
           ierr = nc_put_att_text( ncid, varID, "units", 25, um_vars[loc].units );
        } else {
           i = 1;
           ierr = nc_put_att_int( ncid, varID, "stash_model", 4, 1, &i );
           i = (int ) (stored_um_vars[i].stash_code/1000);
           ierr = nc_put_att_int( ncid, varID, "stash_section", 4, 1, &i );
           i = (int ) (stored_um_vars[i].stash_code - i);
           ierr = nc_put_att_int( ncid, varID, "stash_item", 4, 1, &i );
           tmp = 100.0;
           ierr = nc_put_att_float( ncid, varID, "valid_max", 5, 1, &tmp );
           tmp = 0.0;
           ierr = nc_put_att_float( ncid, varID, "valid_min", 5, 1, &tmp );
           ierr = nc_put_att_text( ncid, varID, "long_name", 16, "unknown UM field" );
           ierr = nc_put_att_text( ncid, varID, "standard_name", 16, "unknown_UM_field" );
           ierr = nc_put_att_text( ncid, varID, "units", 7, "unknown" );
        }
     }
     ndim = 1;
     dim_ids = (int *) malloc( ndim*sizeof(int) );
     ierr = nc_inq_dimid( ncid, "num_etaT_levels", &dim_ids[0] );
     ierr = nc_def_var( ncid, "eta_theta", 5, ndim, dim_ids, &varID );
     ierr = nc_inq_dimid( ncid, "num_etaR_levels", &dim_ids[0] );
     ierr = nc_def_var( ncid, "eta_rho", 5, ndim, dim_ids, &varID );
     free( dim_ids );
     return;
}

canonical_original_code:
void construct_um_variables(int ncid, int iflag) {
     int i; int ierr; int *dim_ids; int ndim; int varID; int loc;
     unsigned long *chunksize;
     float tmp;
     for ( i=0; i<num_stored_um_fields; i++ ) {
         if ( stored_um_vars[i].nz>1 ) { ndim = 4; }
         else { ndim = 3; }
         dim_ids = (int *) malloc( ndim*sizeof(int) );
         dim_ids[0] = stored_um_vars[i].t_dim;
         if ( ndim==4 ) { dim_ids[1] = stored_um_vars[i].z_dim; }
         dim_ids[ndim-2] = stored_um_vars[i].y_dim;
         dim_ids[ndim-1] = stored_um_vars[i].x_dim;
         ierr = nc_def_var( ncid, stored_um_vars[i].name, stored_um_vars[i].vartype,
                            ndim, dim_ids, &varID );
         free( dim_ids );
         if ( netcdf3_flag==0 ) {
            chunksize = (unsigned long * ) malloc( ndim*sizeof(unsigned long) );
            chunksize[0] = 1;
            chunksize[ndim-1] = stored_um_vars[i].nx;
            if ( iflag==0 ) { chunksize[ndim-2] = stored_um_vars[i].ny; }
            else { chunksize[ndim-2] = int_constants[6]; }
            if ( ndim==4 ) { chunksize[1] = 1; }
            ierr = nc_def_var_chunking( ncid, varID, 0, chunksize );
            free( chunksize );
            ierr = nc_def_var_deflate( ncid, varID, 1, 1, 3 );
         }
         if ( stored_um_vars[i].coordinates==101 ) {
            ierr = nc_put_att_text( ncid, varID, "grid_mapping", 12, "rotated_pole" );
            ierr = nc_put_att_text( ncid, varID, "coordinates", 18, "latitude longitude" );
         }
         else if ( stored_um_vars[i].coordinates==1 ) {
            ierr = nc_put_att_text( ncid, varID, "coordinates", 18, "latitude longitude" );
         }
        if ( stored_um_vars[i].lbproc>0 ) {
           if ( stored_um_vars[i].lbproc==8 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 20, "longitude:derivative" ); }
           else if ( stored_um_vars[i].lbproc==16 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 19, "latitude:derivative" ); }
           else if ( stored_um_vars[i].lbproc==64 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 14, "longitude:mean" ); }
           else if ( stored_um_vars[i].lbproc==128 ) {
                if ( stored_um_vars[i].accum==0 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 9, "time:mean" ); }
                else { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:sum" ); }
           }
           else if ( stored_um_vars[i].lbproc==4096 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:min" ); }
           else if ( stored_um_vars[i].lbproc==8192 ) { ierr = nc_put_att_text( ncid, varID, "cell_method", 8, "time:max" ); }
        }
        if ( stored_um_vars[i].xml_index!=9999 ) {
           loc = stored_um_vars[i].xml_index;
           ierr = nc_put_att_int( ncid, varID, "stash_model", 4, 1, &
                                  um_vars[loc].model );
           ierr = nc_put_att_int( ncid, varID, "stash_section", 4, 1, &
                                  um_vars[loc].section );
           ierr = nc_put_att_int( ncid, varID, "stash_item", 4, 1, &
                                  um_vars[loc].code );
           ierr = nc_put_att_float( ncid, varID, "valid_max", 5, 1, &
                                    um_vars[loc].validmax );
           ierr = nc_put_att_float( ncid, varID, "valid_min", 5, 1, &
                                    um_vars[loc].validmin );
           ierr = nc_put_att_text( ncid, varID, "long_name", 100, um_vars[loc].longname );
           ierr = nc_put_att_text( ncid, varID, "standard_name", 75, um_vars[loc].stdname );
           ierr = nc_put_att_text( ncid, varID, "units", 25, um_vars[loc].units );
        } else {
           i = 1;
           ierr = nc_put_att_int( ncid, varID, "stash_model", 4, 1, &i );
           i = (int ) (stored_um_vars[i].stash_code/1000);
           ierr = nc_put_att_int( ncid, varID, "stash_section", 4, 1, &i );
           i = (int ) (stored_um_vars[i].stash_code - i);
           ierr = nc_put_att_int( ncid, varID, "stash_item", 4, 1, &i );
           tmp = 100.0;
           ierr = nc_put_att_float( ncid, varID, "valid_max", 5, 1, &tmp );
           tmp = 0.0;
           ierr = nc_put_att_float( ncid, varID, "valid_min", 5, 1, &tmp );
           ierr = nc_put_att_text( ncid, varID, "long_name", 16, "unknown UM field" );
           ierr = nc_put_att_text( ncid, varID, "standard_name", 16, "unknown_UM_field" );
           ierr = nc_put_att_text( ncid, varID, "units", 7, "unknown" );
        }
     }
     ndim = 1;
     dim_ids = (int *) malloc( ndim*sizeof(int) );
     ierr = nc_inq_dimid( ncid, "num_etaT_levels", &dim_ids[0] );
     ierr = nc_def_var( ncid, "eta_theta", 5, ndim, dim_ids, &varID );
     ierr = nc_inq_dimid( ncid, "num_etaR_levels", &dim_ids[0] );
     ierr = nc_def_var( ncid, "eta_rho", 5, ndim, dim_ids, &varID );
     free( dim_ids );
     return;
}

variable_types: iflag int

variable_types: ndim int

variable_types: loc int

variable_types:
chunksize
unsigned long *

variable_types: tmp float


decompiled_code:
__int64 __fastcall set_time_bnd(unsigned int a1, int a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int16 v4; // dx
__int64 v5; // rbx
float v7; // [rsp+Ch] [rbp-5Ch]
__int64 v8; // [rsp+10h] [rbp-58h] BYREF
__int64 v9; // [rsp+18h] [rbp-50h]
float v10; // [rsp+2Ch] [rbp-3Ch] BYREF
float v11; // [rsp+30h] [rbp-38h] BYREF
char s[6]; // [rsp+35h] [rbp-33h] BYREF
char v13[9]; // [rsp+3Bh] [rbp-2Dh] BYREF
unsigned int v14; // [rsp+44h] [rbp-24h] BYREF
char v15[4]; // [rsp+48h] [rbp-20h] BYREF
char v16[28]; // [rsp+4Ch] [rbp-1Ch] BYREF

v2 = 144LL * a2;
sprintf(s, "time%i", *(unsigned __int16 *)(stored_um_vars + v2 + 80));
nc_inq_dimid(a1, s, v15);
if ( (unsigned int)nc_inq_dimid(a1, "nv", v16) )
nc_def_dim(a1, "nv", 2LL, v16);
sprintf(v13, "time_bnd%hu", *(unsigned __int16 *)(stored_um_vars + v2 + 80));
if ( (unsigned int)nc_inq_varid(a1, v13, &v14) )
{
nc_def_var(a1, v13, 5LL, 2LL, v15, &v14);
nc_put_att_text(a1, v14, "long_name", 37LL, "start & end times for the cell method");
nc_put_att_text(a1, v14, "units", 5LL, "hours");
}
nc_enddef(a1);
v3 = stored_um_vars + v2;
v4 = *(_WORD *)(stored_um_vars + v2 + 60);
if ( v4 == 1 )
{
v10 = 0.0;
v11 = **(float **)(v3 + 96);
nc_put_var_float(a1, v14, &v10);
}
else
{
v7 = (float)(*(float *)(*(_QWORD *)(v3 + 96) + 4LL) - **(float **)(v3 + 96)) * 0.5;
if ( v4 )
{
v5 = 0LL;
do
{
v8 = v5;
v9 = 0LL;
v10 = *(float *)(*(_QWORD *)(v3 + 96) + 4 * v5) - v7;
nc_put_var1_float(a1, v14, &v8, &v10);
v9 = 1LL;
v11 = v7 + *(float *)(*(_QWORD *)(stored_um_vars + v2 + 96) + 4 * v5);
nc_put_var1_float(a1, v14, &v8, &v11);
v3 = stored_um_vars + v2;
++v5;
}
while ( *(unsigned __int16 *)(stored_um_vars + v2 + 60) > (int)v5 );
}
}
return nc_redef(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int16 v4; // dx
__int64 v5; // rbx
float v7; // [rsp+Ch] [rbp-5Ch]
__int64 v8; // [rsp+10h] [rbp-58h] BYREF
__int64 v9; // [rsp+18h] [rbp-50h]
float v10; // [rsp+2Ch] [rbp-3Ch] BYREF
float v11; // [rsp+30h] [rbp-38h] BYREF
char s[6]; // [rsp+35h] [rbp-33h] BYREF
char v13[9]; // [rsp+3Bh] [rbp-2Dh] BYREF
unsigned int v14; // [rsp+44h] [rbp-24h] BYREF
char v15[4]; // [rsp+48h] [rbp-20h] BYREF
char v16[28]; // [rsp+4Ch] [rbp-1Ch] BYREF

v2 = 144LL * a2;
sprintf(s, "time%i", *(unsigned __int16 *)(stored_um_vars + v2 + 80));
nc_inq_dimid(a1, s, v15);
if ( (unsigned int)nc_inq_dimid(a1, "nv", v16) )
nc_def_dim(a1, "nv", 2LL, v16);
sprintf(v13, "time_bnd%hu", *(unsigned __int16 *)(stored_um_vars + v2 + 80));
if ( (unsigned int)nc_inq_varid(a1, v13, &v14) )
{
nc_def_var(a1, v13, 5LL, 2LL, v15, &v14);
nc_put_att_text(a1, v14, "long_name", 37LL, "start & end times for the cell method");
nc_put_att_text(a1, v14, "units", 5LL, "hours");
}
nc_enddef(a1);
v3 = stored_um_vars + v2;
v4 = *(_WORD *)(stored_um_vars + v2 + 60);
if ( v4 == 1 )
{
v10 = 0.0;
v11 = **(float **)(v3 + 96);
nc_put_var_float(a1, v14, &v10);
}
else
{
v7 = (float)(*(float *)(*(_QWORD *)(v3 + 96) + 4LL) - **(float **)(v3 + 96)) * 0.5;
if ( v4 )
{
v5 = 0LL;
do
{
v8 = v5;
v9 = 0LL;
v10 = *(float *)(*(_QWORD *)(v3 + 96) + 4 * v5) - v7;
nc_put_var1_float(a1, v14, &v8, &v10);
v9 = 1LL;
v11 = v7 + *(float *)(*(_QWORD *)(stored_um_vars + v2 + 96) + 4 * v5);
nc_put_var1_float(a1, v14, &v8, &v11);
v3 = stored_um_vars + v2;
++v5;
}
while ( *(unsigned __int16 *)(stored_um_vars + v2 + 60) > (int)v5 );
}
}
return nc_redef(a1);
}

original_code:
void set_time_bnd( int ncid, int var_index ) {
    int i, ierr, dim_ids[2], varID;
    char time_bnd_str[9], dim_name[6];
    float dt, tval[2];
    size_t index[2];
     sprintf( dim_name, "time%i", stored_um_vars[var_index].t_dim );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_ids[0] );
     ierr = nc_inq_dimid( ncid, "nv", &dim_ids[1] );
     if ( ierr!=0 ) { ierr = nc_def_dim( ncid, "nv", 2, &dim_ids[1] ); }
     sprintf( time_bnd_str, "time_bnd%hu", stored_um_vars[var_index].t_dim );
     ierr = nc_inq_varid( ncid, time_bnd_str, &varID );
     if ( ierr!=0 ) {
        ierr = nc_def_var( ncid, time_bnd_str, 5, 2, dim_ids, &varID );
        ierr = nc_put_att_text( ncid, varID, "long_name", 37, "start & end times for the cell method" );
        ierr = nc_put_att_text( ncid, varID, "units", 5, "hours" );
     }
     ierr = nc_enddef( ncid );
     if ( stored_um_vars[var_index].nt==1 ) {
        tval[0] = 0.0;
        tval[1] = stored_um_vars[var_index].times[0];
        ierr = nc_put_var_float( ncid, varID, tval );
     } else {
        dt = 0.5*(stored_um_vars[var_index].times[1] - stored_um_vars[var_index].times[0]);
        for ( i=0; i<stored_um_vars[var_index].nt; i++ ) {
            index[0] = i;
            index[1] = 0;
            tval[0] = stored_um_vars[var_index].times[i] - dt;
            ierr = nc_put_var1_float( ncid, varID, index, &tval[0] );
            index[1] = 1;
            tval[1] = stored_um_vars[var_index].times[i] + dt;
            ierr = nc_put_var1_float( ncid, varID, index, &tval[1] );
        }
     }
     ierr = nc_redef( ncid );
     return;
}

canonical_original_code:
void set_time_bnd(int ncid, int var_index) {
    int i; int ierr; int dim_ids[2]; int varID;
    char time_bnd_str[9]; char dim_name[6];
    float dt; float tval[2];
    unsigned long index[2];
     sprintf( dim_name, "time%i", stored_um_vars[var_index].t_dim );
     ierr = nc_inq_dimid( ncid, dim_name, &dim_ids[0] );
     ierr = nc_inq_dimid( ncid, "nv", &dim_ids[1] );
     if ( ierr!=0 ) { ierr = nc_def_dim( ncid, "nv", 2, &dim_ids[1] ); }
     sprintf( time_bnd_str, "time_bnd%hu", stored_um_vars[var_index].t_dim );
     ierr = nc_inq_varid( ncid, time_bnd_str, &varID );
     if ( ierr!=0 ) {
        ierr = nc_def_var( ncid, time_bnd_str, 5, 2, dim_ids, &varID );
        ierr = nc_put_att_text( ncid, varID, "long_name", 37, "start & end times for the cell method" );
        ierr = nc_put_att_text( ncid, varID, "units", 5, "hours" );
     }
     ierr = nc_enddef( ncid );
     if ( stored_um_vars[var_index].nt==1 ) {
        tval[0] = 0.0;
        tval[1] = stored_um_vars[var_index].times[0];
        ierr = nc_put_var_float( ncid, varID, tval );
     } else {
        dt = 0.5*(stored_um_vars[var_index].times[1] - stored_um_vars[var_index].times[0]);
        for ( i=0; i<stored_um_vars[var_index].nt; i++ ) {
            index[0] = i;
            index[1] = 0;
            tval[0] = stored_um_vars[var_index].times[i] - dt;
            ierr = nc_put_var1_float( ncid, varID, index, &tval[0] );
            index[1] = 1;
            tval[1] = stored_um_vars[var_index].times[i] + dt;
            ierr = nc_put_var1_float( ncid, varID, index, &tval[1] );
        }
     }
     ierr = nc_redef( ncid );
     return;
}

variable_types: ncid int

variable_types: ierr int

variable_types: varID int

variable_types: dt float

variable_types:
tval
float [2]

variable_types:
index
unsigned long [2]


decompiled_code:
__int64 __fastcall create_time_dim(unsigned int a1, int a2, __int64 a3)
{
__int64 v3; // rbp
char v5[8]; // [rsp+1h] [rbp-57h] BYREF
char s[6]; // [rsp+Ah] [rbp-4Eh] BYREF
char v7[40]; // [rsp+10h] [rbp-48h] BYREF
unsigned int v8; // [rsp+38h] [rbp-20h] BYREF
char v9[28]; // [rsp+3Ch] [rbp-1Ch] BYREF

sprintf(s, "time%i", a3);
v3 = 144LL * a2;
nc_def_dim(a1, s, *(unsigned __int16 *)(stored_um_vars + v3 + 60), v9);
nc_def_var(a1, s, 5LL, 1LL, v9, &v8);
if ( header[7] == 1LL )
sprintf(v5, "gregorian");
else
strcpy(v5, "360_day");
nc_put_att_text(a1, v8, "calendar", 9LL, v5);
strftime(v7, 0x21uLL, "hours since %Y-%m-%d %H:%M:%S", &forecast_reference);
nc_put_att_text(a1, v8, "units", 31LL, v7);
nc_put_att_text(a1, v8, "axis", 1LL, "T");
nc_put_att_text(a1, v8, "standard_name", 4LL, "time");
nc_put_att_text(a1, v8, "long_name", 42LL, "forecast period (end of reporting period)");
nc_enddef(a1);
nc_put_var_float(a1, v8, *(_QWORD *)(stored_um_vars + v3 + 96));
return nc_redef(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, int a2, __int64 a3)
{
__int64 v3; // rbp
char v5[8]; // [rsp+1h] [rbp-57h] BYREF
char s[6]; // [rsp+Ah] [rbp-4Eh] BYREF
char v7[40]; // [rsp+10h] [rbp-48h] BYREF
unsigned int v8; // [rsp+38h] [rbp-20h] BYREF
char v9[28]; // [rsp+3Ch] [rbp-1Ch] BYREF

sprintf(s, "time%i", a3);
v3 = 144LL * a2;
nc_def_dim(a1, s, *(unsigned __int16 *)(stored_um_vars + v3 + 60), v9);
nc_def_var(a1, s, 5LL, 1LL, v9, &v8);
if ( header[7] == 1LL )
sprintf(v5, "gregorian");
else
strcpy(v5, "360_day");
nc_put_att_text(a1, v8, "calendar", 9LL, v5);
strftime(v7, 0x21uLL, "hours since %Y-%m-%d %H:%M:%S", &forecast_reference);
nc_put_att_text(a1, v8, "units", 31LL, v7);
nc_put_att_text(a1, v8, "axis", 1LL, "T");
nc_put_att_text(a1, v8, "standard_name", 4LL, "time");
nc_put_att_text(a1, v8, "long_name", 42LL, "forecast period (end of reporting period)");
nc_enddef(a1);
nc_put_var_float(a1, v8, *(_QWORD *)(stored_um_vars + v3 + 96));
return nc_redef(a1);
}

original_code:
void create_time_dim( int ncid, int var_index, int time_dim_cnt ) {
     int dimID[1], ierr, varID;
     char time_des[40], dim_name[6], calendar[9];
     sprintf( dim_name, "time%i", time_dim_cnt );
     ierr = nc_def_dim( ncid, dim_name, (size_t ) stored_um_vars[var_index].nt, &dimID[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dimID, &varID );
     if ( header[7]==1 ) { sprintf( calendar, "gregorian" ); }
     else { sprintf( calendar, "360_day" ); }
     ierr = nc_put_att_text( ncid, varID, "calendar", 9, calendar );
     strftime( time_des, 33, "hours since %Y-%m-%d %H:%M:%S", &forecast_reference );
     ierr = nc_put_att_text( ncid, varID, "units", 31, time_des );
     ierr = nc_put_att_text( ncid, varID, "axis", 1, "T" );
     ierr = nc_put_att_text( ncid, varID, "standard_name", 4, "time" );
     ierr = nc_put_att_text( ncid, varID, "long_name", 42, "forecast period (end of reporting period)" );
     ierr = nc_enddef( ncid );
     ierr = nc_put_var_float( ncid, varID, stored_um_vars[var_index].times );
     ierr = nc_redef( ncid );
     return;
}

canonical_original_code:
void create_time_dim(int ncid, int var_index, int time_dim_cnt) {
     int dimID[1]; int ierr; int varID;
     char time_des[40]; char dim_name[6]; char calendar[9];
     sprintf( dim_name, "time%i", time_dim_cnt );
     ierr = nc_def_dim( ncid, dim_name, (unsigned long ) stored_um_vars[var_index].nt, &dimID[0] );
     ierr = nc_def_var( ncid, dim_name, 5, 1, dimID, &varID );
     if ( header[7]==1 ) { sprintf( calendar, "gregorian" ); }
     else { sprintf( calendar, "360_day" ); }
     ierr = nc_put_att_text( ncid, varID, "calendar", 9, calendar );
     strftime( time_des, 33, "hours since %Y-%m-%d %H:%M:%S", &forecast_reference );
     ierr = nc_put_att_text( ncid, varID, "units", 31, time_des );
     ierr = nc_put_att_text( ncid, varID, "axis", 1, "T" );
     ierr = nc_put_att_text( ncid, varID, "standard_name", 4, "time" );
     ierr = nc_put_att_text( ncid, varID, "long_name", 42, "forecast period (end of reporting period)" );
     ierr = nc_enddef( ncid );
     ierr = nc_put_var_float( ncid, varID, stored_um_vars[var_index].times );
     ierr = nc_redef( ncid );
     return;
}

variable_types:
dimID
int [1]

variable_types:
calendar
char [9]


original_code:
void set_temporal_dimensions( int ncid ) {
    float *sums, tol, flag;
    int i, j, num_unique_times;
    sums = (float *) calloc( num_stored_um_fields,sizeof(float) );
    for ( i=0; i<num_stored_um_fields; i++ ) {
    for ( j=0; j<stored_um_vars[i].nt; j++ ) {
        sums[i] += stored_um_vars[i].times[j];
    }
    }
    flag = -1.0;
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( sums[i]>-0.5 ) {
           for ( j=i+1; j<num_stored_um_fields; j++ ) {
               if ( sums[j]>-0.5 ) {
                  tol = (sums[i]-sums[j])*(sums[i]-sums[j]);
                  if ( tol<0.0001 ) { sums[j] = flag; }
               }
           }
           flag = flag-1.0;
        }
    }
    num_unique_times = (int )(-1.0*(flag+1.0));
    j = 0;
    for ( i=0; i<num_stored_um_fields; i++ )
        if ( sums[i]>-0.5 ) { create_time_dim( ncid, i, j ); j++; }
    j = 0;
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( sums[i]>-0.5 ) { stored_um_vars[i].t_dim = (unsigned short int) j; j++; }
        else { stored_um_vars[i].t_dim = (unsigned short int) ( -1.0*(sums[i]+1.0) ); }
    }
    free( sums );
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( (stored_um_vars[i].lbproc==128)||(stored_um_vars[i].lbproc==4096)||(stored_um_vars[i].lbproc==8192) ) {
           set_time_bnd( ncid, i );
           j++;
        }
    }
    return;
}

canonical_original_code:
void set_temporal_dimensions(int ncid) {
    float *sums; float tol; float flag;
    int i; int j; int num_unique_times;
    sums = (float *) calloc( num_stored_um_fields,sizeof(float) );
    for ( i=0; i<num_stored_um_fields; i++ ) {
    for ( j=0; j<stored_um_vars[i].nt; j++ ) {
        sums[i] += stored_um_vars[i].times[j];
    }
    }
    flag = -1.0;
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( sums[i]>-0.5 ) {
           for ( j=i+1; j<num_stored_um_fields; j++ ) {
               if ( sums[j]>-0.5 ) {
                  tol = (sums[i]-sums[j])*(sums[i]-sums[j]);
                  if ( tol<0.0001 ) { sums[j] = flag; }
               }
           }
           flag = flag-1.0;
        }
    }
    num_unique_times = (int )(-1.0*(flag+1.0));
    j = 0;
    for ( i=0; i<num_stored_um_fields; i++ )
        if ( sums[i]>-0.5 ) { create_time_dim( ncid, i, j ); j++; }
    j = 0;
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( sums[i]>-0.5 ) { stored_um_vars[i].t_dim = (unsigned short) j; j++; }
        else { stored_um_vars[i].t_dim = (unsigned short) ( -1.0*(sums[i]+1.0) ); }
    }
    free( sums );
    for ( i=0; i<num_stored_um_fields; i++ ) {
        if ( (stored_um_vars[i].lbproc==128)||(stored_um_vars[i].lbproc==4096)||(stored_um_vars[i].lbproc==8192) ) {
           set_time_bnd( ncid, i );
           j++;
        }
    }
    return;
}

variable_types:
sums
float *

variable_types: tol float

variable_types: flag float

variable_types: i int

variable_types: j int


decompiled_code:
void __fastcall status_check(int a1, const char *a2)
{
if ( !a1 )
{
printf("\n %s \n\n", a2);
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func0(int a1, const char *a2)
{
if ( !a1 )
{
printf("\n %s \n\n", a2);
exit(1);
}
}

original_code:
void status_check( int status, char *message ) {
     if ( status==0 ) {
        printf( "\n %s \n\n", message );
        exit(1);
     }
}

canonical_original_code:
void status_check(int status, char *message) {
     if ( status==0 ) {
        printf( "\n %s \n\n", message );
        exit(1);
     }
}

variable_types: status int

variable_types:
message
char *


usage

decompiled_code:
int usage()
{
puts("\nUsage: um2netcdf.x [ OPTIONS ] <input-file> <stash-file> \n");
puts(" where\n");
puts(" input-file --> file whose contents are to be parsed and transferred to a netCDF");
puts(" file. It can be an UM fields or dump file.\n");
puts(" stash-file --> XML file that contains the metadata definitions of various UM");
puts(" variables. These definitions include units, title, valid values");
puts(" etc...\n");
puts(" The following options can be specified. They MUST appear before the input filename!\n");
puts(" -h used to display this help message");
puts(" -i interpolates all fields onto the thermodynamic grid (eg. P-points on an Arakawa-C grid)");
puts(" -r fields written in reduced precision (eg. INT/FLOAT instead of LONG/DOUBLE)");
puts(" -n output NetCDF file will not contain any NetCDF-4 features (chunking and/or compression)");
puts(" -o <filename> ");
puts(" used to specify a filename to the output NetCDF file");
puts(" -s used to specify a set of stash codes of UM variables that can be selectively extracted");
puts(" from the input UM fields file into the NetCDF output file. Selected stash codes should");
puts(" be in a space-delimited list. Example:\n");
puts(" um2netcdf.x -i -r -o test.nc -s 3209 3210 input.um stash.xml\n");
puts(" -c used to specify the name of the run configuration XML file");
puts(" -b used to specify a set of stash codes of UM variables to be ignored if located in the");
puts(" input UM fields file into the NetCDF output file. Specified stash codes should");
puts(" be in a space-delimited list. Example:\n");
puts(" um2netcdf.x -i -r -o test.nc -b 3209 3210 input.um stash.xml -c config.xml\n");
return puts(" It does not matter which order you put the option flags.\n");
}

canonical_decompiled_code:
int func3()
{
puts("\nUsage: um2netcdf.x [ OPTIONS ] <input-file> <stash-file> \n");
puts(" where\n");
puts(" input-file --> file whose contents are to be parsed and transferred to a netCDF");
puts(" file. It can be an UM fields or dump file.\n");
puts(" stash-file --> XML file that contains the metadata definitions of various UM");
puts(" variables. These definitions include units, title, valid values");
puts(" etc...\n");
puts(" The following options can be specified. They MUST appear before the input filename!\n");
puts(" -h used to display this help message");
puts(" -i interpolates all fields onto the thermodynamic grid (eg. P-points on an Arakawa-C grid)");
puts(" -r fields written in reduced precision (eg. INT/FLOAT instead of LONG/DOUBLE)");
puts(" -n output NetCDF file will not contain any NetCDF-4 features (chunking and/or compression)");
puts(" -o <filename> ");
puts(" used to specify a filename to the output NetCDF file");
puts(" -s used to specify a set of stash codes of UM variables that can be selectively extracted");
puts(" from the input UM fields file into the NetCDF output file. Selected stash codes should");
puts(" be in a space-delimited list. Example:\n");
puts(" um2netcdf.x -i -r -o test.nc -s 3209 3210 input.um stash.xml\n");
puts(" -c used to specify the name of the run configuration XML file");
puts(" -b used to specify a set of stash codes of UM variables to be ignored if located in the");
puts(" input UM fields file into the NetCDF output file. Specified stash codes should");
puts(" be in a space-delimited list. Example:\n");
puts(" um2netcdf.x -i -r -o test.nc -b 3209 3210 input.um stash.xml -c config.xml\n");
return puts(" It does not matter which order you put the option flags.\n");
}

original_code:
void usage() {
     printf( "\nUsage:  um2netcdf.x [ OPTIONS ] <input-file> <stash-file> \n\n" );
     printf( "  where\n\n" );
     printf( "    input-file  --> file whose contents are to be parsed and transferred to a netCDF\n" );
     printf( "                    file. It can be an UM fields or dump file.\n\n" );
     printf( "    stash-file  --> XML file that contains the metadata definitions of various UM\n" );
     printf( "                    variables. These definitions include units, title, valid values\n" );
     printf( "                    etc...\n\n" );
     printf( "  The following options can be specified.  They MUST appear before the input filename!\n\n" );
     printf( "    -h used to display this help message\n" );
     printf( "    -i interpolates all fields onto the thermodynamic grid (eg. P-points on an Arakawa-C grid)\n" );
     printf( "    -r fields written in reduced precision (eg. INT/FLOAT instead of LONG/DOUBLE)\n" );
     printf( "    -n output NetCDF file will not contain any NetCDF-4 features (chunking and/or compression)\n" );
     printf( "    -o <filename> \n");
     printf( "       used to specify a filename to the output NetCDF file\n" );
     printf( "    -s used to specify a set of stash codes of UM variables that can be selectively extracted\n" );
     printf( "       from the input UM fields file into the NetCDF output file. Selected stash codes should\n" );
     printf( "       be in a space-delimited list.  Example:\n\n" );
     printf( "          um2netcdf.x -i -r -o test.nc -s 3209 3210 input.um stash.xml\n\n" );
     printf( "    -c used to specify the name of the run configuration XML file\n" );
     printf( "    -b used to specify a set of stash codes of UM variables to be ignored if located in the\n" );
     printf( "       input UM fields file into the NetCDF output file. Specified stash codes should\n" );
     printf( "       be in a space-delimited list.  Example:\n\n" );
     printf( "            um2netcdf.x -i -r -o test.nc -b 3209 3210 input.um stash.xml -c config.xml\n\n" );
     printf( "   It does not matter which order you put the option flags.\n\n" );
}


decompiled_code:
int ieee_usage_message()
{
puts("\nWARNING: you are attempting to convert an UM Fields or Dump field with");
puts(" fields that are WGDOS-packed. You will need to unpack the input");
puts(" file using the following procedure:\n");
puts("STEP 1: log into FitzRoy or Barometer\n");
puts("STEP 2: set the UMDIR environment variable as so:");
puts(" export UMDIR=/oper/admin/um_fcm/um\n");
puts("STEP 3: Run the IEEE utility that comes with the UM release as so:");
return puts(" /oper/admin/um_fcm/um/vn8.4/ibm/utils/ieee -64e <input_filename> <output_filename>\n");
}

canonical_decompiled_code:
int func4()
{
puts("\nWARNING: you are attempting to convert an UM Fields or Dump field with");
puts(" fields that are WGDOS-packed. You will need to unpack the input");
puts(" file using the following procedure:\n");
puts("STEP 1: log into FitzRoy or Barometer\n");
puts("STEP 2: set the UMDIR environment variable as so:");
puts(" export UMDIR=/oper/admin/um_fcm/um\n");
puts("STEP 3: Run the IEEE utility that comes with the UM release as so:");
return puts(" /oper/admin/um_fcm/um/vn8.4/ibm/utils/ieee -64e <input_filename> <output_filename>\n");
}

original_code:
void ieee_usage_message() {
     printf( "\nWARNING: you are attempting to convert an UM Fields or Dump field with\n" );
     printf( "           fields that are WGDOS-packed.  You will need to unpack the input\n" );
     printf( "           file using the following procedure:\n\n" );
     printf( "STEP 1: log into FitzRoy or Barometer\n\n" );
     printf( "STEP 2: set the UMDIR environment variable as so:\n" );
     printf( "        export UMDIR=/oper/admin/um_fcm/um\n\n" );
     printf( "STEP 3: Run the IEEE utility that comes with the UM release as so:\n" );
     printf( "        /oper/admin/um_fcm/um/vn8.4/ibm/utils/ieee -64e <input_filename> <output_filename>\n\n" );
}


repo: adilinden/repeater-controller

decompiled_code:
void stdout_open()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void stdout_open(char *dev)
{
    return;
}

canonical_original_code:
void stdout_open(char *dev)
{
    return;
}

variable_types:
dev
char *


decompiled_code:
void stdout_setup()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void stdout_setup(int rate)
{
    return;
}

canonical_original_code:
void stdout_setup(int rate)
{
    return;
}

variable_types: rate int


decompiled_code:
size_t __fastcall stdout_write(const void **a1, int *a2)
{
return fwrite(*a1, 1uLL, *a2, stdout);
}

canonical_decompiled_code:
size_t __fastcall func2(const void **a1, int *a2)
{
return fwrite(*a1, 1uLL, *a2, stdout);
}

original_code:
int stdout_write(int16_t **bf, int *nbf)
{
    return fwrite(*bf, 1, *nbf, stdout);
}

canonical_original_code:
int stdout_write(short **bf, int *nbf)
{
    return fwrite(*bf, 1, *nbf, stdout);
}

variable_types:
bf
short **

variable_types:
nbf
int *


decompiled_code:
void stdout_close()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void stdout_close()
{
    return;
}

canonical_original_code:
void stdout_close()
{
    return;
}