URCsetup

decompiled_code:
__int64 __fastcall URCsetup(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r14
char v5; // al
__int64 v6; // rax
__int64 v7; // r14
__int64 v8; // r13
double v9; // rbx
double v10; // xmm1_8
double v11; // xmm0_8
int v12; // ebx
__int64 result; // rax
unsigned int v14; // ebp
char *v15; // r12
char *v16; // r12
char *v17; // rbx
char *v18; // rbx
char *v19; // rbx
__int64 v20; // rax
signed int v21; // eax
char *v22; // rbx
__int64 v23; // rax
char *v24; // rbx
__int64 v25; // rax
char *v26; // rbx
__int64 v27; // rax
double v28; // rbp
double v29; // xmm0_8
double v30; // xmm1_8
int v31; // eax
double v32; // [rsp+0h] [rbp-118h]
double v33; // [rsp+0h] [rbp-118h]
__int64 v34; // [rsp+8h] [rbp-110h]
double v35; // [rsp+10h] [rbp-108h]
__int64 v36; // [rsp+10h] [rbp-108h]
double v37; // [rsp+18h] [rbp-100h]
__int64 v38; // [rsp+18h] [rbp-100h]
double v39; // [rsp+20h] [rbp-F8h]
double v40; // [rsp+28h] [rbp-F0h]
__int64 v41; // [rsp+28h] [rbp-F0h]
double v42; // [rsp+28h] [rbp-F0h]
double v43; // [rsp+30h] [rbp-E8h]
double v44; // [rsp+30h] [rbp-E8h]
double x; // [rsp+38h] [rbp-E0h]
unsigned int v46; // [rsp+44h] [rbp-D4h]
double v47; // [rsp+48h] [rbp-D0h]
__int64 v48; // [rsp+48h] [rbp-D0h]
double v49; // [rsp+58h] [rbp-C0h]
double v50; // [rsp+60h] [rbp-B8h]
unsigned int v51; // [rsp+70h] [rbp-A8h]
unsigned int v52; // [rsp+74h] [rbp-A4h]
__int64 v53; // [rsp+88h] [rbp-90h] BYREF
__int64 v54; // [rsp+90h] [rbp-88h] BYREF
__int64 v55; // [rsp+98h] [rbp-80h] BYREF
__int64 v56; // [rsp+A0h] [rbp-78h] BYREF
__int64 v57; // [rsp+A8h] [rbp-70h] BYREF
__int64 v58; // [rsp+B0h] [rbp-68h] BYREF
__int64 v59; // [rsp+B8h] [rbp-60h] BYREF
__int64 v60; // [rsp+C0h] [rbp-58h] BYREF
__int64 v61; // [rsp+C8h] [rbp-50h] BYREF
__int64 v62[9]; // [rsp+D0h] [rbp-48h] BYREF

v34 = a2;
v46 = CKTtypelook("Resistor");
v52 = CKTtypelook("Capacitor");
v51 = CKTtypelook("Diode");
if ( !a2 )
return 0LL;
v4 = a3;
while ( 1 )
{
v5 = *(_BYTE *)(v34 + 80);
if ( (v5 & 1) == 0 )
*(_QWORD *)(v34 + 32) = LC5;
if ( (v5 & 2) == 0 )
*(_QWORD *)(v34 + 40) = LC6;
if ( (v5 & 4) == 0 )
*(_QWORD *)(v34 + 48) = LC7;
if ( (v5 & 8) == 0 )
*(_QWORD *)(v34 + 56) = LC8;
if ( *(_QWORD *)(v34 + 16) )
break;
LABEL_80:
result = *(_QWORD *)(v34 + 8);
v34 = result;
if ( !result )
return result;
}
v6 = v4;
v7 = *(_QWORD *)(v34 + 16);
v8 = v6;
while ( 1 )
{
v37 = *(double *)(v7 + 40);
x = *(double *)(v34 + 32);
v32 = x - 1.0;
v9 = *(double *)(v34 + 48) * v37;
v35 = v37 * *(double *)(v34 + 56);
v39 = *(double *)(v34 + 64);
if ( (*(_BYTE *)(v7 + 52) & 2) != 0 )
{
v10 = (double)*(int *)(v7 + 48);
}
else
{
v44 = (v9 * *(double *)(v34 + 40) * v35 + v9 * *(double *)(v34 + 40) * v35) * 3.141592653589793;
v28 = log(v32 / x * (v32 / x) * v44);
v29 = log(x);
v30 = v44;
v31 = 3;
if ( v28 / v29 >= 3.0 )
{
v42 = log(v32 / x * (v32 / x) * v44);
v30 = v44;
v31 = (int)(v42 / log(x));
}
if ( v30 >= 35.0 )
{
*(_DWORD *)(v7 + 48) = v31;
v10 = (double)v31;
}
else
{
*(_DWORD *)(v7 + 48) = 3;
v10 = *(double *)&LC0;
}
}
v11 = pow(x, v10);
v50 = v9 * v32 / (v11 + v11 - 2.0);
v49 = v35 * v32 / (pow(x, (double)(*(_DWORD *)(v7 + 48) - 1)) * (x + 1.0) - 2.0);
v40 = pow(x, (double)(*(_DWORD *)(v7 + 48) - 1));
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v12 = *(_DWORD *)(v7 + 48);
v47 = *(double *)(v34 + 72);
v43 = *(double *)(v7 + 40);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v58,
*(_QWORD *)(v7 + 16),
"diodemod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v56 = 0LL;
result = CKTmodCrt(v8, v51, &v56, v58);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49;
result = CKTpModName("cjo", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
*(double *)v62 = (double)v12 * v43 * v47;
result = CKTpModName("rs", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
*(double *)v62 = v32 * (v37 * v39) / ((x + 1.0) * v40 - 2.0);
result = CKTpModName("is", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
}
else
{
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v60,
*(_QWORD *)(v7 + 16),
"capmod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v56 = 0LL;
result = CKTmodCrt(v8, v52, &v56, v60);
if ( (_DWORD)result )
return result;
}
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v59,
*(_QWORD *)(v7 + 16),
"resmod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v57 = 0LL;
result = CKTmodCrt(v8, v46, &v57, v59);
if ( (_DWORD)result )
return result;
v41 = CKTnum2nod(v8, *(unsigned int *)(v7 + 28));
v48 = CKTnum2nod(v8, *(unsigned int *)(v7 + 32));
if ( *(int *)(v7 + 48) > 0 )
break;
LABEL_78:
v7 = *(_QWORD *)(v7 + 8);
if ( !v7 )
{
v4 = v8;
goto LABEL_80;
}
}
v14 = 1;
v33 = *(double *)&LC1;
while ( 1 )
{
v15 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v15, "hi%d", v14);
result = CKTmkVolt(v8, &v53, *(_QWORD *)(v7 + 16), v15);
if ( (_DWORD)result )
return result;
v38 = v53;
if ( *(_DWORD *)(v7 + 48) == v14 )
{
v36 = v53;
}
else
{
v16 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v16, "lo%d", v14);
result = CKTmkVolt(v8, &v54, *(_QWORD *)(v7 + 16), v16);
if ( (_DWORD)result )
return result;
v36 = v54;
}
v17 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v17, "rlo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v17,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v57, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v41);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 2LL, v36);
if ( (_DWORD)result )
return result;
*(double *)v62 = v50 * v33;
result = CKTpName("resistance", v62, v8, v46, v17, &v55);
if ( (_DWORD)result )
return result;
v18 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v18, "rhi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v18,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v57, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 2LL, v48);
if ( (_DWORD)result )
return result;
*(double *)v62 = v50 * v33;
result = CKTpName("resistance", v62, v8, v46, v18, &v55);
if ( (_DWORD)result )
return result;
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v19 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v19, "dlo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v19,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v36);
if ( (_DWORD)result )
return result;
v20 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v20);
if ( (_DWORD)result )
return result;
*(double *)v62 = v33;
result = CKTpName("area", v62, v8, v51, v19, &v55);
if ( (_DWORD)result )
return result;
}
else
{
v24 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v24, "clo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v24,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v36);
if ( (_DWORD)result )
return result;
v25 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v25);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49 * v33;
result = CKTpName("capacitance", v62, v8, v52, v24, &v55);
if ( (_DWORD)result )
return result;
}
v21 = v14;
if ( *(_DWORD *)(v7 + 48) != v14 )
{
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v22 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v22, "dhi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v22,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
v23 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v23);
if ( (_DWORD)result )
return result;
*(double *)v62 = v33;
result = CKTpName("area", v62, v8, v51, v22, &v55);
if ( (_DWORD)result )
return result;
}
else
{
v26 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v26, "chi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v26,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
v27 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v27);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49 * v33;
result = CKTpName("capacitance", v62, v8, v52, v26, &v55);
if ( (_DWORD)result )
return result;
}
v21 = *(_DWORD *)(v7 + 48);
}
++v14;
v33 = v33 * x;
if ( (int)v14 > v21 )
goto LABEL_78;
v48 = v38;
v41 = v36;
}
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r14
char v5; // al
__int64 v6; // rax
__int64 v7; // r14
__int64 v8; // r13
double v9; // rbx
double v10; // xmm1_8
double v11; // xmm0_8
int v12; // ebx
__int64 result; // rax
unsigned int v14; // ebp
char *v15; // r12
char *v16; // r12
char *v17; // rbx
char *v18; // rbx
char *v19; // rbx
__int64 v20; // rax
signed int v21; // eax
char *v22; // rbx
__int64 v23; // rax
char *v24; // rbx
__int64 v25; // rax
char *v26; // rbx
__int64 v27; // rax
double v28; // rbp
double v29; // xmm0_8
double v30; // xmm1_8
int v31; // eax
double v32; // [rsp+0h] [rbp-118h]
double v33; // [rsp+0h] [rbp-118h]
__int64 v34; // [rsp+8h] [rbp-110h]
double v35; // [rsp+10h] [rbp-108h]
__int64 v36; // [rsp+10h] [rbp-108h]
double v37; // [rsp+18h] [rbp-100h]
__int64 v38; // [rsp+18h] [rbp-100h]
double v39; // [rsp+20h] [rbp-F8h]
double v40; // [rsp+28h] [rbp-F0h]
__int64 v41; // [rsp+28h] [rbp-F0h]
double v42; // [rsp+28h] [rbp-F0h]
double v43; // [rsp+30h] [rbp-E8h]
double v44; // [rsp+30h] [rbp-E8h]
double x; // [rsp+38h] [rbp-E0h]
unsigned int v46; // [rsp+44h] [rbp-D4h]
double v47; // [rsp+48h] [rbp-D0h]
__int64 v48; // [rsp+48h] [rbp-D0h]
double v49; // [rsp+58h] [rbp-C0h]
double v50; // [rsp+60h] [rbp-B8h]
unsigned int v51; // [rsp+70h] [rbp-A8h]
unsigned int v52; // [rsp+74h] [rbp-A4h]
__int64 v53; // [rsp+88h] [rbp-90h] BYREF
__int64 v54; // [rsp+90h] [rbp-88h] BYREF
__int64 v55; // [rsp+98h] [rbp-80h] BYREF
__int64 v56; // [rsp+A0h] [rbp-78h] BYREF
__int64 v57; // [rsp+A8h] [rbp-70h] BYREF
__int64 v58; // [rsp+B0h] [rbp-68h] BYREF
__int64 v59; // [rsp+B8h] [rbp-60h] BYREF
__int64 v60; // [rsp+C0h] [rbp-58h] BYREF
__int64 v61; // [rsp+C8h] [rbp-50h] BYREF
__int64 v62[9]; // [rsp+D0h] [rbp-48h] BYREF

