BJTask

decompiled_code:
__int64 __fastcall BJTask(__int64 a1, __int64 a2, int a3, _QWORD *a4)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
__int64 v16; // rdx
double v17; // xmm0_8
double v18; // xmm0_8
int v19; // eax
__int64 v20; // rdi
__int64 v21; // rdx
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8

switch ( a3 )
{
case 0:
case 5:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
case 123:
case 124:
case 125:
case 126:
case 127:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
case 136:
case 137:
case 138:
case 139:
case 140:
case 141:
case 142:
case 143:
case 144:
case 145:
case 146:
case 147:
case 148:
case 149:
case 150:
case 151:
case 152:
case 153:
case 154:
case 155:
case 156:
case 157:
case 158:
case 159:
case 160:
case 161:
case 162:
case 163:
case 164:
case 165:
case 166:
case 167:
case 168:
case 169:
case 170:
case 171:
case 172:
case 173:
case 174:
case 175:
case 176:
case 177:
case 178:
case 179:
case 180:
case 181:
case 182:
case 183:
case 184:
case 185:
case 186:
case 187:
case 188:
case 189:
case 190:
case 191:
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 198:
case 199:
case 200:
result = 7LL;
break;
case 1:
*a4 = *(_QWORD *)(a2 + 56);
result = 0LL;
break;
case 2:
*(_DWORD *)a4 = *(_BYTE *)(a2 + 1184) & 1;
result = 0LL;
break;
case 3:
*a4 = *(_QWORD *)(a2 + 64);
result = 0LL;
break;
case 4:
*a4 = *(_QWORD *)(a2 + 72);
result = 0LL;
break;
case 6:
*(double *)a4 = *(double *)(a2 + 80) - 273.15;
result = 0LL;
break;
case 201:
v5 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v5 )
{
*(double *)a4 = *(double *)(a2 + 264)
/ (fmax(
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL) - 16),
fmax(
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL)),
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL) + 32)))
* 6.283185307179586);
result = 0LL;
}
break;
case 202:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 28);
result = 0LL;
break;
case 203:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 32);
result = 0LL;
break;
case 204:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 36);
result = 0LL;
break;
case 205:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 40);
result = 0LL;
break;
case 206:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 44);
result = 0LL;
break;
case 207:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 48);
result = 0LL;
break;
case 208:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 52);
result = 0LL;
break;
case 209:
v6 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v6 )
{
*a4 = *(_QWORD *)(v6 + 8LL * *(int *)(a2 + 24));
result = 0LL;
}
break;
case 210:
v7 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v7 )
{
*a4 = *(_QWORD *)(v7 + 8LL * *(int *)(a2 + 24) + 8);
result = 0LL;
}
break;
case 211:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 232);
break;
case 212:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 240);
break;
case 213:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 248);
break;
case 214:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 256);
break;
case 215:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 264);
break;
case 216:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 272);
break;
case 217:
v8 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v8 )
{
*a4 = *(_QWORD *)(v8 + 8LL * *(int *)(a2 + 24) + 32);
result = 0LL;
}
break;
case 218:
v9 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v9 )
{
*a4 = *(_QWORD *)(v9 + 8LL * *(int *)(a2 + 24) + 40);
result = 0LL;
}
break;
case 219:
v10 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v10 )
{
*a4 = *(_QWORD *)(v10 + 8LL * *(int *)(a2 + 24) + 48);
result = 0LL;
}
break;
case 220:
v11 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v11 )
{
*a4 = *(_QWORD *)(v11 + 8LL * *(int *)(a2 + 24) + 56);
result = 0LL;
}
break;
case 221:
v12 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v12 )
{
*a4 = *(_QWORD *)(v12 + 8LL * *(int *)(a2 + 24) + 64);
result = 0LL;
}
break;
case 222:
v13 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v13 )
{
*a4 = *(_QWORD *)(v13 + 8LL * *(int *)(a2 + 24) + 72);
result = 0LL;
}
break;
case 223:
v14 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v14 )
{
*a4 = *(_QWORD *)(v14 + 8LL * *(int *)(a2 + 24) + 80);
result = 0LL;
}
break;
case 224:
v15 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v15 )
{
*a4 = *(_QWORD *)(v15 + 8LL * *(int *)(a2 + 24) + 88);
result = 0LL;
}
break;
case 225:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 280);
break;
case 226:
v16 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v16 )
{
*a4 = *(_QWORD *)(v16 + 8LL * *(int *)(a2 + 24) + 96);
result = 0LL;
}
break;
case 227:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 288);
break;
case 228:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 296);
break;
case 229:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 304);
break;
case 230:
result = *(_DWORD *)(a1 + 684) & 4;
if ( (*(_DWORD *)(a1 + 684) & 4) != 0 )
goto LABEL_63;
if ( *(_QWORD *)(a1 + 280) )
{
*(_QWORD *)&v17 = *(_QWORD *)(a2 + 232) ^ LC3;
*(double *)a4 = v17;
v18 = v17 - *(double *)(a2 + 240);
*(double *)a4 = v18;
if ( (*(_DWORD *)(a1 + 684) & 8) != 0 )
{
if ( (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
*(double *)a4 = v18 + *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72);
}
else
{
result = 0LL;
}
}
break;
case 231:
v19 = *(_DWORD *)(a1 + 684);
if ( (v19 & 4) != 0 )
{
LABEL_63:
errMsg = (char *)calloc(1uLL, 0x30uLL);
errRtn = "BJTask";
strcpy(errMsg, "Current and power not available for ac analysis");
result = 111LL;
}
else
{
result = v19 & 8;
if ( (_DWORD)result )
{
result = 0LL;
if ( (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
{
v20 = *(_QWORD *)(a1 + 280);
if ( v20 )
{
*a4 = *(_QWORD *)(v20 + 8LL * *(int *)(a2 + 24) + 72) ^ LC3;
result = 0LL;
}
}
}
}
break;
case 232:
result = *(_DWORD *)(a1 + 684) & 4;
if ( (*(_DWORD *)(a1 + 684) & 4) != 0 )
{
errMsg = (char *)calloc(1uLL, 0x30uLL);
errRtn = "BJTask";
strcpy(errMsg, "Current and power not available for ac analysis");
result = 112LL;
}
else if ( *(_QWORD *)(a1 + 280) )
{
v21 = *(_QWORD *)(a1 + 536);
if ( v21 )
{
v22 = *(double *)(v21 + 8LL * *(int *)(a2 + 28)) * *(double *)(a2 + 232);
*(double *)a4 = v22;
v23 = v22 + *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 32)) * *(double *)(a2 + 240);
*(double *)a4 = v23;
if ( (*(_BYTE *)(a1 + 684) & 8) != 0 )
{
if ( (*(_BYTE *)(a1 + 712) & 0x20) != 0 )
{
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
}
else
{
*(double *)a4 = v23
- *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72)
* *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 40));
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
if ( (*(_BYTE *)(a1 + 684) & 8) != 0 && (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
v24 = v24 + *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72);
}
}
else
{
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
}
*(double *)a4 = v24 * *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 36)) + *(double *)a4;
}
}
break;
case 233:
*a4 = *(_QWORD *)(a2 + 200);
result = 0LL;
break;
case 234:
*a4 = *(_QWORD *)(a2 + 208);
result = 0LL;
break;
case 235:
*a4 = *(_QWORD *)(a2 + 224);
result = 0LL;
break;
case 236:
*a4 = *(_QWORD *)(a2 + 216);
result = 0LL;
break;
default:
result = 7LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3, _QWORD *a4)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int64 v12; // rdx
__int64 v13; // rdx
__int64 v14; // rdx
__int64 v15; // rdx
__int64 v16; // rdx
double v17; // xmm0_8
double v18; // xmm0_8
int v19; // eax
__int64 v20; // rdi
__int64 v21; // rdx
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8

switch ( a3 )
{
case 0:
case 5:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
case 123:
case 124:
case 125:
case 126:
case 127:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
case 136:
case 137:
case 138:
case 139:
case 140:
case 141:
case 142:
case 143:
case 144:
case 145:
case 146:
case 147:
case 148:
case 149:
case 150:
case 151:
case 152:
case 153:
case 154:
case 155:
case 156:
case 157:
case 158:
case 159:
case 160:
case 161:
case 162:
case 163:
case 164:
case 165:
case 166:
case 167:
case 168:
case 169:
case 170:
case 171:
case 172:
case 173:
case 174:
case 175:
case 176:
case 177:
case 178:
case 179:
case 180:
case 181:
case 182:
case 183:
case 184:
case 185:
case 186:
case 187:
case 188:
case 189:
case 190:
case 191:
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 198:
case 199:
case 200:
result = 7LL;
break;
case 1:
*a4 = *(_QWORD *)(a2 + 56);
result = 0LL;
break;
case 2:
*(_DWORD *)a4 = *(_BYTE *)(a2 + 1184) & 1;
result = 0LL;
break;
case 3:
*a4 = *(_QWORD *)(a2 + 64);
result = 0LL;
break;
case 4:
*a4 = *(_QWORD *)(a2 + 72);
result = 0LL;
break;
case 6:
*(double *)a4 = *(double *)(a2 + 80) - 273.15;
result = 0LL;
break;
case 201:
v5 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v5 )
{
*(double *)a4 = *(double *)(a2 + 264)
/ (fmax(
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL) - 16),
fmax(
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL)),
*(double *)(v5 + 8 * (*(int *)(a2 + 24) + 7LL) + 32)))
* 6.283185307179586);
result = 0LL;
}
break;
case 202:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 28);
result = 0LL;
break;
case 203:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 32);
result = 0LL;
break;
case 204:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 36);
result = 0LL;
break;
case 205:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 40);
result = 0LL;
break;
case 206:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 44);
result = 0LL;
break;
case 207:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 48);
result = 0LL;
break;
case 208:
*(_DWORD *)a4 = *(_DWORD *)(a2 + 52);
result = 0LL;
break;
case 209:
v6 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v6 )
{
*a4 = *(_QWORD *)(v6 + 8LL * *(int *)(a2 + 24));
result = 0LL;
}
break;
case 210:
v7 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v7 )
{
*a4 = *(_QWORD *)(v7 + 8LL * *(int *)(a2 + 24) + 8);
result = 0LL;
}
break;
case 211:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 232);
break;
case 212:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 240);
break;
case 213:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 248);
break;
case 214:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 256);
break;
case 215:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 264);
break;
case 216:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 272);
break;
case 217:
v8 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v8 )
{
*a4 = *(_QWORD *)(v8 + 8LL * *(int *)(a2 + 24) + 32);
result = 0LL;
}
break;
case 218:
v9 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v9 )
{
*a4 = *(_QWORD *)(v9 + 8LL * *(int *)(a2 + 24) + 40);
result = 0LL;
}
break;
case 219:
v10 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v10 )
{
*a4 = *(_QWORD *)(v10 + 8LL * *(int *)(a2 + 24) + 48);
result = 0LL;
}
break;
case 220:
v11 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v11 )
{
*a4 = *(_QWORD *)(v11 + 8LL * *(int *)(a2 + 24) + 56);
result = 0LL;
}
break;
case 221:
v12 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v12 )
{
*a4 = *(_QWORD *)(v12 + 8LL * *(int *)(a2 + 24) + 64);
result = 0LL;
}
break;
case 222:
v13 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v13 )
{
*a4 = *(_QWORD *)(v13 + 8LL * *(int *)(a2 + 24) + 72);
result = 0LL;
}
break;
case 223:
v14 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v14 )
{
*a4 = *(_QWORD *)(v14 + 8LL * *(int *)(a2 + 24) + 80);
result = 0LL;
}
break;
case 224:
v15 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v15 )
{
*a4 = *(_QWORD *)(v15 + 8LL * *(int *)(a2 + 24) + 88);
result = 0LL;
}
break;
case 225:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 280);
break;
case 226:
v16 = *(_QWORD *)(a1 + 280);
result = 0LL;
if ( v16 )
{
*a4 = *(_QWORD *)(v16 + 8LL * *(int *)(a2 + 24) + 96);
result = 0LL;
}
break;
case 227:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 288);
break;
case 228:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 296);
break;
case 229:
result = 0LL;
if ( *(_QWORD *)(a1 + 280) )
*a4 = *(_QWORD *)(a2 + 304);
break;
case 230:
result = *(_DWORD *)(a1 + 684) & 4;
if ( (*(_DWORD *)(a1 + 684) & 4) != 0 )
goto LABEL_63;
if ( *(_QWORD *)(a1 + 280) )
{
*(_QWORD *)&v17 = *(_QWORD *)(a2 + 232) ^ LC3;
*(double *)a4 = v17;
v18 = v17 - *(double *)(a2 + 240);
*(double *)a4 = v18;
if ( (*(_DWORD *)(a1 + 684) & 8) != 0 )
{
if ( (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
*(double *)a4 = v18 + *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72);
}
else
{
result = 0LL;
}
}
break;
case 231:
v19 = *(_DWORD *)(a1 + 684);
if ( (v19 & 4) != 0 )
{
LABEL_63:
errMsg = (char *)calloc(1uLL, 0x30uLL);
errRtn = "BJTask";
strcpy(errMsg, "Current and power not available for ac analysis");
result = 111LL;
}
else
{
result = v19 & 8;
if ( (_DWORD)result )
{
result = 0LL;
if ( (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
{
v20 = *(_QWORD *)(a1 + 280);
if ( v20 )
{
*a4 = *(_QWORD *)(v20 + 8LL * *(int *)(a2 + 24) + 72) ^ LC3;
result = 0LL;
}
}
}
}
break;
case 232:
result = *(_DWORD *)(a1 + 684) & 4;
if ( (*(_DWORD *)(a1 + 684) & 4) != 0 )
{
errMsg = (char *)calloc(1uLL, 0x30uLL);
errRtn = "BJTask";
strcpy(errMsg, "Current and power not available for ac analysis");
result = 112LL;
}
else if ( *(_QWORD *)(a1 + 280) )
{
v21 = *(_QWORD *)(a1 + 536);
if ( v21 )
{
v22 = *(double *)(v21 + 8LL * *(int *)(a2 + 28)) * *(double *)(a2 + 232);
*(double *)a4 = v22;
v23 = v22 + *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 32)) * *(double *)(a2 + 240);
*(double *)a4 = v23;
if ( (*(_BYTE *)(a1 + 684) & 8) != 0 )
{
if ( (*(_BYTE *)(a1 + 712) & 0x20) != 0 )
{
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
}
else
{
*(double *)a4 = v23
- *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72)
* *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 40));
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
if ( (*(_BYTE *)(a1 + 684) & 8) != 0 && (*(_BYTE *)(a1 + 712) & 0x20) == 0 )
v24 = v24 + *(double *)(*(_QWORD *)(a1 + 280) + 8LL * *(int *)(a2 + 24) + 72);
}
}
else
{
v24 = COERCE_DOUBLE(*(_QWORD *)(a2 + 232) ^ LC3) - *(double *)(a2 + 240);
}
*(double *)a4 = v24 * *(double *)(*(_QWORD *)(a1 + 536) + 8LL * *(int *)(a2 + 36)) + *(double *)a4;
}
}
break;
case 233:
*a4 = *(_QWORD *)(a2 + 200);
result = 0LL;
break;
case 234:
*a4 = *(_QWORD *)(a2 + 208);
result = 0LL;
break;
case 235:
*a4 = *(_QWORD *)(a2 + 224);
result = 0LL;
break;
case 236:
*a4 = *(_QWORD *)(a2 + 216);
result = 0LL;
break;
default:
result = 7LL;
break;
}
return result;
}

