original_code:
int pp_para_sql(const Statement *stmt,
    const Parameter *p,
    _Bool before,
    void *user_ptr)
{
  SQL_PP_State *s = user_ptr;
  if (!p->pos && p->iteration && s->tokens) {
    s->tokens_pos = 0;
    tprintf(";\n");
    SQL_Token *i = s->tokens + s->tokens_pos;
    if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
      tprintf("%.*s", (int) (i->end - i->begin), i->begin);
      ++s->tokens_pos;
    }
  }
  if (s->tokens_pos >= s->tokens_size)
    return -1;
  SQL_Token *i = s->tokens + s->tokens_pos;
  switch (p->direction) {
    case PARA_IN:
      if (stmt->type == SELECT && p->iteration > 0 && before)
        return 0;
      break;
    case PARA_OUT:
      if (before) {
        if (s->tokens_pos < s->tokens_size && i->begin && i->host_var) {
          tprintf("%.*s", (int)(i->end - i->begin), i->begin);
          ++s->tokens_pos;
          ++i;
          if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
            tprintf("%.*s", (int)(i->end - i->begin), i->begin);
            ++s->tokens_pos;
          }
        }
        return 0;
      }
      break;
  }
  if (s->tokens_pos < s->tokens_size && i->begin && i->host_var) {
    int ret_val = pp_para_sql_value(stmt, p, before, user_ptr);
    do { if (ret_val) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "prettyprint.c", 374, (0) ? (0) : ""); return (ret_val); } } while (0);
    ++s->tokens_pos;
    ++i;
  }
  if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
    tprintf("%.*s", (int) (i->end - i->begin), i->begin);
    ++s->tokens_pos;
  }
  return 0;
}

canonical_original_code:
int pp_para_sql(struct Statement *stmt, struct Parameter *p, _Bool before, void *user_ptr)
{
  struct SQL_PP_State *s = user_ptr;
  if (!p->pos && p->iteration && s->tokens) {
    s->tokens_pos = 0;
    tprintf(";\n");
    struct SQL_Token *i = s->tokens + s->tokens_pos;
    if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
      tprintf("%.*s", (int) (i->end - i->begin), i->begin);
      ++s->tokens_pos;
    }
  }
  if (s->tokens_pos >= s->tokens_size)
    return -1;
  struct SQL_Token *i = s->tokens + s->tokens_pos;
  switch (p->direction) {
    case PARA_IN:
      if (stmt->type == SELECT && p->iteration > 0 && before)
        return 0;
      break;
    case PARA_OUT:
      if (before) {
        if (s->tokens_pos < s->tokens_size && i->begin && i->host_var) {
          tprintf("%.*s", (int)(i->end - i->begin), i->begin);
          ++s->tokens_pos;
          ++i;
          if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
            tprintf("%.*s", (int)(i->end - i->begin), i->begin);
            ++s->tokens_pos;
          }
        }
        return 0;
      }
      break;
  }
  if (s->tokens_pos < s->tokens_size && i->begin && i->host_var) {
    int ret_val = pp_para_sql_value(stmt, p, before, user_ptr);
    do { if (ret_val) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "prettyprint.c", 374, (0) ? (0) : ""); return (ret_val); } } while (0);
    ++s->tokens_pos;
    ++i;
  }
  if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
    tprintf("%.*s", (int) (i->end - i->begin), i->begin);
    ++s->tokens_pos;
  }
  return 0;
}

variable_types: struct SQL_Token { _Bool host_var; char *begin; char *end; } *

user_defined_types: enum Para_Type { PARA_IN=0, PARA_OUT=1 }

user_defined_types: enum type_no { CHAR=1, INT=3, DOUBLE=4, STRING0=5, VARCHAR=9, VOID=10, UNSIGNED=68, STRING=97 }


repo: gsauthof/traceproc

decompiled_code:
__int64 __fastcall stats_init(_QWORD *a1, size_t a2, size_t a3)
{
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
__int64 v9; // r8

v4 = calloc(a2, 8uLL);
*a1 = v4;
if ( v4 )
{
v5 = calloc(a3, 8uLL);
a1[2] = v5;
if ( v5 )
{
v6 = calloc(a2, 0x10uLL);
a1[4] = v6;
if ( v6 )
{
v7 = calloc(a3, 0x10uLL);
a1[7] = v7;
if ( v7 )
return 0LL;
v9 = 40LL;
}
else
{
v9 = 38LL;
}
}
else
{
v9 = 36LL;
}
}
else
{
v9 = 34LL;
}
fprintf(stderr, "%s() %s:%d: NULL returned\n", "stats_init", "stats.c", v9);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, size_t a2, size_t a3)
{
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
__int64 v9; // r8

v4 = calloc(a2, 8uLL);
*a1 = v4;
if ( v4 )
{
v5 = calloc(a3, 8uLL);
a1[2] = v5;
if ( v5 )
{
v6 = calloc(a2, 0x10uLL);
a1[4] = v6;
if ( v6 )
{
v7 = calloc(a3, 0x10uLL);
a1[7] = v7;
if ( v7 )
return 0LL;
v9 = 40LL;
}
else
{
v9 = 38LL;
}
}
else
{
v9 = 36LL;
}
}
else
{
v9 = 34LL;
}
fprintf(stderr, "%s() %s:%d: NULL returned\n", "stats_init", "stats.c", v9);
return 0xFFFFFFFFLL;
}

original_code:
int stats_init(Stats *stats, size_t type_size, size_t fn_size)
{
  stats->counts = calloc(type_size, sizeof(size_t));
  do { if (!stats->counts) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 34); return (-1); } } while (0);
  stats->fn_counts = calloc(fn_size, sizeof(size_t));
  do { if (!stats->fn_counts) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 36); return (-1); } } while (0);
  stats->times = calloc(type_size, sizeof(struct timespec));
  do { if (!stats->times) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 38); return (-1); } } while (0);
  stats->fn_times = calloc(fn_size, sizeof(struct timespec));
  do { if (!stats->fn_times) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 40); return (-1); } } while (0);
  return 0;
}

canonical_original_code:
int stats_init(struct Stats *stats, unsigned long type_size, unsigned long fn_size)
{
  stats->counts = calloc(type_size, sizeof(unsigned long));
  do { if (!stats->counts) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 34); return (-1); } } while (0);
  stats->fn_counts = calloc(fn_size, sizeof(unsigned long));
  do { if (!stats->fn_counts) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 36); return (-1); } } while (0);
  stats->times = calloc(type_size, sizeof(struct timespec));
  do { if (!stats->times) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 38); return (-1); } } while (0);
  stats->fn_times = calloc(fn_size, sizeof(struct timespec));
  do { if (!stats->fn_times) { fprintf(stderr, "%s() %s:%d: NULL returned\n", __func__, "stats.c", 40); return (-1); } } while (0);
  return 0;
}

variable_types: struct Stats { unsigned long *counts; unsigned long count_sum; unsigned long *fn_counts; unsigned long fn_count_sum; struct timespec { long tv_sec; long tv_nsec; } *times; struct timespec time_sum; struct timespec *fn_times; struct timespec fn_time_sum; struct timespec prog_start; struct timespec prog_end; struct timespec prog_time; } *

return_type: int

user_defined_types: struct Stats { unsigned long *counts; unsigned long count_sum; unsigned long *fn_counts; unsigned long fn_count_sum; struct timespec *times; struct timespec time_sum; struct timespec *fn_times; struct timespec fn_time_sum; struct timespec prog_start; struct timespec prog_end; struct timespec prog_time; }