v34 = a2;
v46 = CKTtypelook("Resistor");
v52 = CKTtypelook("Capacitor");
v51 = CKTtypelook("Diode");
if ( !a2 )
return 0LL;
v4 = a3;
while ( 1 )
{
v5 = *(_BYTE *)(v34 + 80);
if ( (v5 & 1) == 0 )
*(_QWORD *)(v34 + 32) = LC5;
if ( (v5 & 2) == 0 )
*(_QWORD *)(v34 + 40) = LC6;
if ( (v5 & 4) == 0 )
*(_QWORD *)(v34 + 48) = LC7;
if ( (v5 & 8) == 0 )
*(_QWORD *)(v34 + 56) = LC8;
if ( *(_QWORD *)(v34 + 16) )
break;
LABEL_80:
result = *(_QWORD *)(v34 + 8);
v34 = result;
if ( !result )
return result;
}
v6 = v4;
v7 = *(_QWORD *)(v34 + 16);
v8 = v6;
while ( 1 )
{
v37 = *(double *)(v7 + 40);
x = *(double *)(v34 + 32);
v32 = x - 1.0;
v9 = *(double *)(v34 + 48) * v37;
v35 = v37 * *(double *)(v34 + 56);
v39 = *(double *)(v34 + 64);
if ( (*(_BYTE *)(v7 + 52) & 2) != 0 )
{
v10 = (double)*(int *)(v7 + 48);
}
else
{
v44 = (v9 * *(double *)(v34 + 40) * v35 + v9 * *(double *)(v34 + 40) * v35) * 3.141592653589793;
v28 = log(v32 / x * (v32 / x) * v44);
v29 = log(x);
v30 = v44;
v31 = 3;
if ( v28 / v29 >= 3.0 )
{
v42 = log(v32 / x * (v32 / x) * v44);
v30 = v44;
v31 = (int)(v42 / log(x));
}
if ( v30 >= 35.0 )
{
*(_DWORD *)(v7 + 48) = v31;
v10 = (double)v31;
}
else
{
*(_DWORD *)(v7 + 48) = 3;
v10 = *(double *)&LC0;
}
}
v11 = pow(x, v10);
v50 = v9 * v32 / (v11 + v11 - 2.0);
v49 = v35 * v32 / (pow(x, (double)(*(_DWORD *)(v7 + 48) - 1)) * (x + 1.0) - 2.0);
v40 = pow(x, (double)(*(_DWORD *)(v7 + 48) - 1));
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v12 = *(_DWORD *)(v7 + 48);
v47 = *(double *)(v34 + 72);
v43 = *(double *)(v7 + 40);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v58,
*(_QWORD *)(v7 + 16),
"diodemod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v56 = 0LL;
result = CKTmodCrt(v8, v51, &v56, v58);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49;
result = CKTpModName("cjo", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
*(double *)v62 = (double)v12 * v43 * v47;
result = CKTpModName("rs", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
*(double *)v62 = v32 * (v37 * v39) / ((x + 1.0) * v40 - 2.0);
result = CKTpModName("is", v62, v8, v51, v58, &v56);
if ( (_DWORD)result )
return result;
}
else
{
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v60,
*(_QWORD *)(v7 + 16),
"capmod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v56 = 0LL;
result = CKTmodCrt(v8, v52, &v56, v60);
if ( (_DWORD)result )
return result;
}
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, const char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v59,
*(_QWORD *)(v7 + 16),
"resmod",
8LL,
0LL);
if ( (_DWORD)result )
return result;
v57 = 0LL;
result = CKTmodCrt(v8, v46, &v57, v59);
if ( (_DWORD)result )
return result;
v41 = CKTnum2nod(v8, *(unsigned int *)(v7 + 28));
v48 = CKTnum2nod(v8, *(unsigned int *)(v7 + 32));
if ( *(int *)(v7 + 48) > 0 )
break;
LABEL_78:
v7 = *(_QWORD *)(v7 + 8);
if ( !v7 )
{
v4 = v8;
goto LABEL_80;
}
}
v14 = 1;
v33 = *(double *)&LC1;
while ( 1 )
{
v15 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v15, "hi%d", v14);
result = CKTmkVolt(v8, &v53, *(_QWORD *)(v7 + 16), v15);
if ( (_DWORD)result )
return result;
v38 = v53;
if ( *(_DWORD *)(v7 + 48) == v14 )
{
v36 = v53;
}
else
{
v16 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v16, "lo%d", v14);
result = CKTmkVolt(v8, &v54, *(_QWORD *)(v7 + 16), v16);
if ( (_DWORD)result )
return result;
v36 = v54;
}
v17 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v17, "rlo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v17,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v57, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v41);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 2LL, v36);
if ( (_DWORD)result )
return result;
*(double *)v62 = v50 * v33;
result = CKTpName("resistance", v62, v8, v46, v17, &v55);
if ( (_DWORD)result )
return result;
v18 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v18, "rhi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v18,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v57, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 2LL, v48);
if ( (_DWORD)result )
return result;
*(double *)v62 = v50 * v33;
result = CKTpName("resistance", v62, v8, v46, v18, &v55);
if ( (_DWORD)result )
return result;
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v19 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v19, "dlo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v19,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v36);
if ( (_DWORD)result )
return result;
v20 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v20);
if ( (_DWORD)result )
return result;
*(double *)v62 = v33;
result = CKTpName("area", v62, v8, v51, v19, &v55);
if ( (_DWORD)result )
return result;
}
else
{
v24 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v24, "clo%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v24,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v36);
if ( (_DWORD)result )
return result;
v25 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v25);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49 * v33;
result = CKTpName("capacitance", v62, v8, v52, v24, &v55);
if ( (_DWORD)result )
return result;
}
v21 = v14;
if ( *(_DWORD *)(v7 + 48) != v14 )
{
if ( (*(_BYTE *)(v34 + 80) & 0x10) != 0 )
{
v22 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v22, "dhi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v22,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
v23 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v23);
if ( (_DWORD)result )
return result;
*(double *)v62 = v33;
result = CKTpName("area", v62, v8, v51, v22, &v55);
if ( (_DWORD)result )
return result;
}
else
{
v26 = (char *)calloc(1uLL, 0xAuLL);
sprintf(v26, "chi%d", v14);
result = ((__int64 (__fastcall *)(__int64, __int64 *, _QWORD, char *, __int64, _QWORD))*SPfrontEnd)(
v8,
&v61,
*(_QWORD *)(v7 + 16),
v26,
4LL,
0LL);
if ( (_DWORD)result )
return result;
result = CKTcrtElt(v8, v56, &v55, v61);
if ( (_DWORD)result )
return result;
result = CKTbindNode(v8, v55, 1LL, v38);
if ( (_DWORD)result )
return result;
v27 = CKTnum2nod(v8, *(unsigned int *)(v7 + 36));
result = CKTbindNode(v8, v55, 2LL, v27);
if ( (_DWORD)result )
return result;
*(double *)v62 = v49 * v33;
result = CKTpName("capacitance", v62, v8, v52, v26, &v55);
if ( (_DWORD)result )
return result;
}
v21 = *(_DWORD *)(v7 + 48);
}
++v14;
v33 = v33 * x;
if ( (int)v14 > v21 )
goto LABEL_78;
v48 = v38;
v41 = v36;
}
}