original_code:
int
BJTask(CKTcircuit *ckt, GENinstance *instPtr, int which, IFvalue *value, IFvalue *select)
{
    BJTinstance *here = (BJTinstance*)instPtr;
    double tmp;
    int itmp;
    double vr;
    double vi;
    double sr;
    double si;
    double vm;
    static char *msg = "Current and power not available for ac analysis";
    switch(which) {
        case 201:
            tmp = ((*(ckt->CKTstates[0] + here->BJTstate+11)) > (*(ckt->CKTstates[0] + here->BJTstate+15)) ? (*(ckt->CKTstates[0] + here->BJTstate+11)) : (*(ckt->CKTstates[0] + here->BJTstate+15)));
            value->rValue = here->BJTstate+6/(2 * 3.14159265358979323846 *
                ((*(ckt->CKTstates[0] + here->BJTstate+9)) > (tmp) ? (*(ckt->CKTstates[0] + here->BJTstate+9)) : (tmp)));
            return(0);
        case 7:
            value->rValue = here->BJTtemp - (273.15);
            return(0);
        case 8:
            value->rValue = here->BJTdtemp;
            return(0);
        case 1:
            value->rValue = here->BJTarea;
            return(0);
 case 10:
            value->rValue = here->BJTareab;
            return(0);
 case 11:
            value->rValue = here->BJTareac;
            return(0);
 case 9:
            value->rValue = here->BJTm;
            return(0);
        case 2:
            value->iValue = here->BJToff;
            return(0);
        case 3:
            value->rValue = here->BJTicVBE;
            return(0);
        case 4:
            value->rValue = here->BJTicVCE;
            return(0);
        case 202:
            value->iValue = here->BJTcolNode;
            return(0);
        case 203:
            value->iValue = here->BJTbaseNode;
            return(0);
        case 204:
            value->iValue = here->BJTemitNode;
            return(0);
        case 205:
            value->iValue = here->BJTsubstNode;
            return(0);
        case 206:
            value->iValue = here->BJTcolPrimeNode;
            return(0);
        case 207:
            value->iValue = here->BJTbasePrimeNode;
            return(0);
        case 208:
            value->iValue = here->BJTemitPrimeNode;
            return(0);
        case 209:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate);
            return(0);
        case 210:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+1);
            return(0);
        case 211:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+2);
     value->rValue *= here->BJTm;
            return(0);
        case 212:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+3);
     value->rValue *= here->BJTm;
            return(0);
        case 213:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+4);
     value->rValue *= here->BJTm;
            return(0);
        case 214:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+5);
     value->rValue *= here->BJTm;
            return(0);
        case 215:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+6);
     value->rValue *= here->BJTm;
            return(0);
        case 216:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+7);
     value->rValue *= here->BJTm;
            return(0);
        case 217:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+8);
     value->rValue *= here->BJTm;
            return(0);
        case 218:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+9);
     value->rValue *= here->BJTm;
            return(0);
        case 219:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+10);
     value->rValue *= here->BJTm;
            return(0);
        case 220:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+11);
     value->rValue *= here->BJTm;
            return(0);
        case 221:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+12);
     value->rValue *= here->BJTm;
            return(0);
        case 222:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+13);
     value->rValue *= here->BJTm;
            return(0);
        case 223:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+14);
     value->rValue *= here->BJTm;
            return(0);
        case 224:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+15);
     value->rValue *= here->BJTm;
            return(0);
        case 225:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+16);
     value->rValue *= here->BJTm;
            return(0);
        case 226:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+17);
     value->rValue *= here->BJTm;
            return(0);
        case 227:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+18);
     value->rValue *= here->BJTm;
            return(0);
        case 228:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+19);
     value->rValue *= here->BJTm;
            return(0);
        case 229:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+20);
     value->rValue *= here->BJTm;
            return(0);
    case 235:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_Sap[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 230:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 231:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 232:
        if(ckt->CKTsenInfo){
           vr = *(ckt->CKTrhsOld + select->iValue + 1);
           vi = *(ckt->CKTirhsOld + select->iValue + 1);
           vm = sqrt(vr*vr + vi*vi);
           if(vm == 0){
             value->rValue = 0;
             return(0);
           }
           sr = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
                here->BJTsenParmNo);
           si = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
                here->BJTsenParmNo);
               value->rValue = (vr * sr + vi * si)/vm;
            }
        return(0);
    case 233:
        if(ckt->CKTsenInfo){
           vr = *(ckt->CKTrhsOld + select->iValue + 1);
           vi = *(ckt->CKTirhsOld + select->iValue + 1);
           vm = vr*vr + vi*vi;
           if(vm == 0){
             value->rValue = 0;
             return(0);
           }
           sr = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
                here->BJTsenParmNo);
           si = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
                here->BJTsenParmNo);
               value->rValue = (vr * si - vi * sr)/vm;
        }
        return(0);
    case 234:
        if(ckt->CKTsenInfo){
           itmp = select->iValue + 1;
           value->cValue.real= *(ckt->CKTsenInfo->SEN_RHS[itmp]+
               here->BJTsenParmNo);
           value->cValue.imag= *(ckt->CKTsenInfo->SEN_iRHS[itmp]+
               here->BJTsenParmNo);
        }
        return(0);
        case 237 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +11));
            } else if (ckt->CKTcurrentAnalysis & (1 | 2)) {
                value->rValue = 0;
            } else if ((ckt->CKTcurrentAnalysis & 8) &&
                       (ckt->CKTmode & 0x20)) {
                value->rValue = 0;
            } else {
                value->rValue = -*(ckt->CKTstates[0] + here->BJTstate+13);
            }
            return(0);
        case 236 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +11));
            } else {
                value->rValue = -*(ckt->CKTstates[0] + here->BJTstate+2);
                value->rValue -= *(ckt->CKTstates[0] + here->BJTstate+3);
                if ((ckt->CKTcurrentAnalysis & 8) &&
                        !(ckt->CKTmode & 0x20)) {
                    value->rValue += *(ckt->CKTstates[0] + here->BJTstate+13);
                }
            }
            return(0);
        case 238 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +12));
            } else {
                value->rValue = *(ckt->CKTstates[0] + here->BJTstate+2) *
                        *(ckt->CKTrhsOld + here->BJTcolNode);
                value->rValue += *(ckt->CKTstates[0] + here->BJTstate+3) *
                        *(ckt->CKTrhsOld + here->BJTbaseNode);
                if ((ckt->CKTcurrentAnalysis & 8) && !(ckt->CKTmode &
                        0x20)) {
                    value->rValue -= *(ckt->CKTstates[0] + here->BJTstate+13) *
                            *(ckt->CKTrhsOld + here->BJTsubstNode);
                }
                tmp = -*(ckt->CKTstates[0] + here->BJTstate+2);
                tmp -= *(ckt->CKTstates[0] + here->BJTstate+3);
                if ((ckt->CKTcurrentAnalysis & 8) &&
                        !(ckt->CKTmode & 0x20)) {
                    tmp += *(ckt->CKTstates[0] + here->BJTstate+13);
                }
                value->rValue += tmp * *(ckt->CKTrhsOld +
                        here->BJTemitNode);
            }
     value->rValue *= here->BJTm;
            return(0);
 case 239:
     value->rValue = here->BJTcapbe;
     value->rValue *= here->BJTm;
            return(0);
 case 240:
     value->rValue = here->BJTcapbc;
     value->rValue *= here->BJTm;
            return(0);
 case 241:
     value->rValue = here->BJTcapbx;
     value->rValue *= here->BJTm;
            return(0);
 case 242:
     value->rValue = here->BJTcapcs;
     value->rValue *= here->BJTm;
            return(0);
        default:
            return(7);
    }
}