original_code:
int stats_sum_up(Stats *stats, size_t type_size, size_t fn_size,
    const struct timespec *prog_time)
{
  if (prog_time)
    stats->prog_time = *prog_time;
  stats->count_sum = 0;
  stats->time_sum = (const struct timespec) {0};
  for (size_t i = 0; i<type_size; ++i) {
    stats->count_sum += stats->counts[i];
    int ret = timespec_add(&stats->time_sum, stats->times + i);
    do { if (ret) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "stats.c", 55, (0) ? (0) : ""); exit(10); } } while (0);
  }
  stats->fn_count_sum = 0;
  stats->fn_time_sum = (const struct timespec) {0};
  for (size_t i = 0; i<fn_size; ++i) {
    stats->fn_count_sum += stats->fn_counts[i];
    int ret = timespec_add(&stats->fn_time_sum, stats->fn_times + i);
    do { if (ret) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "stats.c", 63, (0) ? (0) : ""); exit(10); } } while (0);
  }
  return 0;
}

canonical_original_code:
int stats_sum_up(struct Stats *stats, unsigned long type_size, unsigned long fn_size, struct timespec *prog_time)
{
  if (prog_time)
    stats->prog_time = *prog_time;
  stats->count_sum = 0;
  stats->time_sum = (struct timespec) {0};
  for (unsigned long i = 0; i<type_size; ++i) {
    stats->count_sum += stats->counts[i];
    int ret = timespec_add(&stats->time_sum, stats->times + i);
    do { if (ret) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "stats.c", 55, (0) ? (0) : ""); exit(10); } } while (0);
  }
  stats->fn_count_sum = 0;
  stats->fn_time_sum = (struct timespec) {0};
  for (unsigned long i = 0; i<fn_size; ++i) {
    stats->fn_count_sum += stats->fn_counts[i];
    int ret = timespec_add(&stats->fn_time_sum, stats->fn_times + i);
    do { if (ret) { fprintf(stderr, "%s() %s:%d: Error %s\n", __func__, "stats.c", 63, (0) ? (0) : ""); exit(10); } } while (0);
  }
  return 0;
}

variable_types:
i
unsigned long

variable_types: ret int

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


original_code:
int stats_pp_fns(const Stats *stats, char const * const * names,
    unsigned n)
{
  tprintf("\n%20s | %10s | %14s | %4s\n",
      "FUNCTION", "COUNT", "TIME (s)", "%");
  tprintf("---------------------+------------+----------------+-----\n");
  struct timespec other = stats->prog_time;
  for (unsigned i = 0; i<n; ++i) {
    if (!stats->fn_counts[i])
      continue;
    char t[15] = {0};
    timespec_pp_intv(&stats->fn_times[i], t, 15);
    tprintf("%20s | %10zu | %14s | %.2f\n",
        names[i],
        stats->fn_counts[i],
        t,
        timespec_cent(&stats->fn_times[i], &stats->prog_time)
        );
    timespec_minus(&other, &stats->fn_times[i]);
  }
  char t[15] = {0};
  timespec_pp_intv(&other, t, 15);
  tprintf("%20s | %10s | %14s | %.2f\n",
      "non-sql", "x", t, timespec_cent(&other, &stats->prog_time));
  tprintf("=====================+============+================+=====\n");
  t[0] = 0;
  timespec_pp_intv(&stats->prog_time, t, 15);
  tprintf("%20s | %10zu | %14s | %4s\n",
      "SUM",stats->fn_count_sum, t, "1.00");
  return 0;
}

canonical_original_code:
int stats_pp_fns(struct Stats *stats, char **names, unsigned int n)
{
  tprintf("\n%20s | %10s | %14s | %4s\n",
      "FUNCTION", "COUNT", "TIME (s)", "%");
  tprintf("---------------------+------------+----------------+-----\n");
  struct timespec other = stats->prog_time;
  for (unsigned int i = 0; i<n; ++i) {
    if (!stats->fn_counts[i])
      continue;
    char t[15] = {0};
    timespec_pp_intv(&stats->fn_times[i], t, 15);
    tprintf("%20s | %10zu | %14s | %.2f\n",
        names[i],
        stats->fn_counts[i],
        t,
        timespec_cent(&stats->fn_times[i], &stats->prog_time)
        );
    timespec_minus(&other, &stats->fn_times[i]);
  }
  char t[15] = {0};
  timespec_pp_intv(&other, t, 15);
  tprintf("%20s | %10s | %14s | %.2f\n",
      "non-sql", "x", t, timespec_cent(&other, &stats->prog_time));
  tprintf("=====================+============+================+=====\n");
  t[0] = 0;
  timespec_pp_intv(&stats->prog_time, t, 15);
  tprintf("%20s | %10zu | %14s | %4s\n",
      "SUM",stats->fn_count_sum, t, "1.00");
  return 0;
}

variable_types:
names
char **

variable_types:
n
unsigned int

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types:
i
unsigned int

variable_types:
t
char [15]


teardown

decompiled_code:
void teardown()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void teardown()
{
}

canonical_original_code:
static void teardown()
{
}

return_type: void


setup

decompiled_code:
void *setup()
{
int v0; // eax
__int64 v1; // rax

v0 = pipe(pipefd);
if ( v0 )
{
v1 = ck_assert_failed(
"unittest/test_trace.c",
95LL,
"Assertion '_ck_x == _ck_y' failed",
"Assertion '%s' failed: %s == %jd, %s == %jd",
"ret_pipe == 0",
"ret_pipe",
v0,
"0",
0LL);
}
else
{
mark_point("unittest/test_trace.c", 95LL);
v1 = pthread_create(&slave_id, 0LL, slave_fn, pipefd);
if ( !(_DWORD)v1 )
return (void *)mark_point("unittest/test_trace.c", 97LL);
}
ck_assert_failed(
"unittest/test_trace.c",
97LL,
"Assertion '_ck_x == _ck_y' failed",
"Assertion '%s' failed: %s == %jd, %s == %jd",
"ret_cre == 0",
"ret_cre",
v1,
"0",
0LL);
return slave_fn("unittest/test_trace.c");
}

canonical_decompiled_code:
void *func2()
{
int v0; // eax
__int64 v1; // rax

v0 = pipe(pipefd);
if ( v0 )
{
v1 = ck_assert_failed(
"unittest/test_trace.c",
95LL,
"Assertion '_ck_x == _ck_y' failed",
"Assertion '%s' failed: %s == %jd, %s == %jd",
"ret_pipe == 0",
"ret_pipe",
v0,
"0",
0LL);
}
else
{
mark_point("unittest/test_trace.c", 95LL);
v1 = pthread_create(&slave_id, 0LL, slave_fn, pipefd);
if ( !(_DWORD)v1 )
return (void *)mark_point("unittest/test_trace.c", 97LL);
}
ck_assert_failed(
"unittest/test_trace.c",
97LL,
"Assertion '_ck_x == _ck_y' failed",
"Assertion '%s' failed: %s == %jd, %s == %jd",
"ret_cre == 0",
"ret_cre",
v1,
"0",
0LL);
return func3("unittest/test_trace.c");
}

original_code:
static void setup()
{
  int ret_pipe = pipe(pipefd);
  do { intmax_t _ck_x = (ret_pipe); intmax_t _ck_y = (0); (_ck_x == _ck_y) ? _mark_point("unittest/test_trace.c", 95) : _ck_assert_failed("unittest/test_trace.c", 95, "Assertion '""_ck_x == _ck_y""' failed" , "Assertion '%s' failed: %s == %jd, %s == %jd", "ret_pipe"" ""=="" ""0", "ret_pipe", _ck_x, "0", _ck_y, ((void *)0)); } while (0);
  int ret_cre = pthread_create(&slave_id, 0, slave_fn, pipefd);
  do { intmax_t _ck_x = (ret_cre); intmax_t _ck_y = (0); (_ck_x == _ck_y) ? _mark_point("unittest/test_trace.c", 97) : _ck_assert_failed("unittest/test_trace.c", 97, "Assertion '""_ck_x == _ck_y""' failed" , "Assertion '%s' failed: %s == %jd, %s == %jd", "ret_cre"" ""=="" ""0", "ret_cre", _ck_x, "0", _ck_y, ((void *)0)); } while (0);
}