original_code:
int
URCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state)
{
    URCmodel *model = (URCmodel *)inModel;
    URCinstance *here;
    int rtype;
    int ctype;
    int dtype;
    CKTnode * lowl;
    CKTnode * lowr;
    CKTnode * hil;
    CKTnode * hir;
    char *nameelt;
    char *namehi;
    CKTnode *nodehi;
    CKTnode *nodelo;
    char *namelo;
    double r;
    double c;
    IFvalue ptemp;
    double p;
    double r0;
    double c0;
    double i0;
    double r1;
    double c1;
    double i1;
    double rd;
    double wnorm;
    double prop;
    int i;
    GENinstance *fast;
    GENmodel *modfast;
    GENmodel *rmodfast;
    int error;
    IFuid dioUid;
    IFuid resUid;
    IFuid capUid;
    IFuid eltUid;
    rtype = CKTtypelook("Resistor");
    ctype = CKTtypelook("Capacitor");
    dtype = CKTtypelook("Diode");
    for( ; model != ((void *)0); model = model->URCnextModel ) {
 if(!model->URCkGiven)
     model->URCk = 1.5;
 if(!model->URCfmaxGiven)
     model->URCfmax = 1e9;
 if(!model->URCrPerLGiven)
     model->URCrPerL = 1000;
 if(!model->URCcPerLGiven)
     model->URCcPerL = 1e-12;
        for (here = model->URCinstances; here != ((void *)0) ;
                here=here->URCnextInstance)
 {
            p = model->URCk;
            r0 = here->URClength * model->URCrPerL;
            c0 = here->URClength * model->URCcPerL;
            i0 = here->URClength * model->URCisPerL;
            if(!here->URClumpsGiven) {
                wnorm = model->URCfmax * r0 * c0 * 2.0 * 3.14159265358979323846;
                here->URClumps=((3.0) > (log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p)) ? (3.0) : (log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p)));
                if(wnorm <35) here->URClumps=3;
            }
            r1 = (r0*(p-1))/((2*(pow(p,(double)here->URClumps)))-2);
            c1 = (c0 * (p-1))/((pow(p,(double)(here->URClumps-1)))*(p+1)-2);
            i1 = (i0 * (p-1))/((pow(p,(double)(here->URClumps-1)))*(p+1)-2);
            rd = here->URClength * here->URClumps * model->URCrsPerL;
            prop=1;
            if(model->URCisPerLGiven) {
                error = (*(SPfrontEnd->IFnewUid))(ckt,&dioUid,here->URCname,
                        "diodemod",0x8,(void **)((void *)0));
                if(error) return(error);
                modfast = (GENmodel *)((void *)0);
                error = CKTmodCrt((void *)ckt,dtype,(void **)&modfast,
                        dioUid);
                if(error) return(error);
                ptemp.rValue = c1;
                error= CKTpModName("cjo",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
                ptemp.rValue = rd;
                error = CKTpModName("rs",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
                ptemp.rValue = i1;
                error = CKTpModName("is",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
            } else {
                error = (*(SPfrontEnd->IFnewUid))((void *)ckt,&capUid,
                        here->URCname, "capmod",0x8,(void **)((void *)0));
                if(error) return(error);
                modfast = (GENmodel *)((void *)0);
                error = CKTmodCrt((void *)ckt,ctype,(void **)&modfast,
                        capUid);
                if(error) return(error);
            }
            error = (*(SPfrontEnd->IFnewUid))(ckt,&resUid,here->URCname,
                    "resmod",0x8,(void **)((void *)0));
            if(error) return(error);
            rmodfast = (GENmodel *)((void *)0);
            error = CKTmodCrt((void *)ckt,rtype,(void **)&rmodfast,resUid);
            if(error) return(error);
            lowl = CKTnum2nod(ckt,here->URCposNode);
            hir = CKTnum2nod(ckt,here->URCnegNode);
            for(i=1;i<=here->URClumps;i++) {
                namehi = (char *)tmalloc((unsigned)(10*sizeof(char)));
                (void)sprintf(namehi,"hi%d",i);
                error = CKTmkVolt(ckt,(CKTnode**)&nodehi,here->URCname,namehi);
                if(error) return(error);
                hil = nodehi;
                if(i==here->URClumps) {
                    lowr = hil;
                } else {
                    namelo = (char *)tmalloc((unsigned)(10*sizeof(char)));
                    (void)sprintf(namelo,"lo%d",i);
                    error = CKTmkVolt(ckt,(CKTnode**)&nodelo,here->URCname,
                            namelo);
                    if(error) return(error);
                    lowr = nodelo;
                }
                r = prop*r1;
                c = prop*c1;
                nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                (void)sprintf(nameelt,"rlo%d",i);
                error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname,
                        nameelt,0x4, (void **)((void *)0));
                if(error) return(error);
                error = CKTcrtElt((void *)ckt,(void *)rmodfast,
                        (void **)&fast,eltUid);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,1,lowl);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,2,lowr);
                if(error) return(error);
                ptemp.rValue = r;
                error = CKTpName("resistance",&ptemp,ckt,rtype,nameelt,&fast);
                if(error) return(error);
  fast->GENowner = here->URCowner;
                nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                (void)sprintf(nameelt,"rhi%d",i);
                error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname,
                        nameelt,0x4, (void **)((void *)0));
                if(error) return(error);
                error = CKTcrtElt((void *)ckt,(void *)rmodfast,
                        (void **)&fast,eltUid);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,2,hir);
                if(error) return(error);
                ptemp.rValue = r;
                error = CKTpName("resistance",&ptemp,ckt,rtype,nameelt,&fast);
                if(error) return(error);
  fast->GENowner = here->URCowner;
                if(model->URCisPerLGiven) {
                    nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                    (void)sprintf(nameelt,"dlo%d",i);
                    error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                            here->URCname,nameelt,0x4,
                            (void **)((void *)0));
                    if(error) return(error);
                    error = CKTcrtElt((void *)ckt,(void *)modfast,
                            (void **)&fast, eltUid);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,1,lowr);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,2,
                            (void *)CKTnum2nod(ckt, here->URCgndNode));
                    if(error) return(error);
                    ptemp.rValue = prop;
                    error = CKTpName("area",&ptemp,ckt,dtype,nameelt,&fast);
                    if(error) return(error);
      fast->GENowner = here->URCowner;
                } else {
                    nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                    (void)sprintf(nameelt,"clo%d",i);
                    error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname
                            ,nameelt,0x4, (void **)((void *)0));
                    if(error) return(error);
                    error = CKTcrtElt((void *)ckt,(void *)modfast,
                            (void **)&fast, eltUid);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,1,lowr);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,2,
                            (void *)CKTnum2nod(ckt, here->URCgndNode));
                    if(error) return(error);
                    ptemp.rValue = c;
                    error = CKTpName("capacitance",&ptemp,ckt,ctype,nameelt,
                            &fast);
                    if(error) return(error);
      fast->GENowner = here->URCowner;
                }
                if(i!=here->URClumps){
                    if(model->URCisPerLGiven) {
                        nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                        (void)sprintf(nameelt,"dhi%d",i);
                        error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                                here->URCname,nameelt,0x4,
                                (void **)((void *)0));
                        if(error) return(error);
                        error = CKTcrtElt((void *)ckt,(void *)modfast,
                                (void **) &fast,eltUid);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,2,
                                (void *)CKTnum2nod(ckt, here->URCgndNode));
                        if(error) return(error);
                        ptemp.rValue = prop;
                        error=CKTpName("area",&ptemp,ckt,dtype,nameelt,&fast);
                        if(error) return(error);
   fast->GENowner = here->URCowner;
                    } else {
                        nameelt = (char *)tmalloc((unsigned)(10*sizeof(char)));
                        (void)sprintf(nameelt,"chi%d",i);
                        error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                                here->URCname,nameelt,0x4,
                                (void **)((void *)0));
                        if(error) return(error);
                        error = CKTcrtElt((void *)ckt,(void *)modfast,
                                (void **)&fast,eltUid);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,2,
                                (void *)CKTnum2nod(ckt, here->URCgndNode));
                        if(error) return(error);
                        ptemp.rValue = c;
                        error =CKTpName("capacitance",&ptemp,ckt,ctype,nameelt,
                                &fast);
                        if(error) return(error);
   fast->GENowner = here->URCowner;
                    }
                }
                prop *= p;
                lowl = lowr;
                hir = hil;
            }
        }
    }
    return(0);
}