canonical_original_code:
int BJTask(struct CKTcircuit *ckt, struct sGENinstance *instPtr, int which, union uIFvalue *value, union uIFvalue *select)
{
    struct sBJTinstance *here = (BJTinstance*)instPtr;
    double tmp;
    int itmp;
    double vr;
    double vi;
    double sr;
    double si;
    double vm;
    static char *msg = "Current and power not available for ac analysis";
    switch(which) {
        case 201:
            tmp = ((*(ckt->CKTstates[0] + here->BJTstate+11)) > (*(ckt->CKTstates[0] + here->BJTstate+15)) ? (*(ckt->CKTstates[0] + here->BJTstate+11)) : (*(ckt->CKTstates[0] + here->BJTstate+15)));
            value->rValue = here->BJTstate+6/(2 * 3.14159265358979323846 *
                ((*(ckt->CKTstates[0] + here->BJTstate+9)) > (tmp) ? (*(ckt->CKTstates[0] + here->BJTstate+9)) : (tmp)));
            return(0);
        case 7:
            value->rValue = here->BJTtemp - (273.15);
            return(0);
        case 8:
            value->rValue = here->BJTdtemp;
            return(0);
        case 1:
            value->rValue = here->BJTarea;
            return(0);
 case 10:
            value->rValue = here->BJTareab;
            return(0);
 case 11:
            value->rValue = here->BJTareac;
            return(0);
 case 9:
            value->rValue = here->BJTm;
            return(0);
        case 2:
            value->iValue = here->BJToff;
            return(0);
        case 3:
            value->rValue = here->BJTicVBE;
            return(0);
        case 4:
            value->rValue = here->BJTicVCE;
            return(0);
        case 202:
            value->iValue = here->BJTcolNode;
            return(0);
        case 203:
            value->iValue = here->BJTbaseNode;
            return(0);
        case 204:
            value->iValue = here->BJTemitNode;
            return(0);
        case 205:
            value->iValue = here->BJTsubstNode;
            return(0);
        case 206:
            value->iValue = here->BJTcolPrimeNode;
            return(0);
        case 207:
            value->iValue = here->BJTbasePrimeNode;
            return(0);
        case 208:
            value->iValue = here->BJTemitPrimeNode;
            return(0);
        case 209:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate);
            return(0);
        case 210:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+1);
            return(0);
        case 211:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+2);
     value->rValue *= here->BJTm;
            return(0);
        case 212:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+3);
     value->rValue *= here->BJTm;
            return(0);
        case 213:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+4);
     value->rValue *= here->BJTm;
            return(0);
        case 214:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+5);
     value->rValue *= here->BJTm;
            return(0);
        case 215:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+6);
     value->rValue *= here->BJTm;
            return(0);
        case 216:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+7);
     value->rValue *= here->BJTm;
            return(0);
        case 217:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+8);
     value->rValue *= here->BJTm;
            return(0);
        case 218:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+9);
     value->rValue *= here->BJTm;
            return(0);
        case 219:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+10);
     value->rValue *= here->BJTm;
            return(0);
        case 220:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+11);
     value->rValue *= here->BJTm;
            return(0);
        case 221:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+12);
     value->rValue *= here->BJTm;
            return(0);
        case 222:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+13);
     value->rValue *= here->BJTm;
            return(0);
        case 223:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+14);
     value->rValue *= here->BJTm;
            return(0);
        case 224:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+15);
     value->rValue *= here->BJTm;
            return(0);
        case 225:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+16);
     value->rValue *= here->BJTm;
            return(0);
        case 226:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+17);
     value->rValue *= here->BJTm;
            return(0);
        case 227:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+18);
     value->rValue *= here->BJTm;
            return(0);
        case 228:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+19);
     value->rValue *= here->BJTm;
            return(0);
        case 229:
            value->rValue = *(ckt->CKTstates[0] + here->BJTstate+20);
     value->rValue *= here->BJTm;
            return(0);
    case 235:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_Sap[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 230:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 231:
        if(ckt->CKTsenInfo){
           value->rValue = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
               here->BJTsenParmNo);
            }
        return(0);
    case 232:
        if(ckt->CKTsenInfo){
           vr = *(ckt->CKTrhsOld + select->iValue + 1);
           vi = *(ckt->CKTirhsOld + select->iValue + 1);
           vm = sqrt(vr*vr + vi*vi);
           if(vm == 0){
             value->rValue = 0;
             return(0);
           }
           sr = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
                here->BJTsenParmNo);
           si = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
                here->BJTsenParmNo);
               value->rValue = (vr * sr + vi * si)/vm;
            }
        return(0);
    case 233:
        if(ckt->CKTsenInfo){
           vr = *(ckt->CKTrhsOld + select->iValue + 1);
           vi = *(ckt->CKTirhsOld + select->iValue + 1);
           vm = vr*vr + vi*vi;
           if(vm == 0){
             value->rValue = 0;
             return(0);
           }
           sr = *(ckt->CKTsenInfo->SEN_RHS[select->iValue + 1]+
                here->BJTsenParmNo);
           si = *(ckt->CKTsenInfo->SEN_iRHS[select->iValue + 1]+
                here->BJTsenParmNo);
               value->rValue = (vr * si - vi * sr)/vm;
        }
        return(0);
    case 234:
        if(ckt->CKTsenInfo){
           itmp = select->iValue + 1;
           value->cValue.real= *(ckt->CKTsenInfo->SEN_RHS[itmp]+
               here->BJTsenParmNo);
           value->cValue.imag= *(ckt->CKTsenInfo->SEN_iRHS[itmp]+
               here->BJTsenParmNo);
        }
        return(0);
        case 237 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned int)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +11));
            } else if (ckt->CKTcurrentAnalysis & (1 | 2)) {
                value->rValue = 0;
            } else if ((ckt->CKTcurrentAnalysis & 8) &&
                       (ckt->CKTmode & 0x20)) {
                value->rValue = 0;
            } else {
                value->rValue = -*(ckt->CKTstates[0] + here->BJTstate+13);
            }
            return(0);
        case 236 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned int)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +11));
            } else {
                value->rValue = -*(ckt->CKTstates[0] + here->BJTstate+2);
                value->rValue -= *(ckt->CKTstates[0] + here->BJTstate+3);
                if ((ckt->CKTcurrentAnalysis & 8) &&
                        !(ckt->CKTmode & 0x20)) {
                    value->rValue += *(ckt->CKTstates[0] + here->BJTstate+13);
                }
            }
            return(0);
        case 238 :
            if (ckt->CKTcurrentAnalysis & 4) {
                errMsg = tmalloc((unsigned int)(strlen(msg)+1));
                errRtn = "BJTask";
                strcpy(errMsg,msg);
                return((100 +12));
            } else {
                value->rValue = *(ckt->CKTstates[0] + here->BJTstate+2) *
                        *(ckt->CKTrhsOld + here->BJTcolNode);
                value->rValue += *(ckt->CKTstates[0] + here->BJTstate+3) *
                        *(ckt->CKTrhsOld + here->BJTbaseNode);
                if ((ckt->CKTcurrentAnalysis & 8) && !(ckt->CKTmode &
                        0x20)) {
                    value->rValue -= *(ckt->CKTstates[0] + here->BJTstate+13) *
                            *(ckt->CKTrhsOld + here->BJTsubstNode);
                }
                tmp = -*(ckt->CKTstates[0] + here->BJTstate+2);
                tmp -= *(ckt->CKTstates[0] + here->BJTstate+3);
                if ((ckt->CKTcurrentAnalysis & 8) &&
                        !(ckt->CKTmode & 0x20)) {
                    tmp += *(ckt->CKTstates[0] + here->BJTstate+13);
                }
                value->rValue += tmp * *(ckt->CKTrhsOld +
                        here->BJTemitNode);
            }
     value->rValue *= here->BJTm;
            return(0);
 case 239:
     value->rValue = here->BJTcapbe;
     value->rValue *= here->BJTm;
            return(0);
 case 240:
     value->rValue = here->BJTcapbc;
     value->rValue *= here->BJTm;
            return(0);
 case 241:
     value->rValue = here->BJTcapbx;
     value->rValue *= here->BJTm;
            return(0);
 case 242:
     value->rValue = here->BJTcapcs;
     value->rValue *= here->BJTm;
            return(0);
        default:
            return(7);
    }
}

variable_types: struct CKTcircuit { struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; } *GENinstances; char *GENmodName; } **CKThead; struct STATistics { int STATnumIter; int STATtranIter; int STAToldIter; int STATtimePts; int STATaccepted; int STATrejected; double STATtotAnalTime; double STATloadTime; double STATdecompTime; double STATsolveTime; double STATreorderTime; double STATcombineTime; double STATsyncTime; double STATtranTime; double STATtranDecompTime; double STATtranSolveTime; double STATtranLoadTime; double STATtranTruncTime; double STATtranCombTime; double STATtranSyncTime; double STATacTime; double STATacDecompTime; double STATacSolveTime; double STATacLoadTime; double STATacCombTime; double STATacSyncTime; } *CKTstat; double *CKTstates[8]; double CKTtime; double CKTdelta; double CKTdeltaOld[7]; double CKTtemp; double CKTnomTemp; double CKTvt; double CKTag[7]; double CKTagp[7]; int CKTorder; int CKTmaxOrder; int CKTintegrateMethod; void *CKTmatrix; int CKTniState; double *CKTrhs; double *CKTrhsOld; double *CKTrhsSpare; double *CKTirhs; double *CKTirhsOld; double *CKTirhsSpare; double *CKTpred; double *CKTsols[8]; double *CKTrhsOp; double *CKTsenRhs; double *CKTseniRhs; int CKTmaxEqNum; int CKTcurrentAnalysis; struct sCKTnode { char *name; int type; int number; double ic; double nodeset; double *ptr; struct sCKTnode *next; unsigned int icGiven; unsigned int nsGiven; } *CKTnodes; struct sCKTnode *CKTlastNode; int CKTnumStates; long CKTmode; int CKTbypass; int CKTdcMaxIter; int CKTdcTrcvMaxIter; int CKTtranMaxIter; int CKTbreakSize; int CKTbreak; double CKTsaveDelta; double CKTminBreak; double *CKTbreaks; double CKTabstol; double CKTpivotAbsTol; double CKTpivotRelTol; double CKTreltol; double CKTchgtol; double CKTvoltTol; double CKTgmin; double CKTgshunt; double CKTdelmin; double CKTtrtol; double CKTfinalTime; double CKTstep; double CKTmaxStep; double CKTinitTime; double CKTomega; double CKTsrcFact; double CKTdiagGmin; int CKTnumSrcSteps; int CKTnumGminSteps; double CKTgminFactor; int CKTnoncon; double CKTdefaultMosM; double CKTdefaultMosL; double CKTdefaultMosW; double CKTdefaultMosAD; double CKTdefaultMosAS; unsigned int CKThadNodeset; unsigned int CKTfixLimit; unsigned int CKTnoOpIter; unsigned int CKTisSetup; struct sJOB { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; } *CKTcurJob; struct SENstruct { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; int SENnumVal; char **SENdevices; char **SENparmNames; unsigned int SENinitflag; unsigned int SENicflag; unsigned int SENstatus; unsigned int SENacpertflag; int SENmode; int SENparms; double SENpertfac; double **SEN_Sap; double **SEN_RHS; double **SEN_iRHS; int SENsize; void *SEN_Jacmat; double *SEN_parmVal; char **SEN_parmName; } *CKTsenInfo; double *CKTtimePoints; double *CKTdeltaList; int CKTtimeListSize; int CKTtimeIndex; int CKTsizeIncr; unsigned int CKTtryToCompact; unsigned int CKTbadMos3; unsigned int CKTkeepOpInfo; unsigned int CKTcopyNodesets; unsigned int CKTnodeDamping; double CKTabsDv; double CKTrelDv; int CKTtroubleNode; struct sGENinstance *CKTtroubleElt; } *

variable_types:
instPtr
struct sGENinstance *

variable_types: which int

variable_types: union uIFvalue { int iValue; double rValue; struct sIFcomplex { double real; double imag; } cValue; char *sValue; char *uValue; void *nValue; struct sIFparseTree { int numVars; int *varTypes; union uIFvalue *vars; int (*IFeval)(struct sIFparseTree *, double, double *, double *, double *); } *tValue; struct { int numValue; union { int *iVec; double *rVec; struct sIFcomplex *cVec; char **sVec; char **uVec; void **nVec; } vec; } v; } *

variable_types:
select
union uIFvalue *