canonical_original_code:
static void setup()
{
  int ret_pipe = pipe(pipefd);
  do { long _ck_x = (ret_pipe); long _ck_y = (0); (_ck_x == _ck_y) ? _mark_point("unittest/test_trace.c", 95) : _ck_assert_failed("unittest/test_trace.c", 95, "Assertion '""_ck_x == _ck_y""' failed" , "Assertion '%s' failed: %s == %jd, %s == %jd", "ret_pipe"" ""=="" ""0", "ret_pipe", _ck_x, "0", _ck_y, ((void *)0)); } while (0);
  int ret_cre = pthread_create(&slave_id, 0, slave_fn, pipefd);
  do { long _ck_x = (ret_cre); long _ck_y = (0); (_ck_x == _ck_y) ? _mark_point("unittest/test_trace.c", 97) : _ck_assert_failed("unittest/test_trace.c", 97, "Assertion '""_ck_x == _ck_y""' failed" , "Assertion '%s' failed: %s == %jd, %s == %jd", "ret_cre"" ""=="" ""0", "ret_cre", _ck_x, "0", _ck_y, ((void *)0)); } while (0);
}


decompiled_code:
__int64 __fastcall slave_fn(void *a1)
{
__int64 *v1; // rbp
size_t v2; // rbx
int v3; // er12
ssize_t v4; // rax

v1 = &buffer;
v2 = 1024LL;
memset(&buffer, 0, 0x400uLL);
v3 = *(_DWORD *)a1;
while ( 1 )
{
v4 = read(v3, v1, v2);
if ( v4 < 0 )
return -1LL;
if ( !v4 )
break;
v2 -= v4;
v1 = (__int64 *)((char *)v1 + v4);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *a1)
{
__int64 *v1; // rbp
size_t v2; // rbx
int v3; // er12
ssize_t v4; // rax

v1 = &buffer;
v2 = 1024LL;
memset(&buffer, 0, 0x400uLL);
v3 = *(_DWORD *)a1;
while ( 1 )
{
v4 = read(v3, v1, v2);
if ( v4 < 0 )
return -1LL;
if ( !v4 )
break;
v2 -= v4;
v1 = (__int64 *)((char *)v1 + v4);
}
return 0LL;
}

original_code:
static void *slave_fn(void *arg)
{
  memset(buffer, 0, 1024);
  int fd = *(int*)arg;
  size_t left = 1024;
  char *p = buffer;
  for (;;) {
    ssize_t n = read(fd, p, left);
    if (n<0)
      return (void*) -1;
    if (!n)
      break;
    left -= n;
    p += n;
  }
  return (void*) 0;
}

canonical_original_code:
static void *slave_fn(void *arg)
{
  memset(buffer, 0, 1024);
  int fd = *(int*)arg;
  unsigned long left = 1024;
  char *p = buffer;
  for (;;) {
    long n = read(fd, p, left);
    if (n<0)
      return (void *) -1;
    if (!n)
      break;
    left -= n;
    p += n;
  }
  return (void *) 0;
}

variable_types:
arg
void *

variable_types: fd int

variable_types:
left
unsigned long

variable_types:
p
char *

variable_types: n long

return_type: void *


decompiled_code:
char *__fastcall trace_set_ftime(char *src)
{
return strncpy(&dest, src, 0x1FuLL);
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
return strncpy(&dest, src, 0x1FuLL);
}

original_code:
void trace_set_ftime(const char *format)
{
  strncpy(trace_state.format, format, 31);
}

canonical_original_code:
void trace_set_ftime(char *format)
{
  strncpy(trace_state.format, format, 31);
}

variable_types:
format
char *


tprintf

decompiled_code:
// local variable allocation has failed, the output may be wrong!
__int64 tprintf(char *s, ...)
{
char *v1; // rbx
unsigned int v2; // er12
size_t v3; // rax
int v4; // er13
int v5; // ebp
int *v7; // rax
char *v8; // rax
struct timespec v9; // [rsp+0h] [rbp-108h] BYREF
gcc_va_list arg; // [rsp+10h] [rbp-F8h] OVERLAPPED BYREF

v1 = s;
if ( byte_288 && dest )
{
v9 = 0LL;
v5 = clock_gettime(0, &v9);
*(_OWORD *)&arg[0].gp_offset = 0LL;
*(_OWORD *)&arg[0].reg_save_area = 0LL;
if ( v5 )
{
v7 = _errno_location();
v5 = -1;
v8 = strerror(*v7);
fprintf(stderr, "clock_gettime: %s\n", v8);
strcpy((char *)arg, "XXX ");
}
else if ( !timespec_strftime(arg, 32LL, &dest, &v9) )
{
LOBYTE(arg[0].gp_offset) = 0;
v5 = -1;
}
v4 = fprintf(trace_state, "%s", (const char *)arg);
va_start(arg, s);
v2 = vfprintf(trace_state, s, arg);
v3 = strlen(s);
if ( !v3 )
goto LABEL_6;
}
else
{
va_start(arg, s);
v2 = vfprintf(trace_state, s, arg);
v3 = strlen(s);
if ( !v3 )
{
byte_288 = *s == 10;
return v2;
}
v4 = 0;
v5 = 0;
}
v1 = &s[v3 - 1];
LABEL_6:
byte_288 = *v1 == 10;
v2 += v4;
if ( v5 )
v2 = -1;
return v2;
}

canonical_decompiled_code:
__int64 func2(char *s, ...)
{
char *v1; // rbx
unsigned int v2; // er12
size_t v3; // rax
int v4; // er13
int v5; // ebp
int *v7; // rax
char *v8; // rax
struct timespec v9; // [rsp+0h] [rbp-108h] BYREF
gcc_va_list arg; // [rsp+10h] [rbp-F8h] OVERLAPPED BYREF

v1 = s;
if ( byte_288 && dest )
{
v9 = 0LL;
v5 = clock_gettime(0, &v9);
*(_OWORD *)&arg[0].gp_offset = 0LL;
*(_OWORD *)&arg[0].reg_save_area = 0LL;
if ( v5 )
{
v7 = _errno_location();
v5 = -1;
v8 = strerror(*v7);
fprintf(stderr, "clock_gettime: %s\n", v8);
strcpy((char *)arg, "XXX ");
}
else if ( !timespec_strftime(arg, 32LL, &dest, &v9) )
{
LOBYTE(arg[0].gp_offset) = 0;
v5 = -1;
}
v4 = fprintf(trace_state, "%s", (const char *)arg);
va_start(arg, s);
v2 = vfprintf(trace_state, s, arg);
v3 = strlen(s);
if ( !v3 )
goto LABEL_6;
}
else
{
va_start(arg, s);
v2 = vfprintf(trace_state, s, arg);
v3 = strlen(s);
if ( !v3 )
{
byte_288 = *s == 10;
return v2;
}
v4 = 0;
v5 = 0;
}
v1 = &s[v3 - 1];
LABEL_6:
byte_288 = *v1 == 10;
v2 += v4;
if ( v5 )
v2 = -1;
return v2;
}

original_code:
int tprintf(const char *format, ...)
{
  int code = 0;
  int ret_t = 0;
  if (trace_state.last_was_nl && *trace_state.format) {
    struct timespec ts = {0};
    int ret_clock = clock_gettime(0, &ts);
    char prefix[32] = {0};
    if (ret_clock) {
      fprintf(stderr, "clock_gettime: %s\n", strerror((*__errno_location ())));
      strcpy(prefix, "XXX ");
      code = -1;
    } else {
      size_t ret_strf = timespec_strftime(prefix, 32, trace_state.format, &ts);
      if (!ret_strf) {
        *prefix = 0;
        code = -1;
      }
    }
    ret_t = fprintf(trace_state.file, "%s", prefix);
  }
  va_list args;
  __builtin_va_start(args,format);
  int ret_f = vfprintf(trace_state.file, format, args);
  __builtin_va_end(args);
  size_t n = strlen(format);
  if (n)
    --n;
  trace_state.last_was_nl = format[n] == '\n';
  if (code >= 0)
    code = ret_t + ret_f;
  return code;
}

canonical_original_code:
int tprintf(char *format, ...)
{
  int code = 0;
  int ret_t = 0;
  if (trace_state.last_was_nl && *trace_state.format) {
    struct timespec ts = {0};
    int ret_clock = clock_gettime(0, &ts);
    char prefix[32] = {0};
    if (ret_clock) {
      fprintf(stderr, "clock_gettime: %s\n", strerror((*__errno_location ())));
      strcpy(prefix, "XXX ");
      code = -1;
    } else {
      unsigned long ret_strf = timespec_strftime(prefix, 32, trace_state.format, &ts);
      if (!ret_strf) {
        *prefix = 0;
        code = -1;
      }
    }
    ret_t = fprintf(trace_state.file, "%s", prefix);
  }
  __builtin_va_list args;
  __builtin_va_start(args,format);
  int ret_f = vfprintf(trace_state.file, format, args);
  __builtin_va_end(args);
  unsigned long n = strlen(format);
  if (n)
    --n;
  trace_state.last_was_nl = format[n] == '\n';
  if (code >= 0)
    code = ret_t + ret_f;
  return code;
}

variable_types: code int

variable_types:
prefix
char [32]

variable_types:
n
unsigned long


repo: gserdyuk/gnucap-a

original_code:
int
B1acLoad(GENmodel *inModel, CKTcircuit *ckt)
{
    B1model *model = (B1model*)inModel;
    B1instance *here;
    int xnrm;
    int xrev;
    double gdpr;
    double gspr;
    double gm;
    double gds;
    double gmbs;
    double gbd;
    double gbs;
    double capbd;
    double capbs;
    double xcggb;
    double xcgdb;
    double xcgsb;
    double xcbgb;
    double xcbdb;
    double xcbsb;
    double xcddb;
    double xcssb;
    double xcdgb;
    double xcsgb;
    double xcdsb;
    double xcsdb;
    double cggb;
    double cgdb;
    double cgsb;
    double cbgb;
    double cbdb;
    double cbsb;
    double cddb;
    double cdgb;
    double cdsb;
    double omega;
    double m;
    omega = ckt->CKTomega;
    for( ; model != ((void *)0); model = model->B1nextModel) {
        for(here = model->B1instances; here!= ((void *)0);
                here = here->B1nextInstance) {
     if (here->B1owner != ARCHme) continue;
            if (here->B1mode >= 0) {
                xnrm=1;
                xrev=0;
            } else {
                xnrm=0;
                xrev=1;
            }
            gdpr=here->B1drainConductance;
            gspr=here->B1sourceConductance;
            gm= *(ckt->CKTstates[0] + here->B1states+ 7);
            gds= *(ckt->CKTstates[0] + here->B1states+ 8);
            gmbs= *(ckt->CKTstates[0] + here->B1states+ 9);
            gbd= *(ckt->CKTstates[0] + here->B1states+ 10);
            gbs= *(ckt->CKTstates[0] + here->B1states+ 11);
            capbd= *(ckt->CKTstates[0] + here->B1states+ 24);
            capbs= *(ckt->CKTstates[0] + here->B1states+ 26);
            cggb = *(ckt->CKTstates[0] + here->B1states+ 18);
            cgsb = *(ckt->CKTstates[0] + here->B1states+ 20);
            cgdb = *(ckt->CKTstates[0] + here->B1states+ 19);
            cbgb = *(ckt->CKTstates[0] + here->B1states+ 21);
            cbsb = *(ckt->CKTstates[0] + here->B1states+ 23);
            cbdb = *(ckt->CKTstates[0] + here->B1states+ 22);
            cdgb = *(ckt->CKTstates[0] + here->B1states+ 28);
            cdsb = *(ckt->CKTstates[0] + here->B1states+ 30);
            cddb = *(ckt->CKTstates[0] + here->B1states+ 29);
            xcdgb = (cdgb - here->B1GDoverlapCap) * omega;
            xcddb = (cddb + capbd + here->B1GDoverlapCap) * omega;
            xcdsb = cdsb * omega;
            xcsgb = -(cggb + cbgb + cdgb + here->B1GSoverlapCap ) * omega;
            xcsdb = -(cgdb + cbdb + cddb) * omega;
            xcssb = (capbs + here->B1GSoverlapCap - (cgsb+cbsb+cdsb)) * omega;
            xcggb = (cggb + here->B1GDoverlapCap + here->B1GSoverlapCap +
                    here->B1GBoverlapCap) * omega;
            xcgdb = (cgdb - here->B1GDoverlapCap ) * omega;
            xcgsb = (cgsb - here->B1GSoverlapCap) * omega;
            xcbgb = (cbgb - here->B1GBoverlapCap) * omega;
            xcbdb = (cbdb - capbd ) * omega;
            xcbsb = (cbsb - capbs ) * omega;
            m = here->B1m;
            *(here->B1GgPtr +1) += m * xcggb;
            *(here->B1BbPtr +1) += m * (-xcbgb-xcbdb-xcbsb);
            *(here->B1DPdpPtr +1) += m * xcddb;
            *(here->B1SPspPtr +1) += m * xcssb;
            *(here->B1GbPtr +1) += m * (-xcggb-xcgdb-xcgsb);
            *(here->B1GdpPtr +1) += m * xcgdb;
            *(here->B1GspPtr +1) += m * xcgsb;
            *(here->B1BgPtr +1) += m * xcbgb;
            *(here->B1BdpPtr +1) += m * xcbdb;
            *(here->B1BspPtr +1) += m * xcbsb;
            *(here->B1DPgPtr +1) += m * xcdgb;
            *(here->B1DPbPtr +1) += m * (-xcdgb-xcddb-xcdsb);
            *(here->B1DPspPtr +1) += m * xcdsb;
            *(here->B1SPgPtr +1) += m * xcsgb;
            *(here->B1SPbPtr +1) += m * (-xcsgb-xcsdb-xcssb);
            *(here->B1SPdpPtr +1) += m * xcsdb;
            *(here->B1DdPtr) += m * gdpr;
            *(here->B1SsPtr) += m * gspr;
            *(here->B1BbPtr) += m * (gbd+gbs);
            *(here->B1DPdpPtr) += m * (gdpr+gds+gbd+xrev*(gm+gmbs));
            *(here->B1SPspPtr) += m * (gspr+gds+gbs+xnrm*(gm+gmbs));
            *(here->B1DdpPtr) -= m * gdpr;
            *(here->B1SspPtr) -= m * gspr;
            *(here->B1BdpPtr) -= m * gbd;
            *(here->B1BspPtr) -= m * gbs;
            *(here->B1DPdPtr) -= m * gdpr;
            *(here->B1DPgPtr) += m * (xnrm-xrev)*gm;
            *(here->B1DPbPtr) += m * (-gbd+(xnrm-xrev)*gmbs);
            *(here->B1DPspPtr) += m * (-gds-xnrm*(gm+gmbs));
            *(here->B1SPgPtr) += m * (-(xnrm-xrev)*gm);
            *(here->B1SPsPtr) -= m * gspr;
            *(here->B1SPbPtr) += m * (-gbs-(xnrm-xrev)*gmbs);
            *(here->B1SPdpPtr) += m * (-gds-xrev*(gm+gmbs));
        }
    }
return(0);
}

canonical_original_code:
int B1acLoad(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sBSIM1model *model = (B1model*)inModel;
    struct sBSIM1instance *here;
    int xnrm;
    int xrev;
    double gdpr;
    double gspr;
    double gm;
    double gds;
    double gmbs;
    double gbd;
    double gbs;
    double capbd;
    double capbs;
    double xcggb;
    double xcgdb;
    double xcgsb;
    double xcbgb;
    double xcbdb;
    double xcbsb;
    double xcddb;
    double xcssb;
    double xcdgb;
    double xcsgb;
    double xcdsb;
    double xcsdb;
    double cggb;
    double cgdb;
    double cgsb;
    double cbgb;
    double cbdb;
    double cbsb;
    double cddb;
    double cdgb;
    double cdsb;
    double omega;
    double m;
    omega = ckt->CKTomega;
    for( ; model != ((void *)0); model = model->B1nextModel) {
        for(here = model->B1instances; here!= ((void *)0);
                here = here->B1nextInstance) {
     if (here->B1owner != ARCHme) continue;
            if (here->B1mode >= 0) {
                xnrm=1;
                xrev=0;
            } else {
                xnrm=0;
                xrev=1;
            }
            gdpr=here->B1drainConductance;
            gspr=here->B1sourceConductance;
            gm= *(ckt->CKTstates[0] + here->B1states+ 7);
            gds= *(ckt->CKTstates[0] + here->B1states+ 8);
            gmbs= *(ckt->CKTstates[0] + here->B1states+ 9);
            gbd= *(ckt->CKTstates[0] + here->B1states+ 10);
            gbs= *(ckt->CKTstates[0] + here->B1states+ 11);
            capbd= *(ckt->CKTstates[0] + here->B1states+ 24);
            capbs= *(ckt->CKTstates[0] + here->B1states+ 26);
            cggb = *(ckt->CKTstates[0] + here->B1states+ 18);
            cgsb = *(ckt->CKTstates[0] + here->B1states+ 20);
            cgdb = *(ckt->CKTstates[0] + here->B1states+ 19);
            cbgb = *(ckt->CKTstates[0] + here->B1states+ 21);
            cbsb = *(ckt->CKTstates[0] + here->B1states+ 23);
            cbdb = *(ckt->CKTstates[0] + here->B1states+ 22);
            cdgb = *(ckt->CKTstates[0] + here->B1states+ 28);
            cdsb = *(ckt->CKTstates[0] + here->B1states+ 30);
            cddb = *(ckt->CKTstates[0] + here->B1states+ 29);
            xcdgb = (cdgb - here->B1GDoverlapCap) * omega;
            xcddb = (cddb + capbd + here->B1GDoverlapCap) * omega;
            xcdsb = cdsb * omega;
            xcsgb = -(cggb + cbgb + cdgb + here->B1GSoverlapCap ) * omega;
            xcsdb = -(cgdb + cbdb + cddb) * omega;
            xcssb = (capbs + here->B1GSoverlapCap - (cgsb+cbsb+cdsb)) * omega;
            xcggb = (cggb + here->B1GDoverlapCap + here->B1GSoverlapCap +
                    here->B1GBoverlapCap) * omega;
            xcgdb = (cgdb - here->B1GDoverlapCap ) * omega;
            xcgsb = (cgsb - here->B1GSoverlapCap) * omega;
            xcbgb = (cbgb - here->B1GBoverlapCap) * omega;
            xcbdb = (cbdb - capbd ) * omega;
            xcbsb = (cbsb - capbs ) * omega;
            m = here->B1m;
            *(here->B1GgPtr +1) += m * xcggb;
            *(here->B1BbPtr +1) += m * (-xcbgb-xcbdb-xcbsb);
            *(here->B1DPdpPtr +1) += m * xcddb;
            *(here->B1SPspPtr +1) += m * xcssb;
            *(here->B1GbPtr +1) += m * (-xcggb-xcgdb-xcgsb);
            *(here->B1GdpPtr +1) += m * xcgdb;
            *(here->B1GspPtr +1) += m * xcgsb;
            *(here->B1BgPtr +1) += m * xcbgb;
            *(here->B1BdpPtr +1) += m * xcbdb;
            *(here->B1BspPtr +1) += m * xcbsb;
            *(here->B1DPgPtr +1) += m * xcdgb;
            *(here->B1DPbPtr +1) += m * (-xcdgb-xcddb-xcdsb);
            *(here->B1DPspPtr +1) += m * xcdsb;
            *(here->B1SPgPtr +1) += m * xcsgb;
            *(here->B1SPbPtr +1) += m * (-xcsgb-xcsdb-xcssb);
            *(here->B1SPdpPtr +1) += m * xcsdb;
            *(here->B1DdPtr) += m * gdpr;
            *(here->B1SsPtr) += m * gspr;
            *(here->B1BbPtr) += m * (gbd+gbs);
            *(here->B1DPdpPtr) += m * (gdpr+gds+gbd+xrev*(gm+gmbs));
            *(here->B1SPspPtr) += m * (gspr+gds+gbs+xnrm*(gm+gmbs));
            *(here->B1DdpPtr) -= m * gdpr;
            *(here->B1SspPtr) -= m * gspr;
            *(here->B1BdpPtr) -= m * gbd;
            *(here->B1BspPtr) -= m * gbs;
            *(here->B1DPdPtr) -= m * gdpr;
            *(here->B1DPgPtr) += m * (xnrm-xrev)*gm;
            *(here->B1DPbPtr) += m * (-gbd+(xnrm-xrev)*gmbs);
            *(here->B1DPspPtr) += m * (-gds-xnrm*(gm+gmbs));
            *(here->B1SPgPtr) += m * (-(xnrm-xrev)*gm);
            *(here->B1SPsPtr) -= m * gspr;
            *(here->B1SPbPtr) += m * (-gbs-(xnrm-xrev)*gmbs);
            *(here->B1SPdpPtr) += m * (-gds-xrev*(gm+gmbs));
        }
    }
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 sBSIM1model { int B1modType; struct sBSIM1model *B1nextModel; struct sBSIM1instance { struct sBSIM1model *B1modPtr; struct sBSIM1instance *B1nextInstance; char *B1name; int B1owner; int B1states; int B1dNode; int B1gNode; int B1sNode; int B1bNode; int B1dNodePrime; int B1sNodePrime; double B1l; double B1w; double B1m; double B1drainArea; double B1sourceArea; double B1drainSquares; double B1sourceSquares; double B1drainPerimeter; double B1sourcePerimeter; double B1sourceConductance; double B1drainConductance; double B1icVBS; double B1icVDS; double B1icVGS; double B1von; double B1vdsat; int B1off; int B1mode; double B1vfb; double B1phi; double B1K1; double B1K2; double B1eta; double B1etaB; double B1etaD; double B1betaZero; double B1betaZeroB; double B1betaVdd; double B1betaVddB; double B1betaVddD; double B1ugs; double B1ugsB; double B1uds; double B1udsB; double B1udsD; double B1subthSlope; double B1subthSlopeB; double B1subthSlopeD; double B1GDoverlapCap; double B1GSoverlapCap; double B1GBoverlapCap; double B1vt0; double B1vdd; double B1temp; double B1oxideThickness; unsigned int B1channelChargePartitionFlag; unsigned int B1lGiven; unsigned int B1wGiven; unsigned int B1mGiven; unsigned int B1drainAreaGiven; unsigned int B1sourceAreaGiven; unsigned int B1drainSquaresGiven; unsigned int B1sourceSquaresGiven; unsigned int B1drainPerimeterGiven; unsigned int B1sourcePerimeterGiven; unsigned int B1dNodePrimeSet; unsigned int B1sNodePrimeSet; unsigned int B1icVBSGiven; unsigned int B1icVDSGiven; unsigned int B1icVGSGiven; unsigned int B1vonGiven; unsigned int B1vdsatGiven; double *B1DdPtr; double *B1GgPtr; double *B1SsPtr; double *B1BbPtr; double *B1DPdpPtr; double *B1SPspPtr; double *B1DdpPtr; double *B1GbPtr; double *B1GdpPtr; double *B1GspPtr; double *B1SspPtr; double *B1BdpPtr; double *B1BspPtr; double *B1DPspPtr; double *B1DPdPtr; double *B1BgPtr; double *B1DPgPtr; double *B1SPgPtr; double *B1SPsPtr; double *B1DPbPtr; double *B1SPbPtr; double *B1SPdpPtr; double B1dCoeffs[82]; double B1nVar[3][5]; } *B1instances; char *B1modName; int B1type; double B1vfb0; double B1vfbL; double B1vfbW; double B1phi0; double B1phiL; double B1phiW; double B1K10; double B1K1L; double B1K1W; double B1K20; double B1K2L; double B1K2W; double B1eta0; double B1etaL; double B1etaW; double B1etaB0; double B1etaBl; double B1etaBw; double B1etaD0; double B1etaDl; double B1etaDw; double B1deltaL; double B1deltaW; double B1mobZero; double B1mobZeroB0; double B1mobZeroBl; double B1mobZeroBw; double B1mobVdd0; double B1mobVddl; double B1mobVddw; double B1mobVddB0; double B1mobVddBl; double B1mobVddBw; double B1mobVddD0; double B1mobVddDl; double B1mobVddDw; double B1ugs0; double B1ugsL; double B1ugsW; double B1ugsB0; double B1ugsBL; double B1ugsBW; double B1uds0; double B1udsL; double B1udsW; double B1udsB0; double B1udsBL; double B1udsBW; double B1udsD0; double B1udsDL; double B1udsDW; double B1subthSlope0; double B1subthSlopeL; double B1subthSlopeW; double B1subthSlopeB0; double B1subthSlopeBL; double B1subthSlopeBW; double B1subthSlopeD0; double B1subthSlopeDL; double B1subthSlopeDW; double B1oxideThickness; double B1Cox; double B1temp; double B1vdd; double B1gateSourceOverlapCap; double B1gateDrainOverlapCap; double B1gateBulkOverlapCap; double B1channelChargePartitionFlag; double B1sheetResistance; double B1jctSatCurDensity; double B1bulkJctPotential; double B1bulkJctBotGradingCoeff; double B1bulkJctSideGradingCoeff; double B1sidewallJctPotential; double B1unitAreaJctCap; double B1unitLengthSidewallJctCap; double B1defaultWidth; double B1deltaLength; double B1fNcoef; double B1fNexp; unsigned int B1vfb0Given; unsigned int B1vfbLGiven; unsigned int B1vfbWGiven; unsigned int B1phi0Given; unsigned int B1phiLGiven; unsigned int B1phiWGiven; unsigned int B1K10Given; unsigned int B1K1LGiven; unsigned int B1K1WGiven; unsigned int B1K20Given; unsigned int B1K2LGiven; unsigned int B1K2WGiven; unsigned int B1eta0Given; unsigned int B1etaLGiven; unsigned int B1etaWGiven; unsigned int B1etaB0Given; unsigned int B1etaBlGiven; unsigned int B1etaBwGiven; unsigned int B1etaD0Given; unsigned int B1etaDlGiven; unsigned int B1etaDwGiven; unsigned int B1deltaLGiven; unsigned int B1deltaWGiven; unsigned int B1mobZeroGiven; unsigned int B1mobZeroB0Given; unsigned int B1mobZeroBlGiven; unsigned int B1mobZeroBwGiven; unsigned int B1mobVdd0Given; unsigned int B1mobVddlGiven; unsigned int B1mobVddwGiven; unsigned int B1mobVddB0Given; unsigned int B1mobVddBlGiven; unsigned int B1mobVddBwGiven; unsigned int B1mobVddD0Given; unsigned int B1mobVddDlGiven; unsigned int B1mobVddDwGiven; unsigned int B1ugs0Given; unsigned int B1ugsLGiven; unsigned int B1ugsWGiven; unsigned int B1ugsB0Given; unsigned int B1ugsBLGiven; unsigned int B1ugsBWGiven; unsigned int B1uds0Given; unsigned int B1udsLGiven; unsigned int B1udsWGiven; unsigned int B1udsB0Given; unsigned int B1udsBLGiven; unsigned int B1udsBWGiven; unsigned int B1udsD0Given; unsigned int B1udsDLGiven; unsigned int B1udsDWGiven; unsigned int B1subthSlope0Given; unsigned int B1subthSlopeLGiven; unsigned int B1subthSlopeWGiven; unsigned int B1subthSlopeB0Given; unsigned int B1subthSlopeBLGiven; unsigned int B1subthSlopeBWGiven; unsigned int B1subthSlopeD0Given; unsigned int B1subthSlopeDLGiven; unsigned int B1subthSlopeDWGiven; unsigned int B1oxideThicknessGiven; unsigned int B1tempGiven; unsigned int B1vddGiven; unsigned int B1gateSourceOverlapCapGiven; unsigned int B1gateDrainOverlapCapGiven; unsigned int B1gateBulkOverlapCapGiven; unsigned int B1channelChargePartitionFlagGiven; unsigned int B1sheetResistanceGiven; unsigned int B1jctSatCurDensityGiven; unsigned int B1bulkJctPotentialGiven; unsigned int B1bulkJctBotGradingCoeffGiven; unsigned int B1sidewallJctPotentialGiven; unsigned int B1bulkJctSideGradingCoeffGiven; unsigned int B1unitAreaJctCapGiven; unsigned int B1unitLengthSidewallJctCapGiven; unsigned int B1defaultWidthGiven; unsigned int B1deltaLengthGiven; unsigned int B1fNcoefGiven; unsigned int B1fNexpGiven; unsigned int B1typeGiven; } *

variable_types: struct sBSIM1instance { struct sBSIM1model { int B1modType; struct sBSIM1model *B1nextModel; struct sBSIM1instance *B1instances; char *B1modName; int B1type; double B1vfb0; double B1vfbL; double B1vfbW; double B1phi0; double B1phiL; double B1phiW; double B1K10; double B1K1L; double B1K1W; double B1K20; double B1K2L; double B1K2W; double B1eta0; double B1etaL; double B1etaW; double B1etaB0; double B1etaBl; double B1etaBw; double B1etaD0; double B1etaDl; double B1etaDw; double B1deltaL; double B1deltaW; double B1mobZero; double B1mobZeroB0; double B1mobZeroBl; double B1mobZeroBw; double B1mobVdd0; double B1mobVddl; double B1mobVddw; double B1mobVddB0; double B1mobVddBl; double B1mobVddBw; double B1mobVddD0; double B1mobVddDl; double B1mobVddDw; double B1ugs0; double B1ugsL; double B1ugsW; double B1ugsB0; double B1ugsBL; double B1ugsBW; double B1uds0; double B1udsL; double B1udsW; double B1udsB0; double B1udsBL; double B1udsBW; double B1udsD0; double B1udsDL; double B1udsDW; double B1subthSlope0; double B1subthSlopeL; double B1subthSlopeW; double B1subthSlopeB0; double B1subthSlopeBL; double B1subthSlopeBW; double B1subthSlopeD0; double B1subthSlopeDL; double B1subthSlopeDW; double B1oxideThickness; double B1Cox; double B1temp; double B1vdd; double B1gateSourceOverlapCap; double B1gateDrainOverlapCap; double B1gateBulkOverlapCap; double B1channelChargePartitionFlag; double B1sheetResistance; double B1jctSatCurDensity; double B1bulkJctPotential; double B1bulkJctBotGradingCoeff; double B1bulkJctSideGradingCoeff; double B1sidewallJctPotential; double B1unitAreaJctCap; double B1unitLengthSidewallJctCap; double B1defaultWidth; double B1deltaLength; double B1fNcoef; double B1fNexp; unsigned int B1vfb0Given; unsigned int B1vfbLGiven; unsigned int B1vfbWGiven; unsigned int B1phi0Given; unsigned int B1phiLGiven; unsigned int B1phiWGiven; unsigned int B1K10Given; unsigned int B1K1LGiven; unsigned int B1K1WGiven; unsigned int B1K20Given; unsigned int B1K2LGiven; unsigned int B1K2WGiven; unsigned int B1eta0Given; unsigned int B1etaLGiven; unsigned int B1etaWGiven; unsigned int B1etaB0Given; unsigned int B1etaBlGiven; unsigned int B1etaBwGiven; unsigned int B1etaD0Given; unsigned int B1etaDlGiven; unsigned int B1etaDwGiven; unsigned int B1deltaLGiven; unsigned int B1deltaWGiven; unsigned int B1mobZeroGiven; unsigned int B1mobZeroB0Given; unsigned int B1mobZeroBlGiven; unsigned int B1mobZeroBwGiven; unsigned int B1mobVdd0Given; unsigned int B1mobVddlGiven; unsigned int B1mobVddwGiven; unsigned int B1mobVddB0Given; unsigned int B1mobVddBlGiven; unsigned int B1mobVddBwGiven; unsigned int B1mobVddD0Given; unsigned int B1mobVddDlGiven; unsigned int B1mobVddDwGiven; unsigned int B1ugs0Given; unsigned int B1ugsLGiven; unsigned int B1ugsWGiven; unsigned int B1ugsB0Given; unsigned int B1ugsBLGiven; unsigned int B1ugsBWGiven; unsigned int B1uds0Given; unsigned int B1udsLGiven; unsigned int B1udsWGiven; unsigned int B1udsB0Given; unsigned int B1udsBLGiven; unsigned int B1udsBWGiven; unsigned int B1udsD0Given; unsigned int B1udsDLGiven; unsigned int B1udsDWGiven; unsigned int B1subthSlope0Given; unsigned int B1subthSlopeLGiven; unsigned int B1subthSlopeWGiven; unsigned int B1subthSlopeB0Given; unsigned int B1subthSlopeBLGiven; unsigned int B1subthSlopeBWGiven; unsigned int B1subthSlopeD0Given; unsigned int B1subthSlopeDLGiven; unsigned int B1subthSlopeDWGiven; unsigned int B1oxideThicknessGiven; unsigned int B1tempGiven; unsigned int B1vddGiven; unsigned int B1gateSourceOverlapCapGiven; unsigned int B1gateDrainOverlapCapGiven; unsigned int B1gateBulkOverlapCapGiven; unsigned int B1channelChargePartitionFlagGiven; unsigned int B1sheetResistanceGiven; unsigned int B1jctSatCurDensityGiven; unsigned int B1bulkJctPotentialGiven; unsigned int B1bulkJctBotGradingCoeffGiven; unsigned int B1sidewallJctPotentialGiven; unsigned int B1bulkJctSideGradingCoeffGiven; unsigned int B1unitAreaJctCapGiven; unsigned int B1unitLengthSidewallJctCapGiven; unsigned int B1defaultWidthGiven; unsigned int B1deltaLengthGiven; unsigned int B1fNcoefGiven; unsigned int B1fNexpGiven; unsigned int B1typeGiven; } *B1modPtr; struct sBSIM1instance *B1nextInstance; char *B1name; int B1owner; int B1states; int B1dNode; int B1gNode; int B1sNode; int B1bNode; int B1dNodePrime; int B1sNodePrime; double B1l; double B1w; double B1m; double B1drainArea; double B1sourceArea; double B1drainSquares; double B1sourceSquares; double B1drainPerimeter; double B1sourcePerimeter; double B1sourceConductance; double B1drainConductance; double B1icVBS; double B1icVDS; double B1icVGS; double B1von; double B1vdsat; int B1off; int B1mode; double B1vfb; double B1phi; double B1K1; double B1K2; double B1eta; double B1etaB; double B1etaD; double B1betaZero; double B1betaZeroB; double B1betaVdd; double B1betaVddB; double B1betaVddD; double B1ugs; double B1ugsB; double B1uds; double B1udsB; double B1udsD; double B1subthSlope; double B1subthSlopeB; double B1subthSlopeD; double B1GDoverlapCap; double B1GSoverlapCap; double B1GBoverlapCap; double B1vt0; double B1vdd; double B1temp; double B1oxideThickness; unsigned int B1channelChargePartitionFlag; unsigned int B1lGiven; unsigned int B1wGiven; unsigned int B1mGiven; unsigned int B1drainAreaGiven; unsigned int B1sourceAreaGiven; unsigned int B1drainSquaresGiven; unsigned int B1sourceSquaresGiven; unsigned int B1drainPerimeterGiven; unsigned int B1sourcePerimeterGiven; unsigned int B1dNodePrimeSet; unsigned int B1sNodePrimeSet; unsigned int B1icVBSGiven; unsigned int B1icVDSGiven; unsigned int B1icVGSGiven; unsigned int B1vonGiven; unsigned int B1vdsatGiven; double *B1DdPtr; double *B1GgPtr; double *B1SsPtr; double *B1BbPtr; double *B1DPdpPtr; double *B1SPspPtr; double *B1DdpPtr; double *B1GbPtr; double *B1GdpPtr; double *B1GspPtr; double *B1SspPtr; double *B1BdpPtr; double *B1BspPtr; double *B1DPspPtr; double *B1DPdPtr; double *B1BgPtr; double *B1DPgPtr; double *B1SPgPtr; double *B1SPsPtr; double *B1DPbPtr; double *B1SPbPtr; double *B1SPdpPtr; double B1dCoeffs[82]; double B1nVar[3][5]; } *

variable_types: xnrm int

variable_types: xrev int

variable_types: gdpr double

variable_types: gspr double

variable_types: gm double

variable_types: gds double

variable_types: gmbs double

variable_types: gbd double

variable_types: gbs double

variable_types: capbd double

variable_types: capbs double

variable_types: xcggb double

variable_types: xcgdb double

variable_types: xcgsb double

variable_types: xcbgb double

variable_types: xcbdb double

variable_types: xcbsb double

variable_types: xcddb double

variable_types: xcssb double

variable_types: xcdgb double

variable_types: xcsgb double

variable_types: xcdsb double

variable_types: xcsdb double

variable_types: cggb double

variable_types: cgdb double

variable_types: cgsb double

variable_types: cbgb double

variable_types: cbdb double

variable_types: cbsb double

variable_types: cddb double

variable_types: cdgb double

variable_types: cdsb double

variable_types: omega double

variable_types: m double

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


TRAtrunc

original_code:
int
TRAtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
{
    TRAmodel *model = (TRAmodel *)inModel;
    TRAinstance *here;
    double v1,v2,v3,v4;
    double v5,v6,d1,d2,d3,d4;
    double tmp;
    for( ; model != ((void *)0); model = model->TRAnextModel ) {
        for (here = model->TRAinstances; here != ((void *)0) ;
                here=here->TRAnextInstance) {
     if (here->TRAowner != ARCHme) continue;
            v1 = ( *(ckt->CKTrhsOld + here->TRAposNode2)
                - *(ckt->CKTrhsOld + here->TRAnegNode2))
                + *(ckt->CKTrhsOld + here->TRAbrEq2) *
                    here->TRAimped;
            v2 = *(here->TRAdelays+1+3*(here->TRAsizeDelay));
            v3 = *(here->TRAdelays+1+3*(here->TRAsizeDelay-1));
            v4 = ( *(ckt->CKTrhsOld + here->TRAposNode1)
                - *(ckt->CKTrhsOld + here->TRAnegNode1))
                + *(ckt->CKTrhsOld + here->TRAbrEq1) *
                    here->TRAimped;
            v5 = *(here->TRAdelays+2+3*(here->TRAsizeDelay));
            v6 = *(here->TRAdelays+2+3*(here->TRAsizeDelay-1));
            d1 = (v1-v2)/ckt->CKTdeltaOld[1];
            d2 = (v2-v3)/ckt->CKTdeltaOld[2];
            d3 = (v4-v5)/ckt->CKTdeltaOld[1];
            d4 = (v5-v6)/ckt->CKTdeltaOld[2];
            if( (fabs(d1-d2) >= here->TRAreltol*((fabs(d1)) > (fabs(d2)) ? (fabs(d1)) : (fabs(d2)))+
                    here->TRAabstol) ||
                    (fabs(d3-d4) >= here->TRAreltol*((fabs(d3)) > (fabs(d4)) ? (fabs(d3)) : (fabs(d4)))+
                    here->TRAabstol) ) {
                tmp = *(here->TRAdelays+3*here->TRAsizeDelay) + here->TRAtd;
                tmp -= ckt->CKTtime;
                *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
            }
        }
    }
    return(0);
}

canonical_original_code:
int TRAtrunc(struct sGENmodel *inModel, struct CKTcircuit *ckt, double *timeStep)
{
    struct sTRAmodel *model = (TRAmodel *)inModel;
    struct sTRAinstance *here;
    double v1; double v2; double v3; double v4;
    double v5; double v6; double d1; double d2; double d3; double d4;
    double tmp;
    for( ; model != ((void *)0); model = model->TRAnextModel ) {
        for (here = model->TRAinstances; here != ((void *)0) ;
                here=here->TRAnextInstance) {
     if (here->TRAowner != ARCHme) continue;
            v1 = ( *(ckt->CKTrhsOld + here->TRAposNode2)
                - *(ckt->CKTrhsOld + here->TRAnegNode2))
                + *(ckt->CKTrhsOld + here->TRAbrEq2) *
                    here->TRAimped;
            v2 = *(here->TRAdelays+1+3*(here->TRAsizeDelay));
            v3 = *(here->TRAdelays+1+3*(here->TRAsizeDelay-1));
            v4 = ( *(ckt->CKTrhsOld + here->TRAposNode1)
                - *(ckt->CKTrhsOld + here->TRAnegNode1))
                + *(ckt->CKTrhsOld + here->TRAbrEq1) *
                    here->TRAimped;
            v5 = *(here->TRAdelays+2+3*(here->TRAsizeDelay));
            v6 = *(here->TRAdelays+2+3*(here->TRAsizeDelay-1));
            d1 = (v1-v2)/ckt->CKTdeltaOld[1];
            d2 = (v2-v3)/ckt->CKTdeltaOld[2];
            d3 = (v4-v5)/ckt->CKTdeltaOld[1];
            d4 = (v5-v6)/ckt->CKTdeltaOld[2];
            if( (fabs(d1-d2) >= here->TRAreltol*((fabs(d1)) > (fabs(d2)) ? (fabs(d1)) : (fabs(d2)))+
                    here->TRAabstol) ||
                    (fabs(d3-d4) >= here->TRAreltol*((fabs(d3)) > (fabs(d4)) ? (fabs(d3)) : (fabs(d4)))+
                    here->TRAabstol) ) {
                tmp = *(here->TRAdelays+3*here->TRAsizeDelay) + here->TRAtd;
                tmp -= ckt->CKTtime;
                *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
            }
        }
    }
    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:
timeStep
double *

variable_types: struct sTRAmodel { int TRAmodType; struct sTRAmodel *TRAnextModel; struct sTRAinstance { struct sTRAmodel *TRAmodPtr; struct sTRAinstance *TRAnextInstance; char *TRAname; int TRAowner; int TRAstate; int TRAposNode1; int TRAnegNode1; int TRAposNode2; int TRAnegNode2; int TRAintNode1; int TRAintNode2; double TRAimped; double TRAconduct; double TRAtd; double TRAnl; double TRAf; double TRAinput1; double TRAinput2; double TRAinitVolt1; double TRAinitCur1; double TRAinitVolt2; double TRAinitCur2; double TRAreltol; double TRAabstol; double *TRAdelays; int TRAsizeDelay; int TRAallocDelay; int TRAbrEq1; int TRAbrEq2; double *TRAibr1Ibr2Ptr; double *TRAibr1Int1Ptr; double *TRAibr1Neg1Ptr; double *TRAibr1Neg2Ptr; double *TRAibr1Pos2Ptr; double *TRAibr2Ibr1Ptr; double *TRAibr2Int2Ptr; double *TRAibr2Neg1Ptr; double *TRAibr2Neg2Ptr; double *TRAibr2Pos1Ptr; double *TRAint1Ibr1Ptr; double *TRAint1Int1Ptr; double *TRAint1Pos1Ptr; double *TRAint2Ibr2Ptr; double *TRAint2Int2Ptr; double *TRAint2Pos2Ptr; double *TRAneg1Ibr1Ptr; double *TRAneg2Ibr2Ptr; double *TRApos1Int1Ptr; double *TRApos1Pos1Ptr; double *TRApos2Int2Ptr; double *TRApos2Pos2Ptr; unsigned int TRAimpedGiven; unsigned int TRAtdGiven; unsigned int TRAnlGiven; unsigned int TRAfGiven; unsigned int TRAicV1Given; unsigned int TRAicC1Given; unsigned int TRAicV2Given; unsigned int TRAicC2Given; unsigned int TRAreltolGiven; unsigned int TRAabstolGiven; } *TRAinstances; char *TRAmodName; } *

variable_types: struct sTRAinstance { struct sTRAmodel { int TRAmodType; struct sTRAmodel *TRAnextModel; struct sTRAinstance *TRAinstances; char *TRAmodName; } *TRAmodPtr; struct sTRAinstance *TRAnextInstance; char *TRAname; int TRAowner; int TRAstate; int TRAposNode1; int TRAnegNode1; int TRAposNode2; int TRAnegNode2; int TRAintNode1; int TRAintNode2; double TRAimped; double TRAconduct; double TRAtd; double TRAnl; double TRAf; double TRAinput1; double TRAinput2; double TRAinitVolt1; double TRAinitCur1; double TRAinitVolt2; double TRAinitCur2; double TRAreltol; double TRAabstol; double *TRAdelays; int TRAsizeDelay; int TRAallocDelay; int TRAbrEq1; int TRAbrEq2; double *TRAibr1Ibr2Ptr; double *TRAibr1Int1Ptr; double *TRAibr1Neg1Ptr; double *TRAibr1Neg2Ptr; double *TRAibr1Pos2Ptr; double *TRAibr2Ibr1Ptr; double *TRAibr2Int2Ptr; double *TRAibr2Neg1Ptr; double *TRAibr2Neg2Ptr; double *TRAibr2Pos1Ptr; double *TRAint1Ibr1Ptr; double *TRAint1Int1Ptr; double *TRAint1Pos1Ptr; double *TRAint2Ibr2Ptr; double *TRAint2Int2Ptr; double *TRAint2Pos2Ptr; double *TRAneg1Ibr1Ptr; double *TRAneg2Ibr2Ptr; double *TRApos1Int1Ptr; double *TRApos1Pos1Ptr; double *TRApos2Int2Ptr; double *TRApos2Pos2Ptr; unsigned int TRAimpedGiven; unsigned int TRAtdGiven; unsigned int TRAnlGiven; unsigned int TRAfGiven; unsigned int TRAicV1Given; unsigned int TRAicC1Given; unsigned int TRAicV2Given; unsigned int TRAicC2Given; unsigned int TRAreltolGiven; unsigned int TRAabstolGiven; } *

variable_types: tmp double