canonical_original_code:
int URCsetup(void *matrix, struct sGENmodel *inModel, struct CKTcircuit *ckt, int *state)
{
    struct sURCmodel *model = (URCmodel *)inModel;
    struct sURCinstance *here;
    int rtype;
    int ctype;
    int dtype;
    struct sCKTnode *lowl;
    struct sCKTnode *lowr;
    struct sCKTnode *hil;
    struct sCKTnode *hir;
    char *nameelt;
    char *namehi;
    struct sCKTnode *nodehi;
    struct sCKTnode *nodelo;
    char *namelo;
    double r;
    double c;
    union uIFvalue ptemp;
    double p;
    double r0;
    double c0;
    double i0;
    double r1;
    double c1;
    double i1;
    double rd;
    double wnorm;
    double prop;
    int i;
    struct sGENinstance *fast;
    struct sGENmodel *modfast;
    struct sGENmodel *rmodfast;
    int error;
    char *dioUid;
    char *resUid;
    char *capUid;
    char *eltUid;
    rtype = CKTtypelook("Resistor");
    ctype = CKTtypelook("Capacitor");
    dtype = CKTtypelook("Diode");
    for( ; model != ((void *)0); model = model->URCnextModel ) {
 if(!model->URCkGiven)
     model->URCk = 1.5;
 if(!model->URCfmaxGiven)
     model->URCfmax = 1e9;
 if(!model->URCrPerLGiven)
     model->URCrPerL = 1000;
 if(!model->URCcPerLGiven)
     model->URCcPerL = 1e-12;
        for (here = model->URCinstances; here != ((void *)0) ;
                here=here->URCnextInstance)
 {
            p = model->URCk;
            r0 = here->URClength * model->URCrPerL;
            c0 = here->URClength * model->URCcPerL;
            i0 = here->URClength * model->URCisPerL;
            if(!here->URClumpsGiven) {
                wnorm = model->URCfmax * r0 * c0 * 2.0 * 3.14159265358979323846;
                here->URClumps=((3.0) > (log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p)) ? (3.0) : (log(wnorm*(((p-1)/p)*((p-1)/p)))/log(p)));
                if(wnorm <35) here->URClumps=3;
            }
            r1 = (r0*(p-1))/((2*(pow(p,(double)here->URClumps)))-2);
            c1 = (c0 * (p-1))/((pow(p,(double)(here->URClumps-1)))*(p+1)-2);
            i1 = (i0 * (p-1))/((pow(p,(double)(here->URClumps-1)))*(p+1)-2);
            rd = here->URClength * here->URClumps * model->URCrsPerL;
            prop=1;
            if(model->URCisPerLGiven) {
                error = (*(SPfrontEnd->IFnewUid))(ckt,&dioUid,here->URCname,
                        "diodemod",0x8,(void **)((void *)0));
                if(error) return(error);
                modfast = (struct sGENmodel *)((void *)0);
                error = CKTmodCrt((void *)ckt,dtype,(void **)&modfast,
                        dioUid);
                if(error) return(error);
                ptemp.rValue = c1;
                error= CKTpModName("cjo",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
                ptemp.rValue = rd;
                error = CKTpModName("rs",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
                ptemp.rValue = i1;
                error = CKTpModName("is",&ptemp,ckt,dtype,dioUid,&modfast);
                if(error) return(error);
            } else {
                error = (*(SPfrontEnd->IFnewUid))((void *)ckt,&capUid,
                        here->URCname, "capmod",0x8,(void **)((void *)0));
                if(error) return(error);
                modfast = (struct sGENmodel *)((void *)0);
                error = CKTmodCrt((void *)ckt,ctype,(void **)&modfast,
                        capUid);
                if(error) return(error);
            }
            error = (*(SPfrontEnd->IFnewUid))(ckt,&resUid,here->URCname,
                    "resmod",0x8,(void **)((void *)0));
            if(error) return(error);
            rmodfast = (struct sGENmodel *)((void *)0);
            error = CKTmodCrt((void *)ckt,rtype,(void **)&rmodfast,resUid);
            if(error) return(error);
            lowl = CKTnum2nod(ckt,here->URCposNode);
            hir = CKTnum2nod(ckt,here->URCnegNode);
            for(i=1;i<=here->URClumps;i++) {
                namehi = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                (void)sprintf(namehi,"hi%d",i);
                error = CKTmkVolt(ckt,(struct sCKTnode **)&nodehi,here->URCname,namehi);
                if(error) return(error);
                hil = nodehi;
                if(i==here->URClumps) {
                    lowr = hil;
                } else {
                    namelo = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                    (void)sprintf(namelo,"lo%d",i);
                    error = CKTmkVolt(ckt,(struct sCKTnode **)&nodelo,here->URCname,
                            namelo);
                    if(error) return(error);
                    lowr = nodelo;
                }
                r = prop*r1;
                c = prop*c1;
                nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                (void)sprintf(nameelt,"rlo%d",i);
                error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname,
                        nameelt,0x4, (void **)((void *)0));
                if(error) return(error);
                error = CKTcrtElt((void *)ckt,(void *)rmodfast,
                        (void **)&fast,eltUid);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,1,lowl);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,2,lowr);
                if(error) return(error);
                ptemp.rValue = r;
                error = CKTpName("resistance",&ptemp,ckt,rtype,nameelt,&fast);
                if(error) return(error);
  fast->GENowner = here->URCowner;
                nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                (void)sprintf(nameelt,"rhi%d",i);
                error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname,
                        nameelt,0x4, (void **)((void *)0));
                if(error) return(error);
                error = CKTcrtElt((void *)ckt,(void *)rmodfast,
                        (void **)&fast,eltUid);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                if(error) return(error);
                error = CKTbindNode((void *)ckt,(void *)fast,2,hir);
                if(error) return(error);
                ptemp.rValue = r;
                error = CKTpName("resistance",&ptemp,ckt,rtype,nameelt,&fast);
                if(error) return(error);
  fast->GENowner = here->URCowner;
                if(model->URCisPerLGiven) {
                    nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                    (void)sprintf(nameelt,"dlo%d",i);
                    error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                            here->URCname,nameelt,0x4,
                            (void **)((void *)0));
                    if(error) return(error);
                    error = CKTcrtElt((void *)ckt,(void *)modfast,
                            (void **)&fast, eltUid);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,1,lowr);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,2,
                            (void *)CKTnum2nod(ckt, here->URCgndNode));
                    if(error) return(error);
                    ptemp.rValue = prop;
                    error = CKTpName("area",&ptemp,ckt,dtype,nameelt,&fast);
                    if(error) return(error);
      fast->GENowner = here->URCowner;
                } else {
                    nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                    (void)sprintf(nameelt,"clo%d",i);
                    error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,here->URCname
                            ,nameelt,0x4, (void **)((void *)0));
                    if(error) return(error);
                    error = CKTcrtElt((void *)ckt,(void *)modfast,
                            (void **)&fast, eltUid);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,1,lowr);
                    if(error) return(error);
                    error = CKTbindNode((void *)ckt,(void *)fast,2,
                            (void *)CKTnum2nod(ckt, here->URCgndNode));
                    if(error) return(error);
                    ptemp.rValue = c;
                    error = CKTpName("capacitance",&ptemp,ckt,ctype,nameelt,
                            &fast);
                    if(error) return(error);
      fast->GENowner = here->URCowner;
                }
                if(i!=here->URClumps){
                    if(model->URCisPerLGiven) {
                        nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                        (void)sprintf(nameelt,"dhi%d",i);
                        error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                                here->URCname,nameelt,0x4,
                                (void **)((void *)0));
                        if(error) return(error);
                        error = CKTcrtElt((void *)ckt,(void *)modfast,
                                (void **) &fast,eltUid);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,2,
                                (void *)CKTnum2nod(ckt, here->URCgndNode));
                        if(error) return(error);
                        ptemp.rValue = prop;
                        error=CKTpName("area",&ptemp,ckt,dtype,nameelt,&fast);
                        if(error) return(error);
   fast->GENowner = here->URCowner;
                    } else {
                        nameelt = (char *)tmalloc((unsigned int)(10*sizeof(char)));
                        (void)sprintf(nameelt,"chi%d",i);
                        error = (*(SPfrontEnd->IFnewUid))(ckt,&eltUid,
                                here->URCname,nameelt,0x4,
                                (void **)((void *)0));
                        if(error) return(error);
                        error = CKTcrtElt((void *)ckt,(void *)modfast,
                                (void **)&fast,eltUid);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,1,hil);
                        if(error) return(error);
                        error = CKTbindNode((void *)ckt,(void *)fast,2,
                                (void *)CKTnum2nod(ckt, here->URCgndNode));
                        if(error) return(error);
                        ptemp.rValue = c;
                        error =CKTpName("capacitance",&ptemp,ckt,ctype,nameelt,
                                &fast);
                        if(error) return(error);
   fast->GENowner = here->URCowner;
                    }
                }
                prop *= p;
                lowl = lowr;
                hir = hil;
            }
        }
    }
    return(0);
}