variable_types: struct sBJTinstance { struct sBJTmodel { int BJTmodType; struct sBJTmodel *BJTnextModel; struct sBJTinstance *BJTinstances; char *BJTmodName; int BJTtype; double BJTtnom; double BJTsatCur; double BJTbetaF; double BJTemissionCoeffF; double BJTearlyVoltF; double BJTrollOffF; double BJTleakBEcurrent; double BJTc2; double BJTleakBEemissionCoeff; double BJTbetaR; double BJTemissionCoeffR; double BJTearlyVoltR; double BJTrollOffR; double BJTleakBCcurrent; double BJTc4; double BJTleakBCemissionCoeff; double BJTbaseResist; double BJTbaseCurrentHalfResist; double BJTminBaseResist; double BJTemitterResist; double BJTcollectorResist; double BJTdepletionCapBE; double BJTpotentialBE; double BJTjunctionExpBE; double BJTtransitTimeF; double BJTtransitTimeBiasCoeffF; double BJTtransitTimeFVBC; double BJTtransitTimeHighCurrentF; double BJTexcessPhase; double BJTdepletionCapBC; double BJTpotentialBC; double BJTjunctionExpBC; double BJTbaseFractionBCcap; double BJTtransitTimeR; double BJTcapCS; double BJTpotentialSubstrate; double BJTexponentialSubstrate; double BJTbetaExp; double BJTenergyGap; double BJTtempExpIS; double BJTdepletionCapCoeff; double BJTfNcoef; double BJTfNexp; double BJTinvEarlyVoltF; double BJTinvEarlyVoltR; double BJTinvRollOffF; double BJTinvRollOffR; double BJTcollectorConduct; double BJTemitterConduct; double BJTtransitTimeVBCFactor; double BJTexcessPhaseFactor; double BJTf2; double BJTf3; double BJTf6; double BJTf7; unsigned int BJTtnomGiven; unsigned int BJTsatCurGiven; unsigned int BJTbetaFGiven; unsigned int BJTemissionCoeffFGiven; unsigned int BJTearlyVoltFGiven; unsigned int BJTrollOffFGiven; unsigned int BJTleakBEcurrentGiven; unsigned int BJTc2Given; unsigned int BJTleakBEemissionCoeffGiven; unsigned int BJTbetaRGiven; unsigned int BJTemissionCoeffRGiven; unsigned int BJTearlyVoltRGiven; unsigned int BJTrollOffRGiven; unsigned int BJTleakBCcurrentGiven; unsigned int BJTc4Given; unsigned int BJTleakBCemissionCoeffGiven; unsigned int BJTbaseResistGiven; unsigned int BJTbaseCurrentHalfResistGiven; unsigned int BJTminBaseResistGiven; unsigned int BJTemitterResistGiven; unsigned int BJTcollectorResistGiven; unsigned int BJTdepletionCapBEGiven; unsigned int BJTpotentialBEGiven; unsigned int BJTjunctionExpBEGiven; unsigned int BJTtransitTimeFGiven; unsigned int BJTtransitTimeBiasCoeffFGiven; unsigned int BJTtransitTimeFVBCGiven; unsigned int BJTtransitTimeHighCurrentFGiven; unsigned int BJTexcessPhaseGiven; unsigned int BJTdepletionCapBCGiven; unsigned int BJTpotentialBCGiven; unsigned int BJTjunctionExpBCGiven; unsigned int BJTbaseFractionBCcapGiven; unsigned int BJTtransitTimeRGiven; unsigned int BJTcapCSGiven; unsigned int BJTpotentialSubstrateGiven; unsigned int BJTexponentialSubstrateGiven; unsigned int BJTbetaExpGiven; unsigned int BJTenergyGapGiven; unsigned int BJTtempExpISGiven; unsigned int BJTdepletionCapCoeffGiven; unsigned int BJTfNcoefGiven; unsigned int BJTfNexpGiven; } *BJTmodPtr; struct sBJTinstance *BJTnextInstance; char *BJTname; int BJTowner; int BJTstate; int BJTcolNode; int BJTbaseNode; int BJTemitNode; int BJTsubstNode; int BJTcolPrimeNode; int BJTbasePrimeNode; int BJTemitPrimeNode; double BJTarea; double BJTareab; double BJTareac; double BJTm; double BJTicVBE; double BJTicVCE; double BJTtemp; double BJTdtemp; double BJTtSatCur; double BJTtBetaF; double BJTtBetaR; double BJTtBEleakCur; double BJTtBCleakCur; double BJTtBEcap; double BJTtBEpot; double BJTtBCcap; double BJTtBCpot; double BJTtDepCap; double BJTtf1; double BJTtf4; double BJTtf5; double BJTtVcrit; double *BJTcolColPrimePtr; double *BJTbaseBasePrimePtr; double *BJTemitEmitPrimePtr; double *BJTcolPrimeColPtr; double *BJTcolPrimeBasePrimePtr; double *BJTcolPrimeEmitPrimePtr; double *BJTbasePrimeBasePtr; double *BJTbasePrimeColPrimePtr; double *BJTbasePrimeEmitPrimePtr; double *BJTemitPrimeEmitPtr; double *BJTemitPrimeColPrimePtr; double *BJTemitPrimeBasePrimePtr; double *BJTcolColPtr; double *BJTbaseBasePtr; double *BJTemitEmitPtr; double *BJTcolPrimeColPrimePtr; double *BJTbasePrimeBasePrimePtr; double *BJTemitPrimeEmitPrimePtr; double *BJTsubstSubstPtr; double *BJTcolPrimeSubstPtr; double *BJTsubstColPrimePtr; double *BJTbaseColPrimePtr; double *BJTcolPrimeBasePtr; unsigned int BJToff; unsigned int BJTtempGiven; unsigned int BJTdtempGiven; unsigned int BJTareaGiven; unsigned int BJTareabGiven; unsigned int BJTareacGiven; unsigned int BJTmGiven; unsigned int BJTicVBEGiven; unsigned int BJTicVCEGiven; unsigned int BJTsenPertFlag; int BJTsenParmNo; double BJTcapbe; double BJTcapbc; double BJTcapcs; double BJTcapbx; double *BJTsens; double BJTdCoeffs[65]; double BJTnVar[3][7]; } *

variable_types: itmp int

variable_types: vr double

variable_types: vi double

variable_types: sr double

variable_types: si double

variable_types: vm double

variable_types:
msg
char *

user_defined_types: union uIFvalue { int iValue; double rValue; struct sIFcomplex cValue; char *sValue; char *uValue; void *nValue; struct sIFparseTree *tValue; struct { int numValue; union { int *iVec; double *rVec; struct sIFcomplex *cVec; char **sVec; char **uVec; void **nVec; } vec; } v; }

user_defined_types: struct sBJTinstance { struct sBJTmodel *BJTmodPtr; struct sBJTinstance *BJTnextInstance; char *BJTname; int BJTowner; int BJTstate; int BJTcolNode; int BJTbaseNode; int BJTemitNode; int BJTsubstNode; int BJTcolPrimeNode; int BJTbasePrimeNode; int BJTemitPrimeNode; double BJTarea; double BJTareab; double BJTareac; double BJTm; double BJTicVBE; double BJTicVCE; double BJTtemp; double BJTdtemp; double BJTtSatCur; double BJTtBetaF; double BJTtBetaR; double BJTtBEleakCur; double BJTtBCleakCur; double BJTtBEcap; double BJTtBEpot; double BJTtBCcap; double BJTtBCpot; double BJTtDepCap; double BJTtf1; double BJTtf4; double BJTtf5; double BJTtVcrit; double *BJTcolColPrimePtr; double *BJTbaseBasePrimePtr; double *BJTemitEmitPrimePtr; double *BJTcolPrimeColPtr; double *BJTcolPrimeBasePrimePtr; double *BJTcolPrimeEmitPrimePtr; double *BJTbasePrimeBasePtr; double *BJTbasePrimeColPrimePtr; double *BJTbasePrimeEmitPrimePtr; double *BJTemitPrimeEmitPtr; double *BJTemitPrimeColPrimePtr; double *BJTemitPrimeBasePrimePtr; double *BJTcolColPtr; double *BJTbaseBasePtr; double *BJTemitEmitPtr; double *BJTcolPrimeColPrimePtr; double *BJTbasePrimeBasePrimePtr; double *BJTemitPrimeEmitPrimePtr; double *BJTsubstSubstPtr; double *BJTcolPrimeSubstPtr; double *BJTsubstColPrimePtr; double *BJTbaseColPrimePtr; double *BJTcolPrimeBasePtr; unsigned int BJToff; unsigned int BJTtempGiven; unsigned int BJTdtempGiven; unsigned int BJTareaGiven; unsigned int BJTareabGiven; unsigned int BJTareacGiven; unsigned int BJTmGiven; unsigned int BJTicVBEGiven; unsigned int BJTicVCEGiven; unsigned int BJTsenPertFlag; int BJTsenParmNo; double BJTcapbe; double BJTcapbc; double BJTcapcs; double BJTcapbx; double *BJTsens; double BJTdCoeffs[65]; double BJTnVar[3][7]; }


BJTtemp

repo: gserdyuk/gnucap-a

original_code:
int
BJTtemp(GENmodel *inModel, CKTcircuit *ckt)
{
    BJTmodel *model = (BJTmodel *)inModel;
    BJTinstance *here;
    double xfc;
    double vt;
    double ratlog;
    double ratio1;
    double factlog;
    double bfactor;
    double factor;
    double fact1,fact2;
    double pbo,pbfact;
    double gmaold,gmanew;
    double egfet;
    double arg;
    for( ; model != ((void *)0); model = model->BJTnextModel ) {
        if(!model->BJTtnomGiven) model->BJTtnom = ckt->CKTnomTemp;
        fact1 = model->BJTtnom/300.15;
        if(!model->BJTleakBEcurrentGiven) {
            if(model->BJTc2Given) {
                model->BJTleakBEcurrent = model->BJTc2 * model->BJTsatCur;
            } else {
                model->BJTleakBEcurrent = 0;
            }
        }
        if(!model->BJTleakBCcurrentGiven) {
            if(model->BJTc4Given) {
                model->BJTleakBCcurrent = model->BJTc4 * model->BJTsatCur;
            } else {
                model->BJTleakBCcurrent = 0;
            }
        }
        if(!model->BJTminBaseResistGiven) {
            model->BJTminBaseResist = model->BJTbaseResist;
        }
        if(model->BJTearlyVoltFGiven && model->BJTearlyVoltF != 0) {
            model->BJTinvEarlyVoltF = 1/model->BJTearlyVoltF;
        } else {
            model->BJTinvEarlyVoltF = 0;
        }
        if(model->BJTrollOffFGiven && model->BJTrollOffF != 0) {
            model->BJTinvRollOffF = 1/model->BJTrollOffF;
        } else {
            model->BJTinvRollOffF = 0;
        }
        if(model->BJTearlyVoltRGiven && model->BJTearlyVoltR != 0) {
            model->BJTinvEarlyVoltR = 1/model->BJTearlyVoltR;
        } else {
            model->BJTinvEarlyVoltR = 0;
        }
        if(model->BJTrollOffRGiven && model->BJTrollOffR != 0) {
            model->BJTinvRollOffR = 1/model->BJTrollOffR;
        } else {
            model->BJTinvRollOffR = 0;
        }
        if(model->BJTcollectorResistGiven && model->BJTcollectorResist != 0) {
            model->BJTcollectorConduct = 1/model->BJTcollectorResist;
        } else {
            model->BJTcollectorConduct = 0;
        }
        if(model->BJTemitterResistGiven && model->BJTemitterResist != 0) {
            model->BJTemitterConduct = 1/model->BJTemitterResist;
        } else {
            model->BJTemitterConduct = 0;
        }
        if(model->BJTtransitTimeFVBCGiven && model->BJTtransitTimeFVBC != 0) {
            model->BJTtransitTimeVBCFactor =1/ (model->BJTtransitTimeFVBC*1.44);
        } else {
            model->BJTtransitTimeVBCFactor = 0;
        }
        model->BJTexcessPhaseFactor = (model->BJTexcessPhase/
            (180.0/3.14159265358979323846)) * model->BJTtransitTimeF;
        if(model->BJTdepletionCapCoeffGiven) {
            if(model->BJTdepletionCapCoeff>.9999) {
                model->BJTdepletionCapCoeff=.9999;
                (*(SPfrontEnd->IFerror))(0x1,
                        "BJT model %s, parameter fc limited to 0.9999",
                        &(model->BJTmodName));
            }
        } else {
            model->BJTdepletionCapCoeff=.5;
        }
        xfc = log(1-model->BJTdepletionCapCoeff);
        model->BJTf2 = exp((1 + model->BJTjunctionExpBE) * xfc);
        model->BJTf3 = 1 - model->BJTdepletionCapCoeff *
                (1 + model->BJTjunctionExpBE);
        model->BJTf6 = exp((1+model->BJTjunctionExpBC)*xfc);
        model->BJTf7 = 1 - model->BJTdepletionCapCoeff *
                (1 + model->BJTjunctionExpBC);
        for (here = model->BJTinstances; here != ((void *)0) ;
                here=here->BJTnextInstance) {
     if (here->BJTowner != ARCHme) continue;
            if(!here->BJTdtempGiven)
        here->BJTdtemp = 0.0;
            if(!here->BJTtempGiven)
        here->BJTtemp = ckt->CKTtemp + here->BJTdtemp;
     vt = here->BJTtemp * CONSTKoverQ;
            fact2 = here->BJTtemp/300.15;
            egfet = 1.16-(7.02e-4*here->BJTtemp*here->BJTtemp)/
                    (here->BJTtemp+1108);
            arg = -egfet/(2*(1.3806226e-23)*here->BJTtemp)+
                    1.1150877/((1.3806226e-23)*(300.15 +300.15));
            pbfact = -2*vt*(1.5*log(fact2)+(1.6021918e-19)*arg);
            ratlog = log(here->BJTtemp/model->BJTtnom);
            ratio1 = here->BJTtemp/model->BJTtnom -1;
            factlog = ratio1 * model->BJTenergyGap/vt +
                    model->BJTtempExpIS*ratlog;
            factor = exp(factlog);
            here->BJTtSatCur = model->BJTsatCur * factor;
            bfactor = exp(ratlog*model->BJTbetaExp);
            here->BJTtBetaF = model->BJTbetaF * bfactor;
            here->BJTtBetaR = model->BJTbetaR * bfactor;
            here->BJTtBEleakCur = model->BJTleakBEcurrent *
                    exp(factlog/model->BJTleakBEemissionCoeff)/bfactor;
            here->BJTtBCleakCur = model->BJTleakBCcurrent *
                    exp(factlog/model->BJTleakBCemissionCoeff)/bfactor;
            pbo = (model->BJTpotentialBE-pbfact)/fact1;
            gmaold = (model->BJTpotentialBE-pbo)/pbo;
            here->BJTtBEcap = model->BJTdepletionCapBE/
                    (1+model->BJTjunctionExpBE*
                    (4e-4*(model->BJTtnom-300.15)-gmaold));
            here->BJTtBEpot = fact2 * pbo+pbfact;
            gmanew = (here->BJTtBEpot-pbo)/pbo;
            here->BJTtBEcap *= 1+model->BJTjunctionExpBE*
                    (4e-4*(here->BJTtemp-300.15)-gmanew);
            pbo = (model->BJTpotentialBC-pbfact)/fact1;
            gmaold = (model->BJTpotentialBC-pbo)/pbo;
            here->BJTtBCcap = model->BJTdepletionCapBC/
                    (1+model->BJTjunctionExpBC*
                    (4e-4*(model->BJTtnom-300.15)-gmaold));
            here->BJTtBCpot = fact2 * pbo+pbfact;
            gmanew = (here->BJTtBCpot-pbo)/pbo;
            here->BJTtBCcap *= 1+model->BJTjunctionExpBC*
                    (4e-4*(here->BJTtemp-300.15)-gmanew);
            here->BJTtDepCap = model->BJTdepletionCapCoeff * here->BJTtBEpot;
            here->BJTtf1 = here->BJTtBEpot * (1 - exp((1 -
                    model->BJTjunctionExpBE) * xfc)) /
                    (1 - model->BJTjunctionExpBE);
            here->BJTtf4 = model->BJTdepletionCapCoeff * here->BJTtBCpot;
            here->BJTtf5 = here->BJTtBCpot * (1 - exp((1 -
                    model->BJTjunctionExpBC) * xfc)) /
                    (1 - model->BJTjunctionExpBC);
            here->BJTtVcrit = vt *
                     log(vt / (CONSTroot2*here->BJTtSatCur*here->BJTarea));
        }
    }
    return(0);
}

canonical_original_code:
int BJTtemp(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sBJTmodel *model = (BJTmodel *)inModel;
    struct sBJTinstance *here;
    double xfc;
    double vt;
    double ratlog;
    double ratio1;
    double factlog;
    double bfactor;
    double factor;
    double fact1; double fact2;
    double pbo; double pbfact;
    double gmaold; double gmanew;
    double egfet;
    double arg;
    for( ; model != ((void *)0); model = model->BJTnextModel ) {
        if(!model->BJTtnomGiven) model->BJTtnom = ckt->CKTnomTemp;
        fact1 = model->BJTtnom/300.15;
        if(!model->BJTleakBEcurrentGiven) {
            if(model->BJTc2Given) {
                model->BJTleakBEcurrent = model->BJTc2 * model->BJTsatCur;
            } else {
                model->BJTleakBEcurrent = 0;
            }
        }
        if(!model->BJTleakBCcurrentGiven) {
            if(model->BJTc4Given) {
                model->BJTleakBCcurrent = model->BJTc4 * model->BJTsatCur;
            } else {
                model->BJTleakBCcurrent = 0;
            }
        }
        if(!model->BJTminBaseResistGiven) {
            model->BJTminBaseResist = model->BJTbaseResist;
        }
        if(model->BJTearlyVoltFGiven && model->BJTearlyVoltF != 0) {
            model->BJTinvEarlyVoltF = 1/model->BJTearlyVoltF;
        } else {
            model->BJTinvEarlyVoltF = 0;
        }
        if(model->BJTrollOffFGiven && model->BJTrollOffF != 0) {
            model->BJTinvRollOffF = 1/model->BJTrollOffF;
        } else {
            model->BJTinvRollOffF = 0;
        }
        if(model->BJTearlyVoltRGiven && model->BJTearlyVoltR != 0) {
            model->BJTinvEarlyVoltR = 1/model->BJTearlyVoltR;
        } else {
            model->BJTinvEarlyVoltR = 0;
        }
        if(model->BJTrollOffRGiven && model->BJTrollOffR != 0) {
            model->BJTinvRollOffR = 1/model->BJTrollOffR;
        } else {
            model->BJTinvRollOffR = 0;
        }
        if(model->BJTcollectorResistGiven && model->BJTcollectorResist != 0) {
            model->BJTcollectorConduct = 1/model->BJTcollectorResist;
        } else {
            model->BJTcollectorConduct = 0;
        }
        if(model->BJTemitterResistGiven && model->BJTemitterResist != 0) {
            model->BJTemitterConduct = 1/model->BJTemitterResist;
        } else {
            model->BJTemitterConduct = 0;
        }
        if(model->BJTtransitTimeFVBCGiven && model->BJTtransitTimeFVBC != 0) {
            model->BJTtransitTimeVBCFactor =1/ (model->BJTtransitTimeFVBC*1.44);
        } else {
            model->BJTtransitTimeVBCFactor = 0;
        }
        model->BJTexcessPhaseFactor = (model->BJTexcessPhase/
            (180.0/3.14159265358979323846)) * model->BJTtransitTimeF;
        if(model->BJTdepletionCapCoeffGiven) {
            if(model->BJTdepletionCapCoeff>.9999) {
                model->BJTdepletionCapCoeff=.9999;
                (*(SPfrontEnd->IFerror))(0x1,
                        "BJT model %s, parameter fc limited to 0.9999",
                        &(model->BJTmodName));
            }
        } else {
            model->BJTdepletionCapCoeff=.5;
        }
        xfc = log(1-model->BJTdepletionCapCoeff);
        model->BJTf2 = exp((1 + model->BJTjunctionExpBE) * xfc);
        model->BJTf3 = 1 - model->BJTdepletionCapCoeff *
                (1 + model->BJTjunctionExpBE);
        model->BJTf6 = exp((1+model->BJTjunctionExpBC)*xfc);
        model->BJTf7 = 1 - model->BJTdepletionCapCoeff *
                (1 + model->BJTjunctionExpBC);
        for (here = model->BJTinstances; here != ((void *)0) ;
                here=here->BJTnextInstance) {
     if (here->BJTowner != ARCHme) continue;
            if(!here->BJTdtempGiven)
        here->BJTdtemp = 0.0;
            if(!here->BJTtempGiven)
        here->BJTtemp = ckt->CKTtemp + here->BJTdtemp;
     vt = here->BJTtemp * CONSTKoverQ;
            fact2 = here->BJTtemp/300.15;
            egfet = 1.16-(7.02e-4*here->BJTtemp*here->BJTtemp)/
                    (here->BJTtemp+1108);
            arg = -egfet/(2*(1.3806226e-23)*here->BJTtemp)+
                    1.1150877/((1.3806226e-23)*(300.15 +300.15));
            pbfact = -2*vt*(1.5*log(fact2)+(1.6021918e-19)*arg);
            ratlog = log(here->BJTtemp/model->BJTtnom);
            ratio1 = here->BJTtemp/model->BJTtnom -1;
            factlog = ratio1 * model->BJTenergyGap/vt +
                    model->BJTtempExpIS*ratlog;
            factor = exp(factlog);
            here->BJTtSatCur = model->BJTsatCur * factor;
            bfactor = exp(ratlog*model->BJTbetaExp);
            here->BJTtBetaF = model->BJTbetaF * bfactor;
            here->BJTtBetaR = model->BJTbetaR * bfactor;
            here->BJTtBEleakCur = model->BJTleakBEcurrent *
                    exp(factlog/model->BJTleakBEemissionCoeff)/bfactor;
            here->BJTtBCleakCur = model->BJTleakBCcurrent *
                    exp(factlog/model->BJTleakBCemissionCoeff)/bfactor;
            pbo = (model->BJTpotentialBE-pbfact)/fact1;
            gmaold = (model->BJTpotentialBE-pbo)/pbo;
            here->BJTtBEcap = model->BJTdepletionCapBE/
                    (1+model->BJTjunctionExpBE*
                    (4e-4*(model->BJTtnom-300.15)-gmaold));
            here->BJTtBEpot = fact2 * pbo+pbfact;
            gmanew = (here->BJTtBEpot-pbo)/pbo;
            here->BJTtBEcap *= 1+model->BJTjunctionExpBE*
                    (4e-4*(here->BJTtemp-300.15)-gmanew);
            pbo = (model->BJTpotentialBC-pbfact)/fact1;
            gmaold = (model->BJTpotentialBC-pbo)/pbo;
            here->BJTtBCcap = model->BJTdepletionCapBC/
                    (1+model->BJTjunctionExpBC*
                    (4e-4*(model->BJTtnom-300.15)-gmaold));
            here->BJTtBCpot = fact2 * pbo+pbfact;
            gmanew = (here->BJTtBCpot-pbo)/pbo;
            here->BJTtBCcap *= 1+model->BJTjunctionExpBC*
                    (4e-4*(here->BJTtemp-300.15)-gmanew);
            here->BJTtDepCap = model->BJTdepletionCapCoeff * here->BJTtBEpot;
            here->BJTtf1 = here->BJTtBEpot * (1 - exp((1 -
                    model->BJTjunctionExpBE) * xfc)) /
                    (1 - model->BJTjunctionExpBE);
            here->BJTtf4 = model->BJTdepletionCapCoeff * here->BJTtBCpot;
            here->BJTtf5 = here->BJTtBCpot * (1 - exp((1 -
                    model->BJTjunctionExpBC) * xfc)) /
                    (1 - model->BJTjunctionExpBC);
            here->BJTtVcrit = vt *
                     log(vt / (CONSTroot2*here->BJTtSatCur*here->BJTarea));
        }
    }
    return(0);
}