variable_types:
matrix
void *

variable_types:
state
int *

variable_types: struct sURCmodel { int URCmodType; struct sURCmodel *URCnextModel; struct sURCinstance { struct sURCmodel *URCmodPtr; struct sURCinstance *URCnextInstance; char *URCname; int URCowner; int URCstate; int URCposNode; int URCnegNode; int URCgndNode; double URClength; int URClumps; unsigned int URClenGiven; unsigned int URClumpsGiven; } *URCinstances; char *URCmodName; double URCk; double URCfmax; double URCrPerL; double URCcPerL; double URCisPerL; double URCrsPerL; unsigned int URCkGiven; unsigned int URCfmaxGiven; unsigned int URCrPerLGiven; unsigned int URCcPerLGiven; unsigned int URCisPerLGiven; unsigned int URCrsPerLGiven; } *

variable_types: struct sURCinstance { struct sURCmodel { int URCmodType; struct sURCmodel *URCnextModel; struct sURCinstance *URCinstances; char *URCmodName; double URCk; double URCfmax; double URCrPerL; double URCcPerL; double URCisPerL; double URCrsPerL; unsigned int URCkGiven; unsigned int URCfmaxGiven; unsigned int URCrPerLGiven; unsigned int URCcPerLGiven; unsigned int URCisPerLGiven; unsigned int URCrsPerLGiven; } *URCmodPtr; struct sURCinstance *URCnextInstance; char *URCname; int URCowner; int URCstate; int URCposNode; int URCnegNode; int URCgndNode; double URClength; int URClumps; unsigned int URClenGiven; unsigned int URClumpsGiven; } *