variable_types: struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; } *GENinstances; char *GENmodName; } *

variable_types: struct CKTcircuit { struct sGENmodel **CKThead; struct STATistics { int STATnumIter; int STATtranIter; int STAToldIter; int STATtimePts; int STATaccepted; int STATrejected; double STATtotAnalTime; double STATloadTime; double STATdecompTime; double STATsolveTime; double STATreorderTime; double STATcombineTime; double STATsyncTime; double STATtranTime; double STATtranDecompTime; double STATtranSolveTime; double STATtranLoadTime; double STATtranTruncTime; double STATtranCombTime; double STATtranSyncTime; double STATacTime; double STATacDecompTime; double STATacSolveTime; double STATacLoadTime; double STATacCombTime; double STATacSyncTime; } *CKTstat; double *CKTstates[8]; double CKTtime; double CKTdelta; double CKTdeltaOld[7]; double CKTtemp; double CKTnomTemp; double CKTvt; double CKTag[7]; double CKTagp[7]; int CKTorder; int CKTmaxOrder; int CKTintegrateMethod; void *CKTmatrix; int CKTniState; double *CKTrhs; double *CKTrhsOld; double *CKTrhsSpare; double *CKTirhs; double *CKTirhsOld; double *CKTirhsSpare; double *CKTpred; double *CKTsols[8]; double *CKTrhsOp; double *CKTsenRhs; double *CKTseniRhs; int CKTmaxEqNum; int CKTcurrentAnalysis; struct sCKTnode { char *name; int type; int number; double ic; double nodeset; double *ptr; struct sCKTnode *next; unsigned int icGiven; unsigned int nsGiven; } *CKTnodes; struct sCKTnode *CKTlastNode; int CKTnumStates; long CKTmode; int CKTbypass; int CKTdcMaxIter; int CKTdcTrcvMaxIter; int CKTtranMaxIter; int CKTbreakSize; int CKTbreak; double CKTsaveDelta; double CKTminBreak; double *CKTbreaks; double CKTabstol; double CKTpivotAbsTol; double CKTpivotRelTol; double CKTreltol; double CKTchgtol; double CKTvoltTol; double CKTgmin; double CKTgshunt; double CKTdelmin; double CKTtrtol; double CKTfinalTime; double CKTstep; double CKTmaxStep; double CKTinitTime; double CKTomega; double CKTsrcFact; double CKTdiagGmin; int CKTnumSrcSteps; int CKTnumGminSteps; double CKTgminFactor; int CKTnoncon; double CKTdefaultMosM; double CKTdefaultMosL; double CKTdefaultMosW; double CKTdefaultMosAD; double CKTdefaultMosAS; unsigned int CKThadNodeset; unsigned int CKTfixLimit; unsigned int CKTnoOpIter; unsigned int CKTisSetup; struct sJOB { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; } *CKTcurJob; struct SENstruct { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; int SENnumVal; char **SENdevices; char **SENparmNames; unsigned int SENinitflag; unsigned int SENicflag; unsigned int SENstatus; unsigned int SENacpertflag; int SENmode; int SENparms; double SENpertfac; double **SEN_Sap; double **SEN_RHS; double **SEN_iRHS; int SENsize; void *SEN_Jacmat; double *SEN_parmVal; char **SEN_parmName; } *CKTsenInfo; double *CKTtimePoints; double *CKTdeltaList; int CKTtimeListSize; int CKTtimeIndex; int CKTsizeIncr; unsigned int CKTtryToCompact; unsigned int CKTbadMos3; unsigned int CKTkeepOpInfo; unsigned int CKTcopyNodesets; unsigned int CKTnodeDamping; double CKTabsDv; double CKTrelDv; int CKTtroubleNode; struct sGENinstance *CKTtroubleElt; } *

variable_types: struct sBJTmodel { int BJTmodType; struct sBJTmodel *BJTnextModel; struct sBJTinstance { struct sBJTmodel *BJTmodPtr; struct sBJTinstance *BJTnextInstance; char *BJTname; int BJTowner; int BJTstate; int BJTcolNode; int BJTbaseNode; int BJTemitNode; int BJTsubstNode; int BJTcolPrimeNode; int BJTbasePrimeNode; int BJTemitPrimeNode; double BJTarea; double BJTareab; double BJTareac; double BJTm; double BJTicVBE; double BJTicVCE; double BJTtemp; double BJTdtemp; double BJTtSatCur; double BJTtBetaF; double BJTtBetaR; double BJTtBEleakCur; double BJTtBCleakCur; double BJTtBEcap; double BJTtBEpot; double BJTtBCcap; double BJTtBCpot; double BJTtDepCap; double BJTtf1; double BJTtf4; double BJTtf5; double BJTtVcrit; double *BJTcolColPrimePtr; double *BJTbaseBasePrimePtr; double *BJTemitEmitPrimePtr; double *BJTcolPrimeColPtr; double *BJTcolPrimeBasePrimePtr; double *BJTcolPrimeEmitPrimePtr; double *BJTbasePrimeBasePtr; double *BJTbasePrimeColPrimePtr; double *BJTbasePrimeEmitPrimePtr; double *BJTemitPrimeEmitPtr; double *BJTemitPrimeColPrimePtr; double *BJTemitPrimeBasePrimePtr; double *BJTcolColPtr; double *BJTbaseBasePtr; double *BJTemitEmitPtr; double *BJTcolPrimeColPrimePtr; double *BJTbasePrimeBasePrimePtr; double *BJTemitPrimeEmitPrimePtr; double *BJTsubstSubstPtr; double *BJTcolPrimeSubstPtr; double *BJTsubstColPrimePtr; double *BJTbaseColPrimePtr; double *BJTcolPrimeBasePtr; unsigned int BJToff; unsigned int BJTtempGiven; unsigned int BJTdtempGiven; unsigned int BJTareaGiven; unsigned int BJTareabGiven; unsigned int BJTareacGiven; unsigned int BJTmGiven; unsigned int BJTicVBEGiven; unsigned int BJTicVCEGiven; unsigned int BJTsenPertFlag; int BJTsenParmNo; double BJTcapbe; double BJTcapbc; double BJTcapcs; double BJTcapbx; double *BJTsens; double BJTdCoeffs[65]; double BJTnVar[3][7]; } *BJTinstances; char *BJTmodName; int BJTtype; double BJTtnom; double BJTsatCur; double BJTbetaF; double BJTemissionCoeffF; double BJTearlyVoltF; double BJTrollOffF; double BJTleakBEcurrent; double BJTc2; double BJTleakBEemissionCoeff; double BJTbetaR; double BJTemissionCoeffR; double BJTearlyVoltR; double BJTrollOffR; double BJTleakBCcurrent; double BJTc4; double BJTleakBCemissionCoeff; double BJTbaseResist; double BJTbaseCurrentHalfResist; double BJTminBaseResist; double BJTemitterResist; double BJTcollectorResist; double BJTdepletionCapBE; double BJTpotentialBE; double BJTjunctionExpBE; double BJTtransitTimeF; double BJTtransitTimeBiasCoeffF; double BJTtransitTimeFVBC; double BJTtransitTimeHighCurrentF; double BJTexcessPhase; double BJTdepletionCapBC; double BJTpotentialBC; double BJTjunctionExpBC; double BJTbaseFractionBCcap; double BJTtransitTimeR; double BJTcapCS; double BJTpotentialSubstrate; double BJTexponentialSubstrate; double BJTbetaExp; double BJTenergyGap; double BJTtempExpIS; double BJTdepletionCapCoeff; double BJTfNcoef; double BJTfNexp; double BJTinvEarlyVoltF; double BJTinvEarlyVoltR; double BJTinvRollOffF; double BJTinvRollOffR; double BJTcollectorConduct; double BJTemitterConduct; double BJTtransitTimeVBCFactor; double BJTexcessPhaseFactor; double BJTf2; double BJTf3; double BJTf6; double BJTf7; unsigned int BJTtnomGiven; unsigned int BJTsatCurGiven; unsigned int BJTbetaFGiven; unsigned int BJTemissionCoeffFGiven; unsigned int BJTearlyVoltFGiven; unsigned int BJTrollOffFGiven; unsigned int BJTleakBEcurrentGiven; unsigned int BJTc2Given; unsigned int BJTleakBEemissionCoeffGiven; unsigned int BJTbetaRGiven; unsigned int BJTemissionCoeffRGiven; unsigned int BJTearlyVoltRGiven; unsigned int BJTrollOffRGiven; unsigned int BJTleakBCcurrentGiven; unsigned int BJTc4Given; unsigned int BJTleakBCemissionCoeffGiven; unsigned int BJTbaseResistGiven; unsigned int BJTbaseCurrentHalfResistGiven; unsigned int BJTminBaseResistGiven; unsigned int BJTemitterResistGiven; unsigned int BJTcollectorResistGiven; unsigned int BJTdepletionCapBEGiven; unsigned int BJTpotentialBEGiven; unsigned int BJTjunctionExpBEGiven; unsigned int BJTtransitTimeFGiven; unsigned int BJTtransitTimeBiasCoeffFGiven; unsigned int BJTtransitTimeFVBCGiven; unsigned int BJTtransitTimeHighCurrentFGiven; unsigned int BJTexcessPhaseGiven; unsigned int BJTdepletionCapBCGiven; unsigned int BJTpotentialBCGiven; unsigned int BJTjunctionExpBCGiven; unsigned int BJTbaseFractionBCcapGiven; unsigned int BJTtransitTimeRGiven; unsigned int BJTcapCSGiven; unsigned int BJTpotentialSubstrateGiven; unsigned int BJTexponentialSubstrateGiven; unsigned int BJTbetaExpGiven; unsigned int BJTenergyGapGiven; unsigned int BJTtempExpISGiven; unsigned int BJTdepletionCapCoeffGiven; unsigned int BJTfNcoefGiven; unsigned int BJTfNexpGiven; } *

variable_types: xfc double

variable_types: vt double

variable_types: ratlog double

variable_types: factlog double

variable_types: bfactor double

variable_types: factor double

variable_types: pbo double

variable_types: pbfact double

variable_types: gmaold double

variable_types: gmanew double

variable_types: egfet double

variable_types: arg double

return_type: int

user_defined_types: struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance *GENinstances; char *GENmodName; }

user_defined_types: struct CKTcircuit { struct sGENmodel **CKThead; struct STATistics *CKTstat; double *CKTstates[8]; double CKTtime; double CKTdelta; double CKTdeltaOld[7]; double CKTtemp; double CKTnomTemp; double CKTvt; double CKTag[7]; double CKTagp[7]; int CKTorder; int CKTmaxOrder; int CKTintegrateMethod; void *CKTmatrix; int CKTniState; double *CKTrhs; double *CKTrhsOld; double *CKTrhsSpare; double *CKTirhs; double *CKTirhsOld; double *CKTirhsSpare; double *CKTpred; double *CKTsols[8]; double *CKTrhsOp; double *CKTsenRhs; double *CKTseniRhs; int CKTmaxEqNum; int CKTcurrentAnalysis; struct sCKTnode *CKTnodes; struct sCKTnode *CKTlastNode; int CKTnumStates; long CKTmode; int CKTbypass; int CKTdcMaxIter; int CKTdcTrcvMaxIter; int CKTtranMaxIter; int CKTbreakSize; int CKTbreak; double CKTsaveDelta; double CKTminBreak; double *CKTbreaks; double CKTabstol; double CKTpivotAbsTol; double CKTpivotRelTol; double CKTreltol; double CKTchgtol; double CKTvoltTol; double CKTgmin; double CKTgshunt; double CKTdelmin; double CKTtrtol; double CKTfinalTime; double CKTstep; double CKTmaxStep; double CKTinitTime; double CKTomega; double CKTsrcFact; double CKTdiagGmin; int CKTnumSrcSteps; int CKTnumGminSteps; double CKTgminFactor; int CKTnoncon; double CKTdefaultMosM; double CKTdefaultMosL; double CKTdefaultMosW; double CKTdefaultMosAD; double CKTdefaultMosAS; unsigned int CKThadNodeset; unsigned int CKTfixLimit; unsigned int CKTnoOpIter; unsigned int CKTisSetup; struct sJOB *CKTcurJob; struct SENstruct *CKTsenInfo; double *CKTtimePoints; double *CKTdeltaList; int CKTtimeListSize; int CKTtimeIndex; int CKTsizeIncr; unsigned int CKTtryToCompact; unsigned int CKTbadMos3; unsigned int CKTkeepOpInfo; unsigned int CKTcopyNodesets; unsigned int CKTnodeDamping; double CKTabsDv; double CKTrelDv; int CKTtroubleNode; struct sGENinstance *CKTtroubleElt; }

user_defined_types: struct sBJTmodel { int BJTmodType; struct sBJTmodel *BJTnextModel; struct sBJTinstance *BJTinstances; char *BJTmodName; int BJTtype; double BJTtnom; double BJTsatCur; double BJTbetaF; double BJTemissionCoeffF; double BJTearlyVoltF; double BJTrollOffF; double BJTleakBEcurrent; double BJTc2; double BJTleakBEemissionCoeff; double BJTbetaR; double BJTemissionCoeffR; double BJTearlyVoltR; double BJTrollOffR; double BJTleakBCcurrent; double BJTc4; double BJTleakBCemissionCoeff; double BJTbaseResist; double BJTbaseCurrentHalfResist; double BJTminBaseResist; double BJTemitterResist; double BJTcollectorResist; double BJTdepletionCapBE; double BJTpotentialBE; double BJTjunctionExpBE; double BJTtransitTimeF; double BJTtransitTimeBiasCoeffF; double BJTtransitTimeFVBC; double BJTtransitTimeHighCurrentF; double BJTexcessPhase; double BJTdepletionCapBC; double BJTpotentialBC; double BJTjunctionExpBC; double BJTbaseFractionBCcap; double BJTtransitTimeR; double BJTcapCS; double BJTpotentialSubstrate; double BJTexponentialSubstrate; double BJTbetaExp; double BJTenergyGap; double BJTtempExpIS; double BJTdepletionCapCoeff; double BJTfNcoef; double BJTfNexp; double BJTinvEarlyVoltF; double BJTinvEarlyVoltR; double BJTinvRollOffF; double BJTinvRollOffR; double BJTcollectorConduct; double BJTemitterConduct; double BJTtransitTimeVBCFactor; double BJTexcessPhaseFactor; double BJTf2; double BJTf3; double BJTf6; double BJTf7; unsigned int BJTtnomGiven; unsigned int BJTsatCurGiven; unsigned int BJTbetaFGiven; unsigned int BJTemissionCoeffFGiven; unsigned int BJTearlyVoltFGiven; unsigned int BJTrollOffFGiven; unsigned int BJTleakBEcurrentGiven; unsigned int BJTc2Given; unsigned int BJTleakBEemissionCoeffGiven; unsigned int BJTbetaRGiven; unsigned int BJTemissionCoeffRGiven; unsigned int BJTearlyVoltRGiven; unsigned int BJTrollOffRGiven; unsigned int BJTleakBCcurrentGiven; unsigned int BJTc4Given; unsigned int BJTleakBCemissionCoeffGiven; unsigned int BJTbaseResistGiven; unsigned int BJTbaseCurrentHalfResistGiven; unsigned int BJTminBaseResistGiven; unsigned int BJTemitterResistGiven; unsigned int BJTcollectorResistGiven; unsigned int BJTdepletionCapBEGiven; unsigned int BJTpotentialBEGiven; unsigned int BJTjunctionExpBEGiven; unsigned int BJTtransitTimeFGiven; unsigned int BJTtransitTimeBiasCoeffFGiven; unsigned int BJTtransitTimeFVBCGiven; unsigned int BJTtransitTimeHighCurrentFGiven; unsigned int BJTexcessPhaseGiven; unsigned int BJTdepletionCapBCGiven; unsigned int BJTpotentialBCGiven; unsigned int BJTjunctionExpBCGiven; unsigned int BJTbaseFractionBCcapGiven; unsigned int BJTtransitTimeRGiven; unsigned int BJTcapCSGiven; unsigned int BJTpotentialSubstrateGiven; unsigned int BJTexponentialSubstrateGiven; unsigned int BJTbetaExpGiven; unsigned int BJTenergyGapGiven; unsigned int BJTtempExpISGiven; unsigned int BJTdepletionCapCoeffGiven; unsigned int BJTfNcoefGiven; unsigned int BJTfNexpGiven; }


SWload

original_code:
int
SWload(GENmodel *inModel, CKTcircuit *ckt)
{
    SWmodel *model = (SWmodel *) inModel;
    SWinstance *here;
    double g_now;
    double v_ctrl;
    double previous_state = -1;
    double current_state = -1;
 double old_current_state = -1;
 double REALLY_OFF = 0, REALLY_ON = 1;
 double HYST_OFF = 2, HYST_ON = 3;
    for( ; model != ((void *)0); model = model->SWnextModel ) {
        for (here = model->SWinstances; here != ((void *)0) ;
                here=here->SWnextInstance) {
     if (here->SWowner != ARCHme) continue;
   old_current_state = *(ckt->CKTstates[0] + here->SWstate);
   previous_state = *(ckt->CKTstates[1] + here->SWstate);
   v_ctrl = *(ckt->CKTrhsOld + here->SWposCntrlNode)
                         - *(ckt->CKTrhsOld + here->SWnegCntrlNode);
            if(ckt->CKTmode & (0x400|0x200)) {
                if(here->SWzero_stateGiven) {
     if ((model->SWvHysteresis >= 0) && (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)))
      current_state = REALLY_ON;
     else if ((model->SWvHysteresis < 0) && (v_ctrl > (model->SWvThreshold - model->SWvHysteresis)))
      current_state = REALLY_ON;
     else
      current_state = HYST_ON;
                } else {
     if ((model->SWvHysteresis >= 0) && (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)))
      current_state = REALLY_OFF;
     else if ((model->SWvHysteresis < 0) && (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)))
      current_state = REALLY_OFF;
     else
      current_state = HYST_OFF;
                }
            } else if (ckt->CKTmode & (0x800)) {
                current_state = previous_state;
            } else if (ckt->CKTmode & (0x100)) {
    if (model->SWvHysteresis > 0) {
     if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)) {
      current_state = REALLY_ON;
     } else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)) {
      current_state = REALLY_OFF;
     } else {
      current_state = old_current_state;
     }
    } else {
     if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis))
     {
      current_state = REALLY_ON;
     } else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis))
     {
      current_state = REALLY_OFF;
     } else {
      if ((previous_state == HYST_OFF) || (previous_state == HYST_ON)) {
       current_state = previous_state;
      } else if (previous_state == REALLY_ON) {
       current_state = HYST_OFF;
      } else if (previous_state == REALLY_OFF) {
       current_state = HYST_ON;
      } else
       internalerror("bad value for previous state in swload");
     }
    }
                if(current_state != old_current_state) {
                    ckt->CKTnoncon++;
     ckt->CKTtroubleElt = (GENinstance *) here;
                }
            } else if(ckt->CKTmode & (0x1000|0x2000) ) {
    if (model->SWvHysteresis > 0) {
     if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis))
      current_state = REALLY_ON;
     else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis))
      current_state = REALLY_OFF;
     else
      current_state = previous_state;
    } else {
     if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis))
      current_state = REALLY_ON;
     else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis))
      current_state = REALLY_OFF;
     else {
      current_state = 0.0;
      if ((previous_state == HYST_ON) || (previous_state == HYST_OFF)) {
       current_state = previous_state;
      } else if (previous_state == REALLY_ON) {
       current_state = REALLY_OFF;
      } else if (previous_state == REALLY_OFF) {
       current_state = REALLY_ON;
      }
     }
    }
           }
   *(ckt->CKTstates[0] + here->SWstate) = current_state;
            if ((current_state == REALLY_ON) || (current_state == HYST_ON))
    g_now = model->SWonConduct;
   else
    g_now = model->SWoffConduct;
            here->SWcond = g_now;
            *(here->SWposPosptr) += g_now;
            *(here->SWposNegptr) -= g_now;
            *(here->SWnegPosptr) -= g_now;
            *(here->SWnegNegptr) += g_now;
        }
    }
    return(0);
}

canonical_original_code:
int SWload(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sSWmodel *model = (SWmodel *) inModel;
    struct sSWinstance *here;
    double g_now;
    double v_ctrl;
    double previous_state = -1;
    double current_state = -1;
 double old_current_state = -1;
 double REALLY_OFF = 0; double REALLY_ON = 1;
 double HYST_OFF = 2; double HYST_ON = 3;
    for( ; model != ((void *)0); model = model->SWnextModel ) {
        for (here = model->SWinstances; here != ((void *)0) ;
                here=here->SWnextInstance) {
     if (here->SWowner != ARCHme) continue;
   old_current_state = *(ckt->CKTstates[0] + here->SWstate);
   previous_state = *(ckt->CKTstates[1] + here->SWstate);
   v_ctrl = *(ckt->CKTrhsOld + here->SWposCntrlNode)
                         - *(ckt->CKTrhsOld + here->SWnegCntrlNode);
            if(ckt->CKTmode & (0x400|0x200)) {
                if(here->SWzero_stateGiven) {
     if ((model->SWvHysteresis >= 0) && (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)))
      current_state = REALLY_ON;
     else if ((model->SWvHysteresis < 0) && (v_ctrl > (model->SWvThreshold - model->SWvHysteresis)))
      current_state = REALLY_ON;
     else
      current_state = HYST_ON;
                } else {
     if ((model->SWvHysteresis >= 0) && (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)))
      current_state = REALLY_OFF;
     else if ((model->SWvHysteresis < 0) && (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)))
      current_state = REALLY_OFF;
     else
      current_state = HYST_OFF;
                }
            } else if (ckt->CKTmode & (0x800)) {
                current_state = previous_state;
            } else if (ckt->CKTmode & (0x100)) {
    if (model->SWvHysteresis > 0) {
     if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)) {
      current_state = REALLY_ON;
     } else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)) {
      current_state = REALLY_OFF;
     } else {
      current_state = old_current_state;
     }
    } else {
     if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis))
     {
      current_state = REALLY_ON;
     } else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis))
     {
      current_state = REALLY_OFF;
     } else {
      if ((previous_state == HYST_OFF) || (previous_state == HYST_ON)) {
       current_state = previous_state;
      } else if (previous_state == REALLY_ON) {
       current_state = HYST_OFF;
      } else if (previous_state == REALLY_OFF) {
       current_state = HYST_ON;
      } else
       internalerror("bad value for previous state in swload");
     }
    }
                if(current_state != old_current_state) {
                    ckt->CKTnoncon++;
     ckt->CKTtroubleElt = (struct sGENinstance *) here;
                }
            } else if(ckt->CKTmode & (0x1000|0x2000) ) {
    if (model->SWvHysteresis > 0) {
     if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis))
      current_state = REALLY_ON;
     else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis))
      current_state = REALLY_OFF;
     else
      current_state = previous_state;
    } else {
     if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis))
      current_state = REALLY_ON;
     else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis))
      current_state = REALLY_OFF;
     else {
      current_state = 0.0;
      if ((previous_state == HYST_ON) || (previous_state == HYST_OFF)) {
       current_state = previous_state;
      } else if (previous_state == REALLY_ON) {
       current_state = REALLY_OFF;
      } else if (previous_state == REALLY_OFF) {
       current_state = REALLY_ON;
      }
     }
    }
           }
   *(ckt->CKTstates[0] + here->SWstate) = current_state;
            if ((current_state == REALLY_ON) || (current_state == HYST_ON))
    g_now = model->SWonConduct;
   else
    g_now = model->SWoffConduct;
            here->SWcond = g_now;
            *(here->SWposPosptr) += g_now;
            *(here->SWposNegptr) -= g_now;
            *(here->SWnegPosptr) -= g_now;
            *(here->SWnegNegptr) += g_now;
        }
    }
    return(0);
}