variable_types: rtype int

variable_types: ctype int

variable_types: dtype int

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

variable_types:
nameelt
char *

variable_types:
namehi
char *

variable_types:
namelo
char *

variable_types: r double

variable_types: c double

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: p double

variable_types: rd double

variable_types: wnorm double

variable_types: prop double

variable_types: i int

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

variable_types: error int

variable_types:
dioUid
char *

variable_types:
resUid
char *

variable_types:
capUid
char *

variable_types:
eltUid
char *


CAPsetup

repo: gserdyuk/gnucap-a

original_code:
int
CAPsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
{
    CAPmodel *model = (CAPmodel*)inModel;
    CAPinstance *here;
    for( ; model != ((void *)0); model = model->CAPnextModel ) {
 if (!model->CAPmCapGiven) {
            model->CAPmCap = 0.0;
        }
        if (!model->CAPcjswGiven){
             model->CAPcjsw = 0.0;
        }
        if (!model->CAPdefWidthGiven) {
            model->CAPdefWidth = 10.e-6;
        }
 if (!model->CAPdefLengthGiven) {
            model->CAPdefLength = 0.0;
        }
        if (!model->CAPnarrowGiven) {
            model->CAPnarrow = 0.0;
        }
        if (!model->CAPshortGiven) {
            model->CAPshort = 0.0;
        }
        if (!model->CAPtc1Given) {
            model->CAPtempCoeff1 = 0.0;
        }
        if (!model->CAPtc2Given) {
            model->CAPtempCoeff2 = 0.0;
        }
 if (!model->CAPtnomGiven) {
            model->CAPtnom = ckt->CKTnomTemp;
        }
 if (!model->CAPdiGiven) {
            model->CAPdi = 0.0;
        }
 if (!model->CAPthickGiven) {
            model->CAPthick = 0.0;
        }
 if (!model->CAPcjGiven) {
     if((model->CAPthickGiven)
        && (model->CAPthick > 0.0)) {
        if (model->CAPdiGiven)
          model->CAPcj = (model->CAPdi * (8.854214871e-12)) / model->CAPthick;
        else
          model->CAPcj = (3.4531479969e-11) / model->CAPthick;
     } else {
        model->CAPcj = 0.0;
     }
        }
        for (here = model->CAPinstances; here != ((void *)0) ;
                here=here->CAPnextInstance) {
     if (here->CAPowner != ARCHme) goto matrixpointers;
            if (!here->CAPlengthGiven) {
                here->CAPlength = 0;
            }
            here->CAPstate = *states;
            *states += 2;
            if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & 0x2) ){
                *states += 2 * (ckt->CKTsenInfo->SENparms);
            }
matrixpointers:
            if((here->CAPposPosptr = SMPmakeElt(matrix,here->CAPposNode,here->CAPposNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPnegNegptr = SMPmakeElt(matrix,here->CAPnegNode,here->CAPnegNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPposNegptr = SMPmakeElt(matrix,here->CAPposNode,here->CAPnegNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPnegPosptr = SMPmakeElt(matrix,here->CAPnegNode,here->CAPposNode))==(double *)((void *)0)){ return(8);}
        }
    }
    return(0);
}

canonical_original_code:
int CAPsetup(void *matrix, struct sGENmodel *inModel, struct CKTcircuit *ckt, int *states)
{
    struct sCAPmodel *model = (CAPmodel*)inModel;
    struct sCAPinstance *here;
    for( ; model != ((void *)0); model = model->CAPnextModel ) {
 if (!model->CAPmCapGiven) {
            model->CAPmCap = 0.0;
        }
        if (!model->CAPcjswGiven){
             model->CAPcjsw = 0.0;
        }
        if (!model->CAPdefWidthGiven) {
            model->CAPdefWidth = 10.e-6;
        }
 if (!model->CAPdefLengthGiven) {
            model->CAPdefLength = 0.0;
        }
        if (!model->CAPnarrowGiven) {
            model->CAPnarrow = 0.0;
        }
        if (!model->CAPshortGiven) {
            model->CAPshort = 0.0;
        }
        if (!model->CAPtc1Given) {
            model->CAPtempCoeff1 = 0.0;
        }
        if (!model->CAPtc2Given) {
            model->CAPtempCoeff2 = 0.0;
        }
 if (!model->CAPtnomGiven) {
            model->CAPtnom = ckt->CKTnomTemp;
        }
 if (!model->CAPdiGiven) {
            model->CAPdi = 0.0;
        }
 if (!model->CAPthickGiven) {
            model->CAPthick = 0.0;
        }
 if (!model->CAPcjGiven) {
     if((model->CAPthickGiven)
        && (model->CAPthick > 0.0)) {
        if (model->CAPdiGiven)
          model->CAPcj = (model->CAPdi * (8.854214871e-12)) / model->CAPthick;
        else
          model->CAPcj = (3.4531479969e-11) / model->CAPthick;
     } else {
        model->CAPcj = 0.0;
     }
        }
        for (here = model->CAPinstances; here != ((void *)0) ;
                here=here->CAPnextInstance) {
     if (here->CAPowner != ARCHme) goto matrixpointers;
            if (!here->CAPlengthGiven) {
                here->CAPlength = 0;
            }
            here->CAPstate = *states;
            *states += 2;
            if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & 0x2) ){
                *states += 2 * (ckt->CKTsenInfo->SENparms);
            }
matrixpointers:
            if((here->CAPposPosptr = SMPmakeElt(matrix,here->CAPposNode,here->CAPposNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPnegNegptr = SMPmakeElt(matrix,here->CAPnegNode,here->CAPnegNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPposNegptr = SMPmakeElt(matrix,here->CAPposNode,here->CAPnegNode))==(double *)((void *)0)){ return(8);}
            if((here->CAPnegPosptr = SMPmakeElt(matrix,here->CAPnegNode,here->CAPposNode))==(double *)((void *)0)){ return(8);}
        }
    }
    return(0);
}

variable_types:
matrix
void *

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:
states
int *

variable_types: struct sCAPmodel { int CAPmodType; struct sCAPmodel *CAPnextModel; struct sCAPinstance { struct sCAPmodel *CAPmodPtr; struct sCAPinstance *CAPnextInstance; char *CAPname; int CAPowner; int CAPstate; int CAPposNode; int CAPnegNode; double CAPtemp; double CAPdtemp; double CAPcapac; double CAPinitCond; double CAPwidth; double CAPlength; double CAPscale; double CAPm; double *CAPposPosptr; double *CAPnegNegptr; double *CAPposNegptr; double *CAPnegPosptr; unsigned int CAPcapGiven; unsigned int CAPicGiven; unsigned int CAPwidthGiven; unsigned int CAPlengthGiven; unsigned int CAPtempGiven; unsigned int CAPdtempGiven; unsigned int CAPscaleGiven; unsigned int CAPmGiven; int CAPsenParmNo; } *CAPinstances; char *CAPmodName; double CAPtnom; double CAPtempCoeff1; double CAPtempCoeff2; double CAPmCap; double CAPcj; double CAPcjsw; double CAPdefWidth; double CAPdefLength; double CAPnarrow; double CAPshort; double CAPdi; double CAPthick; unsigned int CAPmCapGiven; unsigned int CAPcjGiven; unsigned int CAPcjswGiven; unsigned int CAPdefWidthGiven; unsigned int CAPdefLengthGiven; unsigned int CAPnarrowGiven; unsigned int CAPshortGiven; unsigned int CAPtnomGiven; unsigned int CAPtc1Given; unsigned int CAPtc2Given; unsigned int CAPdiGiven; unsigned int CAPthickGiven; } *

variable_types: struct sCAPinstance { struct sCAPmodel { int CAPmodType; struct sCAPmodel *CAPnextModel; struct sCAPinstance *CAPinstances; char *CAPmodName; double CAPtnom; double CAPtempCoeff1; double CAPtempCoeff2; double CAPmCap; double CAPcj; double CAPcjsw; double CAPdefWidth; double CAPdefLength; double CAPnarrow; double CAPshort; double CAPdi; double CAPthick; unsigned int CAPmCapGiven; unsigned int CAPcjGiven; unsigned int CAPcjswGiven; unsigned int CAPdefWidthGiven; unsigned int CAPdefLengthGiven; unsigned int CAPnarrowGiven; unsigned int CAPshortGiven; unsigned int CAPtnomGiven; unsigned int CAPtc1Given; unsigned int CAPtc2Given; unsigned int CAPdiGiven; unsigned int CAPthickGiven; } *CAPmodPtr; struct sCAPinstance *CAPnextInstance; char *CAPname; int CAPowner; int CAPstate; int CAPposNode; int CAPnegNode; double CAPtemp; double CAPdtemp; double CAPcapac; double CAPinitCond; double CAPwidth; double CAPlength; double CAPscale; double CAPm; double *CAPposPosptr; double *CAPnegNegptr; double *CAPposNegptr; double *CAPnegPosptr; unsigned int CAPcapGiven; unsigned int CAPicGiven; unsigned int CAPwidthGiven; unsigned int CAPlengthGiven; unsigned int CAPtempGiven; unsigned int CAPdtempGiven; unsigned int CAPscaleGiven; unsigned int CAPmGiven; int CAPsenParmNo; } *

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; }