variable_types: struct sSWmodel { int SWmodType; struct sSWmodel *SWnextModel; struct sSWinstance { struct sSWmodel *SWmodPtr; struct sSWinstance *SWnextInstance; char *SWname; int SWowner; int SWstate; int SWposNode; int SWnegNode; int SWposCntrlNode; int SWnegCntrlNode; double *SWposPosptr; double *SWnegPosptr; double *SWposNegptr; double *SWnegNegptr; double SWcond; unsigned int SWzero_stateGiven; double SWnVar[3]; } *SWinstances; char *SWmodName; double SWonResistance; double SWoffResistance; double SWvThreshold; double SWvHysteresis; double SWonConduct; double SWoffConduct; unsigned int SWonGiven; unsigned int SWoffGiven; unsigned int SWthreshGiven; unsigned int SWhystGiven; } *

variable_types: struct sSWinstance { struct sSWmodel { int SWmodType; struct sSWmodel *SWnextModel; struct sSWinstance *SWinstances; char *SWmodName; double SWonResistance; double SWoffResistance; double SWvThreshold; double SWvHysteresis; double SWonConduct; double SWoffConduct; unsigned int SWonGiven; unsigned int SWoffGiven; unsigned int SWthreshGiven; unsigned int SWhystGiven; } *SWmodPtr; struct sSWinstance *SWnextInstance; char *SWname; int SWowner; int SWstate; int SWposNode; int SWnegNode; int SWposCntrlNode; int SWnegCntrlNode; double *SWposPosptr; double *SWnegPosptr; double *SWposNegptr; double *SWnegNegptr; double SWcond; unsigned int SWzero_stateGiven; double SWnVar[3]; } *

user_defined_types: struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; }

user_defined_types: struct STATistics { int STATnumIter; int STATtranIter; int STAToldIter; int STATtimePts; int STATaccepted; int STATrejected; double STATtotAnalTime; double STATloadTime; double STATdecompTime; double STATsolveTime; double STATreorderTime; double STATcombineTime; double STATsyncTime; double STATtranTime; double STATtranDecompTime; double STATtranSolveTime; double STATtranLoadTime; double STATtranTruncTime; double STATtranCombTime; double STATtranSyncTime; double STATacTime; double STATacDecompTime; double STATacSolveTime; double STATacLoadTime; double STATacCombTime; double STATacSyncTime; }

user_defined_types: struct sCKTnode { char *name; int type; int number; double ic; double nodeset; double *ptr; struct sCKTnode *next; unsigned int icGiven; unsigned int nsGiven; }

user_defined_types: struct sJOB { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; }

user_defined_types: struct SENstruct { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; int SENnumVal; char **SENdevices; char **SENparmNames; unsigned int SENinitflag; unsigned int SENicflag; unsigned int SENstatus; unsigned int SENacpertflag; int SENmode; int SENparms; double SENpertfac; double **SEN_Sap; double **SEN_RHS; double **SEN_iRHS; int SENsize; void *SEN_Jacmat; double *SEN_parmVal; char **SEN_parmName; }


DIOgetic

original_code:
int
DIOgetic(GENmodel *inModel, CKTcircuit *ckt)
{
    DIOmodel *model = (DIOmodel*)inModel;
    DIOinstance *here;
    for( ; model ; model = model->DIOnextModel) {
        for(here = model->DIOinstances; here ; here = here->DIOnextInstance) {
     if (here->DIOowner != ARCHme) continue;
            if(!here->DIOinitCondGiven) {
                here->DIOinitCond =
                        *(ckt->CKTrhs + here->DIOposNode) -
                        *(ckt->CKTrhs + here->DIOnegNode);
            }
        }
    }
    return(0);
}

canonical_original_code:
int DIOgetic(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sDIOmodel *model = (DIOmodel*)inModel;
    struct sDIOinstance *here;
    for( ; model ; model = model->DIOnextModel) {
        for(here = model->DIOinstances; here ; here = here->DIOnextInstance) {
     if (here->DIOowner != ARCHme) continue;
            if(!here->DIOinitCondGiven) {
                here->DIOinitCond =
                        *(ckt->CKTrhs + here->DIOposNode) -
                        *(ckt->CKTrhs + here->DIOnegNode);
            }
        }
    }
    return(0);
}

variable_types: struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; } *GENinstances; char *GENmodName; } *

variable_types: struct sDIOmodel { int DIOmodType; struct sDIOmodel *DIOnextModel; struct sDIOinstance { struct sDIOmodel *DIOmodPtr; struct sDIOinstance *DIOnextInstance; char *DIOname; int DIOowner; int DIOstate; int DIOposNode; int DIOnegNode; int DIOposPrimeNode; double *DIOposPosPrimePtr; double *DIOnegPosPrimePtr; double *DIOposPrimePosPtr; double *DIOposPrimeNegPtr; double *DIOposPosPtr; double *DIOnegNegPtr; double *DIOposPrimePosPrimePtr; double DIOcap; double *DIOsens; int DIOsenParmNo; unsigned int DIOoff; unsigned int DIOareaGiven; unsigned int DIOpjGiven; unsigned int DIOmGiven; unsigned int DIOinitCondGiven; unsigned int DIOsenPertFlag; unsigned int DIOtempGiven; unsigned int DIOdtempGiven; double DIOarea; double DIOpj; double DIOm; double DIOinitCond; double DIOtemp; double DIOdtemp; double DIOtJctPot; double DIOtJctCap; double DIOtJctSWPot; double DIOtJctSWCap; double DIOtTransitTime; double DIOtGradingCoeff; double DIOtConductance; double DIOtDepCap; double DIOtSatCur; double DIOtSatSWCur; double DIOtVcrit; double DIOtF1; double DIOtBrkdwnV; double DIOtF2; double DIOtF3; double DIOtF2SW; double DIOtF3SW; double DIOdCoeffs[6]; double DIOnVar[3][4]; } *DIOinstances; char *DIOmodName; unsigned int DIOsatCurGiven; unsigned int DIOsatSWCurGiven; unsigned int DIOresistGiven; unsigned int DIOresistTemp1Given; unsigned int DIOresistTemp2Given; unsigned int DIOemissionCoeffGiven; unsigned int DIOtransitTimeGiven; unsigned int DIOtranTimeTemp1Given; unsigned int DIOtranTimeTemp2Given; unsigned int DIOjunctionCapGiven; unsigned int DIOjunctionPotGiven; unsigned int DIOgradingCoeffGiven; unsigned int DIOgradCoeffTemp1Given; unsigned int DIOgradCoeffTemp2Given; unsigned int DIOjunctionSWCapGiven; unsigned int DIOjunctionSWPotGiven; unsigned int DIOgradingSWCoeffGiven; unsigned int DIOforwardKneeCurrentGiven; unsigned int DIOreverseKneeCurrentGiven; unsigned int DIOactivationEnergyGiven; unsigned int DIOsaturationCurrentExpGiven; unsigned int DIOdepletionCapCoeffGiven; unsigned int DIOdepletionSWcapCoeffGiven; unsigned int DIObreakdownVoltageGiven; unsigned int DIObreakdownCurrentGiven; unsigned int DIOnomTempGiven; unsigned int DIOfNcoefGiven; unsigned int DIOfNexpGiven; double DIOsatCur; double DIOsatSWCur; double DIOresist; double DIOresistTemp1; double DIOresistTemp2; double DIOconductance; double DIOemissionCoeff; double DIOtransitTime; double DIOtranTimeTemp1; double DIOtranTimeTemp2; double DIOjunctionCap; double DIOjunctionPot; double DIOgradingCoeff; double DIOgradCoeffTemp1; double DIOgradCoeffTemp2; double DIOjunctionSWCap; double DIOjunctionSWPot; double DIOgradingSWCoeff; double DIOforwardKneeCurrent; double DIOreverseKneeCurrent; double DIOactivationEnergy; double DIOsaturationCurrentExp; double DIOdepletionCapCoeff; double DIOdepletionSWcapCoeff; double DIObreakdownVoltage; double DIObreakdownCurrent; double DIOnomTemp; double DIOfNcoef; double DIOfNexp; } *

variable_types: struct sDIOinstance { struct sDIOmodel { int DIOmodType; struct sDIOmodel *DIOnextModel; struct sDIOinstance *DIOinstances; char *DIOmodName; unsigned int DIOsatCurGiven; unsigned int DIOsatSWCurGiven; unsigned int DIOresistGiven; unsigned int DIOresistTemp1Given; unsigned int DIOresistTemp2Given; unsigned int DIOemissionCoeffGiven; unsigned int DIOtransitTimeGiven; unsigned int DIOtranTimeTemp1Given; unsigned int DIOtranTimeTemp2Given; unsigned int DIOjunctionCapGiven; unsigned int DIOjunctionPotGiven; unsigned int DIOgradingCoeffGiven; unsigned int DIOgradCoeffTemp1Given; unsigned int DIOgradCoeffTemp2Given; unsigned int DIOjunctionSWCapGiven; unsigned int DIOjunctionSWPotGiven; unsigned int DIOgradingSWCoeffGiven; unsigned int DIOforwardKneeCurrentGiven; unsigned int DIOreverseKneeCurrentGiven; unsigned int DIOactivationEnergyGiven; unsigned int DIOsaturationCurrentExpGiven; unsigned int DIOdepletionCapCoeffGiven; unsigned int DIOdepletionSWcapCoeffGiven; unsigned int DIObreakdownVoltageGiven; unsigned int DIObreakdownCurrentGiven; unsigned int DIOnomTempGiven; unsigned int DIOfNcoefGiven; unsigned int DIOfNexpGiven; double DIOsatCur; double DIOsatSWCur; double DIOresist; double DIOresistTemp1; double DIOresistTemp2; double DIOconductance; double DIOemissionCoeff; double DIOtransitTime; double DIOtranTimeTemp1; double DIOtranTimeTemp2; double DIOjunctionCap; double DIOjunctionPot; double DIOgradingCoeff; double DIOgradCoeffTemp1; double DIOgradCoeffTemp2; double DIOjunctionSWCap; double DIOjunctionSWPot; double DIOgradingSWCoeff; double DIOforwardKneeCurrent; double DIOreverseKneeCurrent; double DIOactivationEnergy; double DIOsaturationCurrentExp; double DIOdepletionCapCoeff; double DIOdepletionSWcapCoeff; double DIObreakdownVoltage; double DIObreakdownCurrent; double DIOnomTemp; double DIOfNcoef; double DIOfNexp; } *DIOmodPtr; struct sDIOinstance *DIOnextInstance; char *DIOname; int DIOowner; int DIOstate; int DIOposNode; int DIOnegNode; int DIOposPrimeNode; double *DIOposPosPrimePtr; double *DIOnegPosPrimePtr; double *DIOposPrimePosPtr; double *DIOposPrimeNegPtr; double *DIOposPosPtr; double *DIOnegNegPtr; double *DIOposPrimePosPrimePtr; double DIOcap; double *DIOsens; int DIOsenParmNo; unsigned int DIOoff; unsigned int DIOareaGiven; unsigned int DIOpjGiven; unsigned int DIOmGiven; unsigned int DIOinitCondGiven; unsigned int DIOsenPertFlag; unsigned int DIOtempGiven; unsigned int DIOdtempGiven; double DIOarea; double DIOpj; double DIOm; double DIOinitCond; double DIOtemp; double DIOdtemp; double DIOtJctPot; double DIOtJctCap; double DIOtJctSWPot; double DIOtJctSWCap; double DIOtTransitTime; double DIOtGradingCoeff; double DIOtConductance; double DIOtDepCap; double DIOtSatCur; double DIOtSatSWCur; double DIOtVcrit; double DIOtF1; double DIOtBrkdwnV; double DIOtF2; double DIOtF3; double DIOtF2SW; double DIOtF3SW; double DIOdCoeffs[6]; double DIOnVar[3][4]; } *