decompiled_code:
__int64 ReaderTest_application()
{
int v0; // ebx

v0 = level;
if ( level > 0 )
{
do
{
putchar(32);
--v0;
}
while ( v0 );
}
puts("application");
return 1LL;
}

canonical_decompiled_code:
__int64 func19()
{
int v0; // ebx

v0 = level;
if ( level > 0 )
{
do
{
putchar(32);
--v0;
}
while ( v0 );
}
puts("application");
return 1LL;
}

original_code: void *ReaderTest_application(Dirt_Reader *reader, void *function, void *parameters) { do { int i; for (i = level; i > 0; i--) printf(" "); } while(0); printf("application\n"); return (void*)1; }

canonical_original_code: void *ReaderTest_application(struct Dirt_ReaderT *reader, void *function, void *parameters) { do { int i; for (i = level; i > 0; i--) printf(" "); } while(0); printf("application\n"); return (void *)1; }

variable_types:
function
void *

variable_types:
parameters
void *


main

canonical_name: main

repo: redhog/Dirt

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__int64 v4[4]; // [rsp+0h] [rbp-68h] BYREF
char v5[72]; // [rsp+20h] [rbp-48h] BYREF

v3 = open("ReaderTest.data", 0, envp);
if ( v3 >= 0 )
{
if ( !(unsigned __int8)Dirt_FileBuffer_init(v5, &Dirt_DebugSession, (unsigned int)v3) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize FileBuffer");
exit(1);
}
if ( !(unsigned __int8)Dirt_StandardReader_init(v4, &callbacks, v5) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize Reader");
printf("Unable to initialize Reader");
exit(1);
}
if ( (*(__int64 (__fastcall **)(__int64 *, _QWORD))(v4[0] + 64))(v4, 0LL) )
exit(0);
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"I/O error",
"Unable to read data");
exit(1);
}
perror("Unable to open file");
exit(1);
}

original_code:
int main(int argc, char **argv)
 {
  Dirt_FdBuffer fdbuffer;
  Dirt_Buffer *buffer = (Dirt_Buffer *) &fdbuffer;
  Dirt_Reader reader;
  int fd;
  if ((fd = open("ReaderTest.data", 00)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FileBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FileBuffer");
    exit(1);
   }
  if (!Dirt_StandardReader_init(&reader, &callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Reader");
    printf("Unable to initialize Reader");
    exit(1);
   }
  if (!reader.type->read(&reader, 0))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to read data");
    exit(1);
   }
  exit(0);
 }

canonical_original_code:
int main(int argc, char **argv)
 {
  struct Dirt_FdBufferT fdbuffer;
  struct Dirt_BufferT *buffer = (Dirt_Buffer *) &fdbuffer;
  struct Dirt_ReaderT reader;
  int fd;
  if ((fd = open("ReaderTest.data", 00)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FileBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FileBuffer");
    exit(1);
   }
  if (!Dirt_StandardReader_init(&reader, &callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Reader");
    printf("Unable to initialize Reader");
    exit(1);
   }
  if (!reader.type->read(&reader, 0))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to read data");
    exit(1);
   }
  exit(0);
 }

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Dirt_FdBufferT { struct Dirt_BufferT { struct Dirt_BufferTypeT { struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; void (*free)(struct Dirt_BufferT *buffer); char (*advance)(struct Dirt_BufferT *buffer, unsigned long nr); char (*cut)(struct Dirt_BufferT *buffer, char *dst, unsigned long nr); char (*contains)(struct Dirt_BufferT *buffer, char *buf, unsigned long len, unsigned long at); long (*read)(struct Dirt_BufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_BufferT *buffer, unsigned long nr); } *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long len; unsigned long size; unsigned long maxsize; } buffer; int fd; }

variable_types: struct Dirt_ReaderT { struct Dirt_ReaderType { long (*readStr_readUnicodeescape)(struct Dirt_ReaderT *reader, long *pos, char *dst); long (*readStr_read)(struct Dirt_ReaderT *reader, char *start, char startlen, char *dst); void *(*readStr)(struct Dirt_ReaderT *reader, char unicode); void *(*readNum)(struct Dirt_ReaderT *reader); long (*readIdentifier_read)(struct Dirt_ReaderT *reader, char *dst); void *(*readIdentifier)(struct Dirt_ReaderT *reader); void *(*readIdentifiers)(struct Dirt_ReaderT *reader); void *(*readUnicodeOrId)(struct Dirt_ReaderT *reader); void *(*read)(struct Dirt_ReaderT *reader, char inParens); } *type; struct Dirt_Reader_Callbacks { void (*free)(struct Dirt_ReaderT *reader, void *item); void *(*str)(struct Dirt_ReaderT *reader, char *str, unsigned long len); void *(*unicodeStr)(struct Dirt_ReaderT *reader, char *str, unsigned long len); void *(*identifier)(struct Dirt_ReaderT *reader, char *identifier, unsigned long len); void *(*num_float)(struct Dirt_ReaderT *reader, float real); void *(*num_int)(struct Dirt_ReaderT *reader, int integer); void *(*num_long)(struct Dirt_ReaderT *reader, long integer); void *(*none)(struct Dirt_ReaderT *reader); void *(*false)(struct Dirt_ReaderT *reader); void *(*true)(struct Dirt_ReaderT *reader); void *(*structure)(struct Dirt_ReaderT *reader); void *(*structure_add)(struct Dirt_ReaderT *reader, void *structure, void *item); void *(*structure_finalize_tuple)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_list)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_dictionary)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_type)(struct Dirt_ReaderT *reader, void *structure); void *(*keyvalue)(struct Dirt_ReaderT *reader, void *key, void *value); void *(*parameter)(struct Dirt_ReaderT *reader, void *name, void *value); void *(*member)(struct Dirt_ReaderT *reader, void *name, void *value); void *(*application)(struct Dirt_ReaderT *reader, void *function, void *parameters); } *callback; struct Dirt_BufferT { struct Dirt_BufferTypeT { struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; void (*free)(struct Dirt_BufferT *buffer); char (*advance)(struct Dirt_BufferT *buffer, unsigned long nr); char (*cut)(struct Dirt_BufferT *buffer, char *dst, unsigned long nr); char (*contains)(struct Dirt_BufferT *buffer, char *buf, unsigned long len, unsigned long at); long (*read)(struct Dirt_BufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_BufferT *buffer, unsigned long nr); } *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long len; unsigned long size; unsigned long maxsize; } *buffer; }

variable_types: fd int

return_type: int

user_defined_types: struct Dirt_FdBufferT { struct Dirt_BufferT buffer; int fd; }

user_defined_types: struct Dirt_ReaderT { struct Dirt_ReaderType *type; struct Dirt_Reader_Callbacks *callback; struct Dirt_BufferT *buffer; }

user_defined_types: struct Dirt_BufferT { struct Dirt_BufferTypeT *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long len; unsigned long size; unsigned long maxsize; }

user_defined_types: struct Dirt_BufferTypeT { struct Dirt_SessionT *session; void (*free)(struct Dirt_BufferT *buffer); char (*advance)(struct Dirt_BufferT *buffer, unsigned long nr); char (*cut)(struct Dirt_BufferT *buffer, char *dst, unsigned long nr); char (*contains)(struct Dirt_BufferT *buffer, char *buf, unsigned long len, unsigned long at); long (*read)(struct Dirt_BufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_BufferT *buffer, unsigned long nr); }

user_defined_types: struct Dirt_SessionT { struct Dirt_SessionTypeT *type; }


decompiled_code:
__int64 __fastcall WriterTest_write(__int64 a1)
{
listlen *= 2;
return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 32LL))(a1);
}

original_code: char WriterTest_write(Dirt_Writer *writer, void *any) { listlen *= 2; return writer->type->num_int(writer, listlen); }

canonical_original_code: char WriterTest_write(struct Dirt_WriterT *writer, void *any) { listlen *= 2; return writer->type->num_int(writer, listlen); }

variable_types: struct Dirt_WriterT { struct Dirt_WriterType { char (*str)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*unicodeStr)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*identifier)(struct Dirt_WriterT *writer, char *identifier, unsigned long len); char (*num_float)(struct Dirt_WriterT *writer, float real); char (*num_int)(struct Dirt_WriterT *writer, int integer); char (*num_long)(struct Dirt_WriterT *writer, long integer); char (*none)(struct Dirt_WriterT *writer); char (*false)(struct Dirt_WriterT *writer); char (*true)(struct Dirt_WriterT *writer); char (*structure_tuple)(struct Dirt_WriterT *writer, void *structure); char (*structure_list)(struct Dirt_WriterT *writer, void *structure); char (*structure_dictionary)(struct Dirt_WriterT *writer, void *structure); char (*structure_type)(struct Dirt_WriterT *writer, void *structure); char (*keyvalue)(struct Dirt_WriterT *writer, void *keyvalue); char (*parameter)(struct Dirt_WriterT *writer, void *keyvalue); char (*member)(struct Dirt_WriterT *writer, void *keyvalue); char (*application)(struct Dirt_WriterT *writer, void *keyvalue); } *type; struct Dirt_Writer_Callbacks { char (*write)(struct Dirt_WriterT *writer, void *any); void *(*structure_open)(struct Dirt_WriterT *writer, void *structure); char (*structure_end)(struct Dirt_WriterT *writer, void *iter); void *(*structure_next)(struct Dirt_WriterT *writer, void *iter); void (*structure_close)(struct Dirt_WriterT *writer, void *iter); void *(*keyvalue_key)(struct Dirt_WriterT *writer, void *keyvalue); void *(*keyvalue_value)(struct Dirt_WriterT *writer, void *keyvalue); } *callback; struct Dirt_WriteBufferT { struct Dirt_WriteBufferTypeT { void (*free)(struct Dirt_WriteBufferT *WriteBuffer); void (*release)(struct Dirt_WriteBufferT *WriteBuffer); void (*lock)(struct Dirt_WriteBufferT *WriteBuffer); char (*write)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); char (*adjust)(struct Dirt_WriteBufferT *buffer); char (*advance)(struct Dirt_WriteBufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); } *type; struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; char *buf; long pos; unsigned long wpos; unsigned long size; unsigned long maxsize; } *buffer; } *

variable_types:
any
void *

return_type: char

user_defined_types: struct Dirt_WriterT { struct Dirt_WriterType *type; struct Dirt_Writer_Callbacks *callback; struct Dirt_WriteBufferT *buffer; }

user_defined_types: struct Dirt_WriteBufferT { struct Dirt_WriteBufferTypeT *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long wpos; unsigned long size; unsigned long maxsize; }


decompiled_code:
__int64 WriterTest_structure_open()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code: void *WriterTest_structure_open(Dirt_Writer *writer, void *structure) { return (void *) 1; }

canonical_original_code: void *WriterTest_structure_open(struct Dirt_WriterT *writer, void *structure) { return (void *) 1; }

variable_types:
structure
void *

return_type: void *

user_defined_types: struct Dirt_WriterType { char (*str)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*unicodeStr)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*identifier)(struct Dirt_WriterT *writer, char *identifier, unsigned long len); char (*num_float)(struct Dirt_WriterT *writer, float real); char (*num_int)(struct Dirt_WriterT *writer, int integer); char (*num_long)(struct Dirt_WriterT *writer, long integer); char (*none)(struct Dirt_WriterT *writer); char (*false)(struct Dirt_WriterT *writer); char (*true)(struct Dirt_WriterT *writer); char (*structure_tuple)(struct Dirt_WriterT *writer, void *structure); char (*structure_list)(struct Dirt_WriterT *writer, void *structure); char (*structure_dictionary)(struct Dirt_WriterT *writer, void *structure); char (*structure_type)(struct Dirt_WriterT *writer, void *structure); char (*keyvalue)(struct Dirt_WriterT *writer, void *keyvalue); char (*parameter)(struct Dirt_WriterT *writer, void *keyvalue); char (*member)(struct Dirt_WriterT *writer, void *keyvalue); char (*application)(struct Dirt_WriterT *writer, void *keyvalue); }

user_defined_types: struct Dirt_Writer_Callbacks { char (*write)(struct Dirt_WriterT *writer, void *any); void *(*structure_open)(struct Dirt_WriterT *writer, void *structure); char (*structure_end)(struct Dirt_WriterT *writer, void *iter); void *(*structure_next)(struct Dirt_WriterT *writer, void *iter); void (*structure_close)(struct Dirt_WriterT *writer, void *iter); void *(*keyvalue_key)(struct Dirt_WriterT *writer, void *keyvalue); void *(*keyvalue_value)(struct Dirt_WriterT *writer, void *keyvalue); }

user_defined_types: struct Dirt_WriteBufferTypeT { void (*free)(struct Dirt_WriteBufferT *WriteBuffer); void (*release)(struct Dirt_WriteBufferT *WriteBuffer); void (*lock)(struct Dirt_WriteBufferT *WriteBuffer); char (*write)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); char (*adjust)(struct Dirt_WriteBufferT *buffer); char (*advance)(struct Dirt_WriteBufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); }

user_defined_types: struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); }


decompiled_code:
bool WriterTest_structure_end()
{
return listlen > 9999;
}

canonical_decompiled_code:
bool func2()
{
return listlen > 9999;
}

original_code: char WriterTest_structure_end(Dirt_Writer *writer, void *iter) { return listlen >= 10000; }

canonical_original_code: char WriterTest_structure_end(struct Dirt_WriterT *writer, void *iter) { return listlen >= 10000; }

variable_types:
iter
void *


decompiled_code:
__int64 WriterTest_structure_next()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 1LL;
}

original_code: void *WriterTest_structure_next(Dirt_Writer *writer, void *iter) { return (void *) 1; }

canonical_original_code: void *WriterTest_structure_next(struct Dirt_WriterT *writer, void *iter) { return (void *) 1; }


decompiled_code:
void WriterTest_structure_close()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code: void WriterTest_structure_close(Dirt_Writer *writer, void *iter) { }

canonical_original_code: void WriterTest_structure_close(struct Dirt_WriterT *writer, void *iter) { }

return_type: void


decompiled_code:
__int64 WriterTest_keyvalue_key()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 0LL;
}

original_code: void *WriterTest_keyvalue_key(Dirt_Writer *writer, void *keyvalue) { return 0; }

canonical_original_code: void *WriterTest_keyvalue_key(struct Dirt_WriterT *writer, void *keyvalue) { return 0; }

variable_types:
keyvalue
void *


decompiled_code:
__int64 WriterTest_keyvalue_value()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 0LL;
}

original_code: void *WriterTest_keyvalue_value(Dirt_Writer *writer, void *keyvalue) { return 0; }

canonical_original_code: void *WriterTest_keyvalue_value(struct Dirt_WriterT *writer, void *keyvalue) { return 0; }


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__int64 v4[4]; // [rsp+0h] [rbp-68h] BYREF
__int64 v5[9]; // [rsp+20h] [rbp-48h] BYREF

v3 = open("WriterTest.output", 65, 384LL);
if ( v3 >= 0 )
{
if ( !(unsigned __int8)Dirt_FdWriteBuffer_init(v5, &Dirt_DebugSession, (unsigned int)v3) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize FdWriteBuffer");
exit(1);
}
if ( !(unsigned __int8)Dirt_StandardWriter_init(v4, callbacks, v5) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize Writer");
printf("Unable to initialize Writer");
exit(1);
}
if ( !(*(unsigned __int8 (__fastcall **)(__int64 *, _QWORD))(v4[0] + 80))(v4, 0LL) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"I/O error",
"Unable to write data");
exit(1);
}
(*(void (__fastcall **)(__int64 *))v5[0])(v5);
exit(0);
}
perror("Unable to open file");
exit(1);
}

original_code:
int main(int argc, char **argv)
 {
  Dirt_FdWriteBuffer fdbuffer;
  Dirt_WriteBuffer *buffer = (Dirt_WriteBuffer *) &fdbuffer;
  Dirt_Writer writer;
  int fd;
  if ((fd = open("WriterTest.output", 01 | 0100, 0400 | 0200)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FdWriteBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FdWriteBuffer");
    exit(1);
   }
  if (!Dirt_StandardWriter_init(&writer, &callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Writer");
    printf("Unable to initialize Writer");
    exit(1);
   }
  if (!writer.type->structure_list(&writer, ((void *)0)))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to write data");
    exit(1);
   }
  buffer->type->free(buffer);
  exit(0);
 }

canonical_original_code:
int main(int argc, char **argv)
 {
  struct Dirt_FdWriteBufferT fdbuffer;
  struct Dirt_WriteBufferT *buffer = (Dirt_WriteBuffer *) &fdbuffer;
  struct Dirt_WriterT writer;
  int fd;
  if ((fd = open("WriterTest.output", 01 | 0100, 0400 | 0200)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FdWriteBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FdWriteBuffer");
    exit(1);
   }
  if (!Dirt_StandardWriter_init(&writer, &callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Writer");
    printf("Unable to initialize Writer");
    exit(1);
   }
  if (!writer.type->structure_list(&writer, ((void *)0)))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to write data");
    exit(1);
   }
  buffer->type->free(buffer);
  exit(0);
 }

variable_types: struct Dirt_FdWriteBufferT { struct Dirt_WriteBufferT { struct Dirt_WriteBufferTypeT { void (*free)(struct Dirt_WriteBufferT *WriteBuffer); void (*release)(struct Dirt_WriteBufferT *WriteBuffer); void (*lock)(struct Dirt_WriteBufferT *WriteBuffer); char (*write)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); char (*adjust)(struct Dirt_WriteBufferT *buffer); char (*advance)(struct Dirt_WriteBufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); } *type; struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; char *buf; long pos; unsigned long wpos; unsigned long size; unsigned long maxsize; } buffer; int fd; }

variable_types: struct Dirt_WriterT { struct Dirt_WriterType { char (*str)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*unicodeStr)(struct Dirt_WriterT *writer, char *str, unsigned long len); char (*identifier)(struct Dirt_WriterT *writer, char *identifier, unsigned long len); char (*num_float)(struct Dirt_WriterT *writer, float real); char (*num_int)(struct Dirt_WriterT *writer, int integer); char (*num_long)(struct Dirt_WriterT *writer, long integer); char (*none)(struct Dirt_WriterT *writer); char (*false)(struct Dirt_WriterT *writer); char (*true)(struct Dirt_WriterT *writer); char (*structure_tuple)(struct Dirt_WriterT *writer, void *structure); char (*structure_list)(struct Dirt_WriterT *writer, void *structure); char (*structure_dictionary)(struct Dirt_WriterT *writer, void *structure); char (*structure_type)(struct Dirt_WriterT *writer, void *structure); char (*keyvalue)(struct Dirt_WriterT *writer, void *keyvalue); char (*parameter)(struct Dirt_WriterT *writer, void *keyvalue); char (*member)(struct Dirt_WriterT *writer, void *keyvalue); char (*application)(struct Dirt_WriterT *writer, void *keyvalue); } *type; struct Dirt_Writer_Callbacks { char (*write)(struct Dirt_WriterT *writer, void *any); void *(*structure_open)(struct Dirt_WriterT *writer, void *structure); char (*structure_end)(struct Dirt_WriterT *writer, void *iter); void *(*structure_next)(struct Dirt_WriterT *writer, void *iter); void (*structure_close)(struct Dirt_WriterT *writer, void *iter); void *(*keyvalue_key)(struct Dirt_WriterT *writer, void *keyvalue); void *(*keyvalue_value)(struct Dirt_WriterT *writer, void *keyvalue); } *callback; struct Dirt_WriteBufferT { struct Dirt_WriteBufferTypeT { void (*free)(struct Dirt_WriteBufferT *WriteBuffer); void (*release)(struct Dirt_WriteBufferT *WriteBuffer); void (*lock)(struct Dirt_WriteBufferT *WriteBuffer); char (*write)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); char (*adjust)(struct Dirt_WriteBufferT *buffer); char (*advance)(struct Dirt_WriteBufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_WriteBufferT *WriteBuffer, unsigned long nr); } *type; struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; char *buf; long pos; unsigned long wpos; unsigned long size; unsigned long maxsize; } *buffer; }

user_defined_types: struct Dirt_FdWriteBufferT { struct Dirt_WriteBufferT buffer; int fd; }


printStruct

decompiled_code:
int __fastcall printStruct(__int64 a1)
{
void *v1; // rax
__int64 v2; // rax
unsigned __int64 v3; // rbp
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rbp
unsigned __int64 v6; // rbp
unsigned __int64 v7; // rbp
unsigned __int64 v8; // rbp

v1 = *(void **)a1;
if ( *(_UNKNOWN **)a1 == &Dirt_StructType_Str )
{
LODWORD(v1) = printf("'''%*s'''", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_UnicodeStr )
{
LODWORD(v1) = printf("u'''%*s'''", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Identifier )
{
LODWORD(v1) = printf("%*s", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Float )
{
LODWORD(v1) = printf("%f", *(float *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Long )
{
LODWORD(v1) = printf("%li", *(_QWORD *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Int )
{
LODWORD(v1) = printf("%i", *(unsigned int *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_None )
{
LODWORD(v1) = printf("None");
return (int)v1;
}
if ( v1 == &Dirt_StructType_False )
{
LODWORD(v1) = printf("False");
return (int)v1;
}
if ( v1 == &Dirt_StructType_True )
{
LODWORD(v1) = printf("True");
return (int)v1;
}
if ( v1 == &Dirt_StructType_Structure )
{
printf("Structure(");
if ( *(_QWORD *)(a1 + 24) )
{
v4 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v4));
if ( *(_QWORD *)(a1 + 24) - 1LL > v4 )
printf(", ");
++v4;
}
while ( *(_QWORD *)(a1 + 24) > v4 );
}
goto LABEL_67;
}
if ( v1 == &Dirt_StructType_Structure_Tuple )
{
putchar(40);
if ( *(_QWORD *)(a1 + 24) )
{
v5 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v5));
if ( *(_QWORD *)(a1 + 24) - 1LL > v5 )
printf(", ");
++v5;
}
while ( *(_QWORD *)(a1 + 24) > v5 );
}
LABEL_67:
LODWORD(v1) = putchar(41);
return (int)v1;
}
if ( v1 == &Dirt_StructType_Structure_List )
{
putchar(91);
if ( *(_QWORD *)(a1 + 24) )
{
v6 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v6));
if ( *(_QWORD *)(a1 + 24) - 1LL > v6 )
printf(", ");
++v6;
}
while ( *(_QWORD *)(a1 + 24) > v6 );
}
LODWORD(v1) = putchar(93);
}
else if ( v1 == &Dirt_StructType_Structure_Dictionary )
{
putchar(123);
if ( *(_QWORD *)(a1 + 24) )
{
v7 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v7));
if ( *(_QWORD *)(a1 + 24) - 1LL > v7 )
printf(", ");
++v7;
}
while ( *(_QWORD *)(a1 + 24) > v7 );
}
LODWORD(v1) = putchar(125);
}
else if ( v1 == &Dirt_StructType_Structure_Type )
{
putchar(60);
if ( *(_QWORD *)(a1 + 24) )
{
v8 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v8));
if ( *(_QWORD *)(a1 + 24) - 1LL > v8 )
printf(", ");
++v8;
}
while ( *(_QWORD *)(a1 + 24) > v8 );
}
LODWORD(v1) = putchar(62);
}
else if ( v1 == &Dirt_StructType_Keyvalue )
{
printStruct(*(_QWORD *)(a1 + 16));
putchar(58);
LODWORD(v1) = printStruct(*(_QWORD *)(a1 + 24));
}
else if ( v1 == &Dirt_StructType_Parameter )
{
printStruct(*(_QWORD *)(a1 + 16));
putchar(61);
LODWORD(v1) = printStruct(*(_QWORD *)(a1 + 24));
}
else
{
if ( v1 != &Dirt_StructType_Member )
{
if ( v1 != &Dirt_StructType_Application )
return (int)v1;
printStruct(*(_QWORD *)(a1 + 16));
putchar(40);
v2 = *(_QWORD *)(a1 + 24);
if ( *(_QWORD *)(v2 + 24) )
{
v3 = 0LL;
do
{
printStruct(*(_QWORD *)(*(_QWORD *)(v2 + 16) + 8 * v3));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 24) + 24LL) - 1LL > v3 )
printf(", ");
++v3;
v2 = *(_QWORD *)(a1 + 24);
}
while ( *(_QWORD *)(v2 + 24) > v3 );
}
goto LABEL_67;
}
printStruct(*(_QWORD *)(a1 + 16));
putchar(46);
LODWORD(v1) = printStruct(*(_QWORD *)(a1 + 24));
}
return (int)v1;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
void *v1; // rax
__int64 v2; // rax
unsigned __int64 v3; // rbp
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rbp
unsigned __int64 v6; // rbp
unsigned __int64 v7; // rbp
unsigned __int64 v8; // rbp

v1 = *(void **)a1;
if ( *(_UNKNOWN **)a1 == &Dirt_StructType_Str )
{
LODWORD(v1) = printf("'''%*s'''", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_UnicodeStr )
{
LODWORD(v1) = printf("u'''%*s'''", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Identifier )
{
LODWORD(v1) = printf("%*s", *(_QWORD *)(a1 + 24), *(const char **)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Float )
{
LODWORD(v1) = printf("%f", *(float *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Long )
{
LODWORD(v1) = printf("%li", *(_QWORD *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_Num_Int )
{
LODWORD(v1) = printf("%i", *(unsigned int *)(a1 + 16));
return (int)v1;
}
if ( v1 == &Dirt_StructType_None )
{
LODWORD(v1) = printf("None");
return (int)v1;
}
if ( v1 == &Dirt_StructType_False )
{
LODWORD(v1) = printf("False");
return (int)v1;
}
if ( v1 == &Dirt_StructType_True )
{
LODWORD(v1) = printf("True");
return (int)v1;
}
if ( v1 == &Dirt_StructType_Structure )
{
printf("Structure(");
if ( *(_QWORD *)(a1 + 24) )
{
v4 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v4));
if ( *(_QWORD *)(a1 + 24) - 1LL > v4 )
printf(", ");
++v4;
}
while ( *(_QWORD *)(a1 + 24) > v4 );
}
goto LABEL_67;
}
if ( v1 == &Dirt_StructType_Structure_Tuple )
{
putchar(40);
if ( *(_QWORD *)(a1 + 24) )
{
v5 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v5));
if ( *(_QWORD *)(a1 + 24) - 1LL > v5 )
printf(", ");
++v5;
}
while ( *(_QWORD *)(a1 + 24) > v5 );
}
LABEL_67:
LODWORD(v1) = putchar(41);
return (int)v1;
}
if ( v1 == &Dirt_StructType_Structure_List )
{
putchar(91);
if ( *(_QWORD *)(a1 + 24) )
{
v6 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v6));
if ( *(_QWORD *)(a1 + 24) - 1LL > v6 )
printf(", ");
++v6;
}
while ( *(_QWORD *)(a1 + 24) > v6 );
}
LODWORD(v1) = putchar(93);
}
else if ( v1 == &Dirt_StructType_Structure_Dictionary )
{
putchar(123);
if ( *(_QWORD *)(a1 + 24) )
{
v7 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v7));
if ( *(_QWORD *)(a1 + 24) - 1LL > v7 )
printf(", ");
++v7;
}
while ( *(_QWORD *)(a1 + 24) > v7 );
}
LODWORD(v1) = putchar(125);
}
else if ( v1 == &Dirt_StructType_Structure_Type )
{
putchar(60);
if ( *(_QWORD *)(a1 + 24) )
{
v8 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8 * v8));
if ( *(_QWORD *)(a1 + 24) - 1LL > v8 )
printf(", ");
++v8;
}
while ( *(_QWORD *)(a1 + 24) > v8 );
}
LODWORD(v1) = putchar(62);
}
else if ( v1 == &Dirt_StructType_Keyvalue )
{
func0(*(_QWORD *)(a1 + 16));
putchar(58);
LODWORD(v1) = func0(*(_QWORD *)(a1 + 24));
}
else if ( v1 == &Dirt_StructType_Parameter )
{
func0(*(_QWORD *)(a1 + 16));
putchar(61);
LODWORD(v1) = func0(*(_QWORD *)(a1 + 24));
}
else
{
if ( v1 != &Dirt_StructType_Member )
{
if ( v1 != &Dirt_StructType_Application )
return (int)v1;
func0(*(_QWORD *)(a1 + 16));
putchar(40);
v2 = *(_QWORD *)(a1 + 24);
if ( *(_QWORD *)(v2 + 24) )
{
v3 = 0LL;
do
{
func0(*(_QWORD *)(*(_QWORD *)(v2 + 16) + 8 * v3));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 24) + 24LL) - 1LL > v3 )
printf(", ");
++v3;
v2 = *(_QWORD *)(a1 + 24);
}
while ( *(_QWORD *)(v2 + 24) > v3 );
}
goto LABEL_67;
}
func0(*(_QWORD *)(a1 + 16));
putchar(46);
LODWORD(v1) = func0(*(_QWORD *)(a1 + 24));
}
return (int)v1;
}

original_code:
void printStruct(Dirt_Struct *strct)
 {
  size_t pos;
  if (strct->type == &Dirt_StructType_Str) printf("'''%*s'''", ((Dirt_StringStruct *) strct)->len, ((Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_UnicodeStr) printf("u'''%*s'''", ((Dirt_StringStruct *) strct)->len, ((Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_Identifier) printf("%*s", ((Dirt_StringStruct *) strct)->len, ((Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_Num_Float) printf("%f", ((Dirt_FloatStruct *) strct)->num_float);
  else if (strct->type == &Dirt_StructType_Num_Long) printf("%li", ((Dirt_LongStruct *) strct)->num_long);
  else if (strct->type == &Dirt_StructType_Num_Int) printf("%i", ((Dirt_IntStruct *) strct)->num_int);
  else if (strct->type == &Dirt_StructType_None) printf("None");
  else if (strct->type == &Dirt_StructType_False) printf("False");
  else if (strct->type == &Dirt_StructType_True) printf("True");
  else if (strct->type == &Dirt_StructType_Structure)
   {
    printf("Structure(");
    for (pos = 0; pos < ((Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(")");
   }
  else if (strct->type == &Dirt_StructType_Structure_Tuple)
   {
    printf("(");
    for (pos = 0; pos < ((Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(")");
   }
  else if (strct->type == &Dirt_StructType_Structure_List)
   {
    printf("[");
    for (pos = 0; pos < ((Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf("]");
   }
  else if (strct->type == &Dirt_StructType_Structure_Dictionary)
   {
    printf("{");
    for (pos = 0; pos < ((Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf("}");
   }
  else if (strct->type == &Dirt_StructType_Structure_Type)
   {
    printf("<");
    for (pos = 0; pos < ((Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(">");
   }
  else if (strct->type == &Dirt_StructType_Keyvalue)
   {
    printStruct(((Dirt_KeyvalueStruct *) strct)->key);
    printf(":");
    printStruct(((Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Parameter)
   {
    printStruct(((Dirt_KeyvalueStruct *) strct)->key);
    printf("=");
    printStruct(((Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Member)
   {
    printStruct(((Dirt_KeyvalueStruct *) strct)->key);
    printf(".");
    printStruct(((Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Application)
   {
    printStruct(((Dirt_KeyvalueStruct *) strct)->key);
    printf("(");
    for (pos = 0; pos < ((Dirt_StructureStruct*) ((Dirt_KeyvalueStruct *) strct)->value)->len; pos++)
     {
      printStruct(((Dirt_StructureStruct*) ((Dirt_KeyvalueStruct *) strct)->value)->items[pos]);
      if (pos < ((Dirt_StructureStruct*) ((Dirt_KeyvalueStruct *) strct)->value)->len - 1)
       printf(", ");
     }
    printf(")");
  }
 }

canonical_original_code:
void printStruct(struct Dirt_StructT *strct)
 {
  unsigned long pos;
  if (strct->type == &Dirt_StructType_Str) printf("'''%*s'''", ((struct Dirt_StringStruct *) strct)->len, ((struct Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_UnicodeStr) printf("u'''%*s'''", ((struct Dirt_StringStruct *) strct)->len, ((struct Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_Identifier) printf("%*s", ((struct Dirt_StringStruct *) strct)->len, ((struct Dirt_StringStruct *) strct)->str);
  else if (strct->type == &Dirt_StructType_Num_Float) printf("%f", ((struct Dirt_FloatStruct *) strct)->num_float);
  else if (strct->type == &Dirt_StructType_Num_Long) printf("%li", ((struct Dirt_LongStruct *) strct)->num_long);
  else if (strct->type == &Dirt_StructType_Num_Int) printf("%i", ((struct Dirt_IntStruct *) strct)->num_int);
  else if (strct->type == &Dirt_StructType_None) printf("None");
  else if (strct->type == &Dirt_StructType_False) printf("False");
  else if (strct->type == &Dirt_StructType_True) printf("True");
  else if (strct->type == &Dirt_StructType_Structure)
   {
    printf("Structure(");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(")");
   }
  else if (strct->type == &Dirt_StructType_Structure_Tuple)
   {
    printf("(");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(")");
   }
  else if (strct->type == &Dirt_StructType_Structure_List)
   {
    printf("[");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf("]");
   }
  else if (strct->type == &Dirt_StructType_Structure_Dictionary)
   {
    printf("{");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf("}");
   }
  else if (strct->type == &Dirt_StructType_Structure_Type)
   {
    printf("<");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) strct)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) strct)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) strct)->len - 1)
       printf(", ");
     }
    printf(">");
   }
  else if (strct->type == &Dirt_StructType_Keyvalue)
   {
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->key);
    printf(":");
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Parameter)
   {
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->key);
    printf("=");
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Member)
   {
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->key);
    printf(".");
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->value);
   }
  else if (strct->type == &Dirt_StructType_Application)
   {
    printStruct(((struct Dirt_KeyvalueStruct *) strct)->key);
    printf("(");
    for (pos = 0; pos < ((struct Dirt_StructureStruct *) ((struct Dirt_KeyvalueStruct *) strct)->value)->len; pos++)
     {
      printStruct(((struct Dirt_StructureStruct *) ((struct Dirt_KeyvalueStruct *) strct)->value)->items[pos]);
      if (pos < ((struct Dirt_StructureStruct *) ((struct Dirt_KeyvalueStruct *) strct)->value)->len - 1)
       printf(", ");
     }
    printf(")");
  }
 }

variable_types: struct Dirt_StructT { struct Dirt_StructType { unsigned long size; void (*decref)(struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session, struct Dirt_StructT *item); struct Dirt_StructT *(*incref)(struct Dirt_SessionT *session, struct Dirt_StructT *item); void (*free)(struct Dirt_SessionT *session, struct Dirt_StructT *item); struct Dirt_StructT *(*contract)(struct Dirt_SessionT *session, struct Dirt_StructT *item); } *type; int references; } *

variable_types:
pos
unsigned long

user_defined_types: struct Dirt_StructT { struct Dirt_StructType *type; int references; }

user_defined_types: struct Dirt_StringStruct { struct Dirt_StructT base; char *str; unsigned long len; }

user_defined_types: struct Dirt_FloatStruct { struct Dirt_StructT base; float num_float; }

user_defined_types: struct Dirt_LongStruct { struct Dirt_StructT base; long num_long; }

user_defined_types: struct Dirt_IntStruct { struct Dirt_StructT base; int num_int; }

user_defined_types: struct Dirt_StructureStruct { struct Dirt_StructT base; struct Dirt_StructT **items; unsigned long len; }

user_defined_types: struct Dirt_KeyvalueStruct { struct Dirt_StructT base; struct Dirt_StructT *key; struct Dirt_StructT *value; }

user_defined_types: struct Dirt_StructType { unsigned long size; void (*decref)(struct Dirt_SessionT *session, struct Dirt_StructT *item); struct Dirt_StructT *(*incref)(struct Dirt_SessionT *session, struct Dirt_StructT *item); void (*free)(struct Dirt_SessionT *session, struct Dirt_StructT *item); struct Dirt_StructT *(*contract)(struct Dirt_SessionT *session, struct Dirt_StructT *item); }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6[4]; // [rsp+0h] [rbp-68h] BYREF
char v7[72]; // [rsp+20h] [rbp-48h] BYREF

v3 = open("ReaderTest.data", 0, envp);
if ( v3 >= 0 )
{
if ( !(unsigned __int8)Dirt_FileBuffer_init(v7, &Dirt_DebugSession, (unsigned int)v3) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize FileBuffer");
exit(1);
}
if ( !(unsigned __int8)Dirt_StandardReader_init(v6, &Dirt_StructReader_Callbacks, v7) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize Reader");
printf("Unable to initialize Reader");
exit(1);
}
v4 = (*(__int64 (__fastcall **)(__int64 *, _QWORD))(v6[0] + 64))(v6, 0LL);
v5 = v4;
if ( v4 )
{
printStruct(v4);
putchar(10);
(*(void (__fastcall **)(__int64 *, __int64))(*(_QWORD *)v5 + 8LL))(&Dirt_DebugSession, v5);
exit(0);
}
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"I/O error",
"Unable to read data");
exit(1);
}
perror("Unable to open file");
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6[4]; // [rsp+0h] [rbp-68h] BYREF
char v7[72]; // [rsp+20h] [rbp-48h] BYREF

v3 = open("ReaderTest.data", 0, envp);
if ( v3 >= 0 )
{
if ( !(unsigned __int8)Dirt_FileBuffer_init(v7, &Dirt_DebugSession, (unsigned int)v3) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize FileBuffer");
exit(1);
}
if ( !(unsigned __int8)Dirt_StandardReader_init(v6, &Dirt_StructReader_Callbacks, v7) )
{
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"Init",
"Unable to initialize Reader");
printf("Unable to initialize Reader");
exit(1);
}
v4 = (*(__int64 (__fastcall **)(__int64 *, _QWORD))(v6[0] + 64))(v6, 0LL);
v5 = v4;
if ( v4 )
{
func0(v4);
putchar(10);
(*(void (__fastcall **)(__int64 *, __int64))(*(_QWORD *)v5 + 8LL))(&Dirt_DebugSession, v5);
exit(0);
}
(*(void (__fastcall **)(__int64 *, const char *, const char *))Dirt_DebugSession)(
&Dirt_DebugSession,
"I/O error",
"Unable to read data");
exit(1);
}
perror("Unable to open file");
exit(1);
}

original_code:
int main(int argc, char **argv)
 {
  Dirt_Struct *strct;
  Dirt_FdBuffer fdbuffer;
  Dirt_Buffer *buffer = (Dirt_Buffer *) &fdbuffer;
  Dirt_Reader reader;
  int fd;
  if ((fd = open("ReaderTest.data", 00)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FileBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FileBuffer");
    exit(1);
   }
  if (!Dirt_StandardReader_init(&reader, &Dirt_StructReader_Callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Reader");
    printf("Unable to initialize Reader");
    exit(1);
   }
  if (!(strct = (Dirt_Struct *) reader.type->read(&reader, 0)))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to read data");
    exit(1);
   }
  printStruct(strct);
  printf("\n");
  strct->type->decref(&Dirt_DebugSession, strct);
  exit(0);
 }

canonical_original_code:
int main(int argc, char **argv)
 {
  struct Dirt_StructT *strct;
  struct Dirt_FdBufferT fdbuffer;
  struct Dirt_BufferT *buffer = (Dirt_Buffer *) &fdbuffer;
  struct Dirt_ReaderT reader;
  int fd;
  if ((fd = open("ReaderTest.data", 00)) < 0)
   {
    perror("Unable to open file");
    exit(1);
   }
  if (!Dirt_FileBuffer_init(&fdbuffer, &Dirt_DebugSession, fd))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize FileBuffer");
    exit(1);
   }
  if (!Dirt_StandardReader_init(&reader, &Dirt_StructReader_Callbacks, buffer))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "Init", "Unable to initialize Reader");
    printf("Unable to initialize Reader");
    exit(1);
   }
  if (!(strct = (struct Dirt_StructT *) reader.type->read(&reader, 0)))
   {
    Dirt_DebugSession.type->error(&Dirt_DebugSession, "I/O error", "Unable to read data");
    exit(1);
   }
  printStruct(strct);
  printf("\n");
  strct->type->decref(&Dirt_DebugSession, strct);
  exit(0);
 }

variable_types: struct Dirt_BufferT { struct Dirt_BufferTypeT { struct Dirt_SessionT { struct Dirt_SessionTypeT { void (*error)(struct Dirt_SessionT *session, char *class, char *error); unsigned long (*unicodeLookupName)(struct Dirt_SessionT *session, char *name, char *dst); unsigned long (*unicodeLookupOrdinal)(struct Dirt_SessionT *session, int ordinal, char *dst); } *type; } *session; void (*free)(struct Dirt_BufferT *buffer); char (*advance)(struct Dirt_BufferT *buffer, unsigned long nr); char (*cut)(struct Dirt_BufferT *buffer, char *dst, unsigned long nr); char (*contains)(struct Dirt_BufferT *buffer, char *buf, unsigned long len, unsigned long at); long (*read)(struct Dirt_BufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_BufferT *buffer, unsigned long nr); } *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long len; unsigned long size; unsigned long maxsize; } *

user_defined_types: struct Dirt_FdBufferT { struct Dirt_BufferT buffer; int fd; }

user_defined_types: struct Dirt_ReaderT { struct Dirt_ReaderType *type; struct Dirt_Reader_Callbacks *callback; struct Dirt_BufferT *buffer; }

user_defined_types: struct Dirt_BufferT { struct Dirt_BufferTypeT *type; struct Dirt_SessionT *session; char *buf; long pos; unsigned long len; unsigned long size; unsigned long maxsize; }

user_defined_types: struct Dirt_ReaderType { long (*readStr_readUnicodeescape)(struct Dirt_ReaderT *reader, long *pos, char *dst); long (*readStr_read)(struct Dirt_ReaderT *reader, char *start, char startlen, char *dst); void *(*readStr)(struct Dirt_ReaderT *reader, char unicode); void *(*readNum)(struct Dirt_ReaderT *reader); long (*readIdentifier_read)(struct Dirt_ReaderT *reader, char *dst); void *(*readIdentifier)(struct Dirt_ReaderT *reader); void *(*readIdentifiers)(struct Dirt_ReaderT *reader); void *(*readUnicodeOrId)(struct Dirt_ReaderT *reader); void *(*read)(struct Dirt_ReaderT *reader, char inParens); }

user_defined_types: struct Dirt_Reader_Callbacks { void (*free)(struct Dirt_ReaderT *reader, void *item); void *(*str)(struct Dirt_ReaderT *reader, char *str, unsigned long len); void *(*unicodeStr)(struct Dirt_ReaderT *reader, char *str, unsigned long len); void *(*identifier)(struct Dirt_ReaderT *reader, char *identifier, unsigned long len); void *(*num_float)(struct Dirt_ReaderT *reader, float real); void *(*num_int)(struct Dirt_ReaderT *reader, int integer); void *(*num_long)(struct Dirt_ReaderT *reader, long integer); void *(*none)(struct Dirt_ReaderT *reader); void *(*false)(struct Dirt_ReaderT *reader); void *(*true)(struct Dirt_ReaderT *reader); void *(*structure)(struct Dirt_ReaderT *reader); void *(*structure_add)(struct Dirt_ReaderT *reader, void *structure, void *item); void *(*structure_finalize_tuple)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_list)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_dictionary)(struct Dirt_ReaderT *reader, void *structure); void *(*structure_finalize_type)(struct Dirt_ReaderT *reader, void *structure); void *(*keyvalue)(struct Dirt_ReaderT *reader, void *key, void *value); void *(*parameter)(struct Dirt_ReaderT *reader, void *name, void *value); void *(*member)(struct Dirt_ReaderT *reader, void *name, void *value); void *(*application)(struct Dirt_ReaderT *reader, void *function, void *parameters); }

user_defined_types: struct Dirt_BufferTypeT { struct Dirt_SessionT *session; void (*free)(struct Dirt_BufferT *buffer); char (*advance)(struct Dirt_BufferT *buffer, unsigned long nr); char (*cut)(struct Dirt_BufferT *buffer, char *dst, unsigned long nr); char (*contains)(struct Dirt_BufferT *buffer, char *buf, unsigned long len, unsigned long at); long (*read)(struct Dirt_BufferT *buffer, unsigned long nr); char (*extend)(struct Dirt_BufferT *buffer, unsigned long nr); }


assertBuffer

decompiled_code:
int __fastcall assertBuffer(_QWORD *a1, const char *a2)
{
size_t v2; // rax
size_t v3; // r12
const char *v4; // rbx

v2 = strlen(a2);
v3 = a1[4];
if ( v3 >= v2 )
{
v4 = (const char *)(a1[2] + a1[3]);
LODWORD(v2) = strncmp(v4, a2, v2);
if ( (_DWORD)v2 )
{
printf("Bad buffer contents '%.*s' (should have been '%s')\n", v3, v4, a2);
exit(1);
}
}
return v2;
}

canonical_decompiled_code:
int __fastcall func0(_QWORD *a1, const char *a2)
{
size_t v2; // rax
size_t v3; // r12
const char *v4; // rbx

v2 = strlen(a2);
v3 = a1[4];
if ( v3 >= v2 )
{
v4 = (const char *)(a1[2] + a1[3]);
LODWORD(v2) = strncmp(v4, a2, v2);
if ( (_DWORD)v2 )
{
printf("Bad buffer contents '%.*s' (should have been '%s')\n", v3, v4, a2);
exit(1);
}
}
return v2;
}

original_code:
void assertBuffer(Dirt_Buffer *buffer, char *string)
 {
  size_t stringlen = strlen(string);
  if (stringlen <= buffer->len && (strncmp(buffer->buf + buffer->pos, string, stringlen) != 0))
   {
    printf("Bad buffer contents '%.*s' (should have been '%s')\n", buffer->len, buffer->buf + buffer->pos, string);
    exit(1);
   }
 }

canonical_original_code:
void assertBuffer(struct Dirt_BufferT *buffer, char *string)
 {
  unsigned long stringlen = strlen(string);
  if (stringlen <= buffer->len && (strncmp(buffer->buf + buffer->pos, string, stringlen) != 0))
   {
    printf("Bad buffer contents '%.*s' (should have been '%s')\n", buffer->len, buffer->buf + buffer->pos, string);
    exit(1);
   }
 }

variable_types:
string
char *

variable_types:
stringlen
unsigned long

user_defined_types: struct Dirt_SessionT { struct Dirt_SessionTypeT *type; }


repo: redivo/tcc

decompiled_code:
__int64 __fastcall cfg_set_fault_injection_enable(unsigned int a1, int a2)
{
if ( a1 > 1 )
return 4294967294LL;
LOBYTE(Cfg[11 * a1 + 1]) = a2 != 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2)
{
if ( a1 > 1 )
return 4294967294LL;
LOBYTE(Cfg[11 * a1 + 1]) = a2 != 0;
return 0LL;
}

original_code:
int cfg_set_fault_injection_enable(int index, int enable)
{
 if (!(index >= 0 && index < 2))
  return -2;
 Cfg.i2c_fi[index].enable = !!enable;
 return 0;
}

variable_types: index int

variable_types: enable int


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

if ( a1 > 1 )
return 4294967294LL;
if ( a2 < 0 )
return 4294967294LL;
result = hw_set_i2c_address(a1 + 1, (unsigned __int8)a2);
if ( (int)result >= 0 )
{
BYTE1(Cfg[11 * a1 + 1]) = a2;
result = 0LL;
}
return result;
}

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

if ( a1 > 1 )
return 4294967294LL;
if ( a2 < 0 )
return 4294967294LL;
result = hw_set_i2c_address(a1 + 1, (unsigned __int8)a2);
if ( (int)result >= 0 )
{
BYTE1(Cfg[11 * a1 + 1]) = a2;
result = 0LL;
}
return result;
}

original_code:
int cfg_set_fault_injection_dev_address(int index, unsigned char address)
{
 if (!(index >= 0 && index < 2))
  return -2;
 if (!((address >> 7) == 0))
  return -2;
 do {int _ret; _ret = hw_set_i2c_address((index + 1), address); if (_ret < 0) { return _ret; }} while (0);
 Cfg.i2c_fi[index].dev_address = address;
 return 0;
}

variable_types:
address
unsigned char


decompiled_code:
__int64 __fastcall cfg_set_fault_injection_write_enable(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
HIBYTE(Cfg[11 * a1 + 1]) = a2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
HIBYTE(Cfg[11 * a1 + 1]) = a2;
return 0LL;
}

original_code:
int cfg_set_fault_injection_write_enable(int index, _Bool enable)
{
 if (!(index >= 0 && index < 2))
  return -2;
 Cfg.i2c_fi[index].general_write_enable = enable;
 return 0;
}


decompiled_code:
__int64 __fastcall cfg_set_fault_injection_read_enable(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
BYTE2(Cfg[11 * a1 + 1]) = a2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
BYTE2(Cfg[11 * a1 + 1]) = a2;
return 0LL;
}

original_code:
int cfg_set_fault_injection_read_enable(int index, _Bool enable)
{
 if (!(index >= 0 && index < 2))
  return -2;
 Cfg.i2c_fi[index].general_read_enable = enable;
 return 0;
}


decompiled_code:
__int64 __fastcall cfg_set_fi_cust_fault_reg_addr(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
LOBYTE(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
LOBYTE(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

original_code:
int cfg_set_fi_cust_fault_reg_addr(int fi, int custom_fautl_index, unsigned char address)
{
 if (!(fi >= 0 && fi < 2))
  return -2;
 if (!(custom_fautl_index >= 0 && custom_fautl_index < 5))
  return -2;
 Cfg.i2c_fi[fi].i2c_cust_fault[custom_fautl_index].reg_addr = address;
 return 0;
}

variable_types: fi int


decompiled_code:
__int64 __fastcall cfg_set_fi_cust_fault_read_enable(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
BYTE1(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
BYTE1(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

original_code:
int cfg_set_fi_cust_fault_read_enable(int fi, int custom_fautl_index, _Bool enable)
{
 if (!(fi >= 0 && fi < 2))
  return -2;
 if (!(custom_fautl_index >= 0 && custom_fautl_index < 5))
  return -2;
 Cfg.i2c_fi[fi].i2c_cust_fault[custom_fautl_index].read_enable = enable;
 return 0;
}


decompiled_code:
__int64 __fastcall cfg_set_fi_cust_fault_write_enable(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
BYTE2(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, unsigned int a2, char a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
BYTE2(Cfg[11 * a1 + 2 + 2 * a2]) = a3;
return 0LL;
}

original_code:
int cfg_set_fi_cust_fault_write_enable(int fi, int custom_fautl_index, _Bool enable)
{
 if (!(fi >= 0 && fi < 2))
  return -2;
 if (!(custom_fautl_index >= 0 && custom_fautl_index < 5))
  return -2;
 Cfg.i2c_fi[fi].i2c_cust_fault[custom_fautl_index].write_enable = enable;
 return 0;
}


decompiled_code:
__int64 __fastcall cfg_set_fi_cust_fault_forced_response(unsigned int a1, unsigned int a2, int a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
Cfg[11 * a1 + 3 + 2 * a2] = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, unsigned int a2, int a3)
{
if ( a1 > 1 )
return 4294967294LL;
if ( a2 > 4 )
return 4294967294LL;
Cfg[11 * a1 + 3 + 2 * a2] = a3;
return 0LL;
}

original_code:
int cfg_set_fi_cust_fault_forced_response(int fi, int custom_fautl_index, int response)
{
 if (!(fi >= 0 && fi < 2))
  return -2;
 if (!(custom_fautl_index >= 0 && custom_fautl_index < 5))
  return -2;
 Cfg.i2c_fi[fi].i2c_cust_fault[custom_fautl_index].forced_response = response;
 return 0;
}

variable_types: response int


decompiled_code:
__int64 hw_ctrl_pins_init()
{
__int64 result; // rax
unsigned int *v1; // rbx

result = hw_pin_set_dir((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], 1LL);
if ( (int)result >= 0 )
{
result = hw_set_value((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], 0LL);
if ( (int)result >= 0 )
{
v1 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_pin_set_dir(*v1, v1[1], 1LL);
if ( (int)result < 0 )
break;
result = hw_set_value(*v1, v1[1], 1LL);
if ( (int)result < 0 )
break;
v1 += 2;
if ( v1 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq + 24) )
return 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
unsigned int *v1; // rbx

result = hw_pin_set_dir((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], 1LL);
if ( (int)result >= 0 )
{
result = hw_set_value((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], 0LL);
if ( (int)result >= 0 )
{
v1 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_pin_set_dir(*v1, v1[1], 1LL);
if ( (int)result < 0 )
break;
result = hw_set_value(*v1, v1[1], 1LL);
if ( (int)result < 0 )
break;
v1 += 2;
if ( v1 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq + 24) )
return 0LL;
}
}
}
return result;
}

original_code:
int hw_ctrl_pins_init(void)
{
 int seq;
 do {int _ret; _ret = hw_pin_set_dir(Sfp_select.port, Sfp_select.pin, 1); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_set_value(Sfp_select.port, Sfp_select.pin, 0); if (_ret < 0) { return _ret; }} while (0);
 for (seq = 0; seq < 3; seq++) {
  do {int _ret; _ret = hw_pin_set_dir(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 1); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = hw_set_value(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 1); if (_ret < 0) { return _ret; }} while (0);
 }
 return 0;
}

canonical_original_code:
int hw_ctrl_pins_init()
{
 int seq;
 do {int _ret; _ret = hw_pin_set_dir(Sfp_select.port, Sfp_select.pin, 1); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_set_value(Sfp_select.port, Sfp_select.pin, 0); if (_ret < 0) { return _ret; }} while (0);
 for (seq = 0; seq < 3; seq++) {
  do {int _ret; _ret = hw_pin_set_dir(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 1); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = hw_set_value(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 1); if (_ret < 0) { return _ret; }} while (0);
 }
 return 0;
}

variable_types: seq int


decompiled_code:
__int64 __fastcall hw_sfp_insert(int a1)
{
__int64 result; // rax
unsigned int *v2; // rbx

result = hw_set_value((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], a1 != 0);
if ( (int)result >= 0 )
{
v2 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_set_value(*v2, v2[1], 0LL);
if ( (int)result < 0 )
break;
v2 += 2;
if ( v2 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq + 24) )
return 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
unsigned int *v2; // rbx

result = hw_set_value((unsigned int)Sfp_select[0], (unsigned int)Sfp_select[1], a1 != 0);
if ( (int)result >= 0 )
{
v2 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_set_value(*v2, v2[1], 0LL);
if ( (int)result < 0 )
break;
v2 += 2;
if ( v2 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq + 24) )
return 0LL;
}
}
return result;
}

original_code:
int hw_sfp_insert(int sfp)
{
 int seq;
 do {int _ret; _ret = hw_set_value(Sfp_select.port, Sfp_select.pin, !!sfp); if (_ret < 0) { return _ret; }} while (0);
 for (seq = 0; seq < 3; seq++) {
  do {int _ret; _ret = hw_set_value(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 0); if (_ret < 0) { return _ret; }} while (0);
 }
 return 0;
}

variable_types: sfp int


decompiled_code:
__int64 hw_sfp_remove()
{
unsigned int *v0; // rbx
__int64 result; // rax

v0 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_set_value(v0[4], v0[5], 1LL);
if ( (int)result < 0 )
break;
v0 -= 2;
if ( v0 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq - 24) )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int *v0; // rbx
__int64 result; // rax

v0 = (unsigned int *)&Sfp_disable_seq;
while ( 1 )
{
result = hw_set_value(v0[4], v0[5], 1LL);
if ( (int)result < 0 )
break;
v0 -= 2;
if ( v0 == (unsigned int *)(unsigned int)((_DWORD)&Sfp_disable_seq - 24) )
return 0LL;
}
return result;
}

original_code:
int hw_sfp_remove(int sfp)
{
 int seq;
 for (seq = 3 - 1; seq >= 0; seq--) {
  do {int _ret; _ret = hw_set_value(Sfp_disable_seq[seq].port, Sfp_disable_seq[seq].pin, 1); if (_ret < 0) { return _ret; }} while (0);
 }
 return 0;
}


decompiled_code:
__int64 __fastcall cli_fault_injection_en(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
unsigned int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_enable((unsigned int)(v2 - 1), v3);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
unsigned int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_enable((unsigned int)(v2 - 1), v3);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cli_fault_injection_en(char *line, int num_of_args)
{
 char fault_num_str[10];
 char en_value_str[10];
 int fault_num;
 int en_value;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, en_value_str, sizeof(en_value_str), 3); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 en_value = atoi(en_value_str);
 do {int _ret; _ret = cfg_set_fault_injection_enable(fault_num, en_value); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}

variable_types:
line
char *


decompiled_code:
__int64 __fastcall cli_fault_injection_dev_addr(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
unsigned __int8 v3; // al
char *endptr; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fault_injection_dev_address((unsigned int)(v2 - 1), v3);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
unsigned __int8 v3; // al
char *endptr; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fault_injection_dev_address((unsigned int)(v2 - 1), v3);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cli_fault_injection_dev_addr(char *line, int num_of_args)
{
 char fault_num_str[10];
 char dev_addr_str[10];
 int fault_num;
 int dev_addr;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, dev_addr_str, sizeof(dev_addr_str), 3); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 dev_addr = (int) strtol(dev_addr_str, (char **) &dev_addr_str, 16);
 do {int _ret; _ret = cfg_set_fault_injection_dev_address(fault_num, (unsigned char) dev_addr); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_fault_injection_gen_read_en(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_read_enable((unsigned int)(v2 - 1), v3 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_read_enable((unsigned int)(v2 - 1), v3 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cli_fault_injection_gen_read_en(char *line, int num_of_args)
{
 char fault_num_str[10];
 char en_value_str[10];
 int fault_num;
 int en_value;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, en_value_str, sizeof(en_value_str), 3); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 en_value = atoi(en_value_str);
 do {int _ret; _ret = cfg_set_fault_injection_read_enable(fault_num, en_value); if (_ret < 0) { return _ret; }} while (0);
 return 0;
 return 0;
}


decompiled_code:
__int64 __fastcall cli_fault_injection_gen_write_en(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_write_enable((unsigned int)(v2 - 1), v3 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // eax
char v4[10]; // [rsp+Ch] [rbp-1Ch] BYREF
char nptr[18]; // [rsp+16h] [rbp-12h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v4, 10LL, 3LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v4);
result = cfg_set_fault_injection_write_enable((unsigned int)(v2 - 1), v3 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cli_fault_injection_gen_write_en(char *line, int num_of_args)
{
 char fault_num_str[10];
 char en_value_str[10];
 int fault_num;
 int en_value;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, en_value_str, sizeof(en_value_str), 3); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 en_value = atoi(en_value_str);
 do {int _ret; _ret = cfg_set_fault_injection_write_enable(fault_num, en_value); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_cust_fault_reg_addr(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
unsigned __int8 v4; // al
char *endptr; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fi_cust_fault_reg_addr((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
unsigned __int8 v4; // al
char *endptr; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fi_cust_fault_reg_addr((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

original_code:
int cli_cust_fault_reg_addr(char *line, int num_of_args)
{
 char fault_num_str[10];
 char cust_fault_num_str[10];
 char reg_addr_str[10];
 int fault_num;
 int cust_fault_num;
 int reg_addr;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, cust_fault_num_str, sizeof(cust_fault_num_str), 3); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, reg_addr_str, sizeof(reg_addr_str), 4); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 cust_fault_num = atoi(cust_fault_num_str) - 1;
 reg_addr = (int) strtol(reg_addr_str, (char **) &reg_addr_str, 16);
 do {int _ret; _ret = cfg_set_fi_cust_fault_reg_addr(fault_num, cust_fault_num, reg_addr); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_cust_fault_read_en(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
int v4; // eax
char v5[10]; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v5, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = atoi(v5);
result = cfg_set_fi_cust_fault_read_enable((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
int v4; // eax
char v5[10]; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v5, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = atoi(v5);
result = cfg_set_fi_cust_fault_read_enable((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

original_code:
int cli_cust_fault_read_en(char *line, int num_of_args)
{
 char fault_num_str[10];
 char cust_fault_num_str[10];
 char en_value_str[10];
 int fault_num;
 int cust_fault_num;
 int en_value;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, cust_fault_num_str, sizeof(cust_fault_num_str), 3); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, en_value_str, sizeof(en_value_str), 4); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 cust_fault_num = atoi(cust_fault_num_str) - 1;
 en_value = !!atoi(en_value_str);
 do {int _ret; _ret = cfg_set_fi_cust_fault_read_enable(fault_num, cust_fault_num, en_value); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_cust_fault_write_en(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
int v4; // eax
char v5[10]; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v5, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = atoi(v5);
result = cfg_set_fi_cust_fault_write_enable((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 result; // rax
int v2; // ebx
int v3; // ebp
int v4; // eax
char v5[10]; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v5, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
v3 = atoi(v6);
v4 = atoi(v5);
result = cfg_set_fi_cust_fault_write_enable((unsigned int)(v2 - 1), (unsigned int)(v3 - 1), v4 != 0);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

original_code:
int cli_cust_fault_write_en(char *line, int num_of_args)
{
 char fault_num_str[10];
 char cust_fault_num_str[10];
 char en_value_str[10];
 int fault_num;
 int cust_fault_num;
 int en_value;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, cust_fault_num_str, sizeof(cust_fault_num_str), 3); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, en_value_str, sizeof(en_value_str), 4); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 cust_fault_num = atoi(cust_fault_num_str) - 1;
 en_value = !!atoi(en_value_str);
 do {int _ret; _ret = cfg_set_fi_cust_fault_write_enable(fault_num, cust_fault_num, en_value); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_cust_force_resp(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // ebx
unsigned int v3; // ebp
__int64 v4; // rdx
char *endptr; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr) - 1;
v3 = atoi(v6) - 1;
v4 = 0xFFFFFFFFLL;
if ( strcmp((const char *)&endptr, "no") )
v4 = (unsigned int)strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fi_cust_fault_forced_response(v2, v3, v4);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // ebx
unsigned int v3; // ebp
__int64 v4; // rdx
char *endptr; // [rsp+2h] [rbp-36h] BYREF
char v6[10]; // [rsp+Ch] [rbp-2Ch] BYREF
char nptr[34]; // [rsp+16h] [rbp-22h] BYREF

result = cli_get_word(a1, nptr, 10LL, 2LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, v6, 10LL, 3LL);
if ( (int)result >= 0 )
{
result = cli_get_word(a1, &endptr, 10LL, 4LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr) - 1;
v3 = atoi(v6) - 1;
v4 = 0xFFFFFFFFLL;
if ( strcmp((const char *)&endptr, "no") )
v4 = (unsigned int)strtol((const char *)&endptr, &endptr, 16);
result = cfg_set_fi_cust_fault_forced_response(v2, v3, v4);
if ( (int)result > 0 )
result = 0LL;
}
}
}
return result;
}

original_code:
int cli_cust_force_resp(char *line, int num_of_args)
{
 char fault_num_str[10];
 char cust_fault_num_str[10];
 char response_str[10];
 int fault_num;
 int cust_fault_num;
 int response;
 do {int _ret; _ret = cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, cust_fault_num_str, sizeof(cust_fault_num_str), 3); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = cli_get_word(line, response_str, sizeof(response_str), 4); if (_ret < 0) { return _ret; }} while (0);
 fault_num = atoi(fault_num_str) - 1;
 cust_fault_num = atoi(cust_fault_num_str) - 1;
 if (strcmp(response_str, "no") == 0)
  response = -1;
 else
  response = (int) strtol(response_str, (char **) &response_str, 16);
 do {int _ret; _ret = cfg_set_fi_cust_fault_forced_response(fault_num, cust_fault_num, response); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cfg_insert_sfp(unsigned int a1)
{
__int64 result; // rax

if ( a1 > 1 )
return 4294967294LL;
if ( Cfg[0] && a1 )
return 4294967290LL;
if ( Cfg[1] && a1 != 1 )
return 4294967290LL;
result = cfg_set_enable(a1, 1LL);
if ( (int)result >= 0 )
{
result = hw_enable_led(a1, 1LL);
if ( (int)result >= 0 )
{
result = hw_sfp_insert(a1);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 result; // rax

if ( a1 > 1 )
return 4294967294LL;
if ( Cfg[0] && a1 )
return 4294967290LL;
if ( Cfg[1] && a1 != 1 )
return 4294967290LL;
result = cfg_set_enable(a1, 1LL);
if ( (int)result >= 0 )
{
result = hw_enable_led(a1, 1LL);
if ( (int)result >= 0 )
{
result = hw_sfp_insert(a1);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cfg_insert_sfp(int sfp)
{
 int s;
 if (!(sfp >= 0 && sfp < 2))
  return -2;
 for (s = 0; s < 2; s++)
  if (Cfg.sfp[s].enable && s != sfp)
   return -6;
 do {int _ret; _ret = cfg_set_enable(sfp, 1); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_enable_led(sfp, 1); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_sfp_insert(sfp); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}

variable_types: s int


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

result = cfg_set_enable(a1, 0LL);
if ( (int)result >= 0 )
{
result = hw_enable_led((unsigned int)a1, 0LL);
if ( (int)result >= 0 )
{
result = hw_sfp_remove((unsigned int)a1);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

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

result = cfg_set_enable(a1, 0LL);
if ( (int)result >= 0 )
{
result = hw_enable_led((unsigned int)a1, 0LL);
if ( (int)result >= 0 )
{
result = hw_sfp_remove((unsigned int)a1);
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int cfg_remove_sfp(int sfp)
{
 do {int _ret; _ret = cfg_set_enable(sfp, 0); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_enable_led(sfp, 0); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_sfp_remove(sfp); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 cli_show_cfg()
{
cfg_show();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
cfg_show();
return 0LL;
}

original_code:
static int cli_show_cfg(char *line, int num_of_args)
{
 cfg_show();
 return 0;
}


decompiled_code:
__int64 cli_print_help()
{
char *v0; // rbx

puts("\r");
v0 = Commands;
do
{
printf(" %-25s %s\r\n", v0, v0 + 25);
v0 += 184;
}
while ( v0 != (char *)(unsigned int)((_DWORD)Commands + 2576) );
puts("\r");
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
char *v0; // rbx

puts("\r");
v0 = Commands;
do
{
printf(" %-25s %s\r\n", v0, v0 + 25);
v0 += 184;
}
while ( v0 != (char *)(unsigned int)((_DWORD)Commands + 2576) );
puts("\r");
return 0LL;
}

original_code:
static int cli_print_help(char *line, int num_of_args)
{
 int number_of_commands;
 int i;
 number_of_commands = sizeof(Commands) / sizeof(command_t);
 printf("\r\n");
 for (i = 0; i < number_of_commands; i++)
  printf(" %-25s %s\r\n", Commands[i].command, Commands[i].help);
 printf("\r\n");
 return 0;
}

variable_types: i int


decompiled_code:
__int64 cli_get_cmd()
{
int v0; // ebx
char v1; // al
char v3[120]; // [rsp+0h] [rbp-78h] BYREF

if ( !(unsigned __int8)term_init_is_done() )
return 4294967293LL;
printf("SFP-TESTER# ");
v3[0] = 0;
v0 = 0;
while ( 1 )
{
v1 = getchar();
if ( v1 == 13 )
break;
if ( v0 > 98 || v1 == 10 )
{
if ( v1 == 10 )
break;
}
else
{
v3[v0++] = v1;
v3[v0] = 0;
}
}
strcpy(Cmd_line, v3);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
char v1; // al
char v3[120]; // [rsp+0h] [rbp-78h] BYREF

if ( !(unsigned __int8)term_init_is_done() )
return 4294967293LL;
printf("SFP-TESTER# ");
v3[0] = 0;
v0 = 0;
while ( 1 )
{
v1 = getchar();
if ( v1 == 13 )
break;
if ( v0 > 98 || v1 == 10 )
{
if ( v1 == 10 )
break;
}
else
{
v3[v0++] = v1;
v3[v0] = 0;
}
}
strcpy(Cmd_line, v3);
return 0LL;
}

original_code:
int cli_get_cmd(void)
{
 int char_index = 0;
 char cmd_line[100];
 char c;
 if (!term_init_is_done())
  return -3;
 printf("SFP-TESTER# ");
 strcpy(cmd_line, "");
 do {
  c = getchar();
  if (c == 0x0D)
   break;
  if (char_index >= 100 - 1)
   continue;
  if (c != 0x0D && c!= 0x0A) {
   cmd_line[char_index] = c;
   cmd_line[char_index + 1] = '\0';
   char_index++;
  }
 } while (c != 0x0D && c!= 0x0A);
 sprintf(Cmd_line, "%s", cmd_line);
 return 0;
}

canonical_original_code:
int cli_get_cmd()
{
 int char_index = 0;
 char cmd_line[100];
 char c;
 if (!term_init_is_done())
  return -3;
 printf("SFP-TESTER# ");
 strcpy(cmd_line, "");
 do {
  c = getchar();
  if (c == 0x0D)
   break;
  if (char_index >= 100 - 1)
   continue;
  if (c != 0x0D && c!= 0x0A) {
   cmd_line[char_index] = c;
   cmd_line[char_index + 1] = '\0';
   char_index++;
  }
 } while (c != 0x0D && c!= 0x0A);
 sprintf(Cmd_line, "%s", cmd_line);
 return 0;
}

variable_types: c char


original_code:
int cli_get_word(char *input, char *word, int word_size, int order)
{
 int i;
 int j = 0;
 int found_words = 0;
 int first_char = 1;
 if (input == ((void *)0) || word == ((void *)0))
  return -2;
 sprintf(word, "");
 for (i = 0; input[i]; i++) {
  if (j >= word_size)
   break;
  if (input[i] == ' ') {
   first_char = 1;
   continue;
  }
  if (input[i] == '\0')
   break;
  if (first_char) {
   found_words++;
   first_char = 0;
  }
  if (found_words != order)
   continue;
  word[j] = input[i];
  j++;
 }
 word[j] = '\0';
 return 0;
}

variable_types:
input
char *

variable_types:
word
char *

variable_types: order int

variable_types: j int


decompiled_code:
__int64 cli_handle_cmd()
{
int v0; // er12
int v1; // ebp
unsigned int v2; // er12
char *v3; // rbx
char v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = cli_get_number_of_words(Cmd_line);
cli_get_command(Cmd_line, v5);
v1 = cli_get_number_of_words(Cmd_line);
if ( v1 )
{
v2 = v0 - 1;
v3 = Commands;
v1 = 0;
do
{
if ( !strcmp(v5, v3) && (unsigned __int8)v3[175] == v2 )
{
v1 = (*((__int64 (__fastcall **)(char *, _QWORD))v3 + 22))(Cmd_line, v2);
if ( v1 < 0 )
return (unsigned int)v1;
v1 = 1;
}
v3 += 184;
}
while ( v3 != (char *)(unsigned int)((_DWORD)Commands + 2576) );
if ( v1 )
v1 = 0;
else
puts(" Unknown command\r");
}
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 func6()
{
int v0; // er12
int v1; // ebp
unsigned int v2; // er12
char *v3; // rbx
char v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = func0(Cmd_line);
func5(Cmd_line, v5);
v1 = func0(Cmd_line);
if ( v1 )
{
v2 = v0 - 1;
v3 = Commands;
v1 = 0;
do
{
if ( !strcmp(v5, v3) && (unsigned __int8)v3[175] == v2 )
{
v1 = (*((__int64 (__fastcall **)(char *, _QWORD))v3 + 22))(Cmd_line, v2);
if ( v1 < 0 )
return (unsigned int)v1;
v1 = 1;
}
v3 += 184;
}
while ( v3 != (char *)(unsigned int)((_DWORD)Commands + 2576) );
if ( v1 )
v1 = 0;
else
puts(" Unknown command\r");
}
return (unsigned int)v1;
}

original_code:
int cli_handle_cmd(void)
{
 int number_of_commands;
 int number_of_argumments;
 char command[25];
 int found_command = 0;
 int i;
 number_of_commands = sizeof(Commands) / sizeof(command_t);
 number_of_argumments = cli_get_number_of_words(Cmd_line) - 1;
 cli_get_command(Cmd_line, command);
 if (cli_get_number_of_words(Cmd_line) == 0)
  return 0;
 for (i = 0; i < number_of_commands; i++) {
  if (strcmp(command, Commands[i].command) != 0)
   continue;
  if (number_of_argumments != Commands[i].argumment_number)
   continue;
  do {int _ret; _ret = Commands[i].callback(Cmd_line, number_of_argumments); if (_ret < 0) { return _ret; }} while (0);
  found_command = 1;
 }
 if (!found_command)
  printf(" Unknown command\r\n");
 return 0;
}

canonical_original_code:
int cli_handle_cmd()
{
 int number_of_commands;
 int number_of_argumments;
 char command[25];
 int found_command = 0;
 int i;
 number_of_commands = sizeof(Commands) / sizeof(command_t);
 number_of_argumments = cli_get_number_of_words(Cmd_line) - 1;
 cli_get_command(Cmd_line, command);
 if (cli_get_number_of_words(Cmd_line) == 0)
  return 0;
 for (i = 0; i < number_of_commands; i++) {
  if (strcmp(command, Commands[i].command) != 0)
   continue;
  if (number_of_argumments != Commands[i].argumment_number)
   continue;
  do {int _ret; _ret = Commands[i].callback(Cmd_line, number_of_argumments); if (_ret < 0) { return _ret; }} while (0);
  found_command = 1;
 }
 if (!found_command)
  printf(" Unknown command\r\n");
 return 0;
}

variable_types:
command
char [25]


decompiled_code:
void U0init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void U0init()
{
}

canonical_original_code:
void U0init()
{
}


decompiled_code:
__int64 U0getchar()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0LL;
}

original_code:
char U0getchar(void)
{
 return 0;
}

canonical_original_code:
char U0getchar()
{
 return 0;
}


decompiled_code:
void U0putchar()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void U0putchar(int c)
{
}

canonical_original_code:
void U0putchar(int c)
{
}

variable_types: c int


decompiled_code:
void U0puts()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void U0puts(char *s)
{
}

canonical_original_code:
void U0puts(char *s)
{
}

variable_types:
s
char *


decompiled_code:
__int64 U0gets()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
char *U0gets(char *txt, int nmax)
{
 return 0;
}

variable_types:
txt
char *

variable_types: nmax int

return_type: char *


decompiled_code:
__int64 term_init()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
int term_init(void)
{
 return 0;
}

canonical_original_code:
int term_init()
{
 return 0;
}


decompiled_code:
__int64 term_init_is_done()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
_Bool term_init_is_done(void)
{
 return 1;
}

canonical_original_code:
_Bool term_init_is_done()
{
 return 1;
}


decompiled_code:
__int64 term_rx_data_ready()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
_Bool term_rx_data_ready(void)
{
 return 0;
}

canonical_original_code:
_Bool term_rx_data_ready()
{
 return 0;
}


decompiled_code:
__int64 __fastcall cli_insert_sfp(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char nptr[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = cli_get_word(a1, nptr, 2LL, 2LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
result = cfg_insert_sfp((unsigned int)(v2 - 1));
if ( (int)result > 0 )
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char nptr[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = cli_get_word(a1, nptr, 2LL, 2LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
result = cfg_insert_sfp((unsigned int)(v2 - 1));
if ( (int)result > 0 )
result = 0LL;
}
return result;
}

original_code:
int cli_insert_sfp(char *line, int num_of_args)
{
 int sfp;
 char sfp_str[2];
 do {int _ret; _ret = cli_get_word(line, sfp_str, sizeof(sfp_str), 2); if (_ret < 0) { return _ret; }} while (0);
 sfp = atoi(sfp_str) - 1;
 do {int _ret; _ret = cfg_insert_sfp(sfp); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 __fastcall cli_remove_sfp(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char nptr[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = cli_get_word(a1, nptr, 2LL, 2LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
result = cfg_remove_sfp((unsigned int)(v2 - 1));
if ( (int)result > 0 )
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax
int v2; // eax
char nptr[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = cli_get_word(a1, nptr, 2LL, 2LL);
if ( (int)result >= 0 )
{
v2 = atoi(nptr);
result = cfg_remove_sfp((unsigned int)(v2 - 1));
if ( (int)result > 0 )
result = 0LL;
}
return result;
}

original_code:
int cli_remove_sfp(char *line, int num_of_args)
{
 int sfp;
 char sfp_str[2];
 do {int _ret; _ret = cli_get_word(line, sfp_str, sizeof(sfp_str), 2); if (_ret < 0) { return _ret; }} while (0);
 sfp = atoi(sfp_str) - 1;
 do {int _ret; _ret = cfg_remove_sfp(sfp); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 hw_dbg_get_reg()
{
return 4294967288LL;
}

original_code:
int hw_dbg_get_reg(_Bool write, char *dbg_str, int value)
{
  return -8;
 return 0;
}

variable_types: value int


decompiled_code:
__int64 hw_set_i2c_address()
{
return 0LL;
}

original_code:
int hw_set_i2c_address(int i2c_number, unsigned char address)
{
 return 0;
}

variable_types:
address
unsigned char


decompiled_code:
__int64 hw_get_i2c_address()
{
return 0LL;
}

original_code:
int hw_get_i2c_address(int i2c_number, unsigned char *address)
{
 return 0;
}

variable_types:
address
unsigned char *


decompiled_code:
__int64 hw_i2c_init()
{
return 0LL;
}

original_code:
int hw_i2c_init(void)
{
 return 0;
}

canonical_original_code:
int hw_i2c_init()
{
 return 0;
}


decompiled_code:
__int64 hw_init()
{
__int64 result; // rax

result = hw_leds_init();
if ( (int)result >= 0 )
{
result = hw_ctrl_pins_init();
if ( (int)result >= 0 )
{
result = hw_i2c_init();
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = hw_leds_init();
if ( (int)result >= 0 )
{
result = hw_ctrl_pins_init();
if ( (int)result >= 0 )
{
result = hw_i2c_init();
if ( (int)result > 0 )
result = 0LL;
}
}
return result;
}

original_code:
int hw_init(void)
{
 do {int _ret; _ret = hw_leds_init(); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_ctrl_pins_init(); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_i2c_init(); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}

canonical_original_code:
int hw_init()
{
 do {int _ret; _ret = hw_leds_init(); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_ctrl_pins_init(); if (_ret < 0) { return _ret; }} while (0);
 do {int _ret; _ret = hw_i2c_init(); if (_ret < 0) { return _ret; }} while (0);
 return 0;
}


decompiled_code:
__int64 hw_set_value()
{
return 0LL;
}

original_code:
int hw_set_value(int port, int pin, _Bool val)
{
 return 0;
}

variable_types: port int

variable_types: pin int


decompiled_code:
__int64 hw_pin_set_dir()
{
return 0LL;
}

original_code:
int hw_pin_set_dir(int port, int pin, int dir)
{
 return 0;
}

variable_types: dir int


decompiled_code:
__int64 __fastcall cfg_set_enable(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
Cfg[a1] = a2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, char a2)
{
if ( a1 > 1 )
return 4294967294LL;
Cfg[a1] = a2;
return 0LL;
}

original_code:
int cfg_set_enable(int sfp, _Bool enable)
{
 if (!(sfp >= 0 && sfp < 2))
  return -2;
 Cfg.sfp[sfp].enable = enable;
 return 0;
}

variable_types: sfp int


decompiled_code:
__int64 cfg_init()
{
__int64 result; // rax
unsigned int v1; // ebp
unsigned int v2; // ebx

result = cfg_set_enable(0, 0);
if ( (int)result >= 0 )
{
result = cfg_set_enable(1u, 0);
if ( (int)result >= 0 )
{
v1 = 0;
LABEL_4:
result = cfg_set_fault_injection_enable(v1, 0LL);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_dev_address(v1, v1 + 80);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_write_enable(v1, 1LL);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_read_enable(v1, 1LL);
if ( (int)result >= 0 )
{
v2 = 0;
while ( 1 )
{
result = cfg_set_fi_cust_fault_reg_addr(v1, v2, 0LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_read_enable(v1, v2, 1LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_write_enable(v1, v2, 1LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_forced_response(v1, v2, 0xFFFFFFFFLL);
if ( (int)result < 0 )
break;
if ( ++v2 == 5 )
{
if ( ++v1 != 2 )
goto LABEL_4;
return 0LL;
}
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
unsigned int v1; // ebp
unsigned int v2; // ebx

result = func0(0, 0);
if ( (int)result >= 0 )
{
result = func0(1u, 0);
if ( (int)result >= 0 )
{
v1 = 0;
LABEL_4:
result = cfg_set_fault_injection_enable(v1, 0LL);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_dev_address(v1, v1 + 80);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_write_enable(v1, 1LL);
if ( (int)result >= 0 )
{
result = cfg_set_fault_injection_read_enable(v1, 1LL);
if ( (int)result >= 0 )
{
v2 = 0;
while ( 1 )
{
result = cfg_set_fi_cust_fault_reg_addr(v1, v2, 0LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_read_enable(v1, v2, 1LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_write_enable(v1, v2, 1LL);
if ( (int)result < 0 )
break;
result = cfg_set_fi_cust_fault_forced_response(v1, v2, 0xFFFFFFFFLL);
if ( (int)result < 0 )
break;
if ( ++v2 == 5 )
{
if ( ++v1 != 2 )
goto LABEL_4;
return 0LL;
}
}
}
}
}
}
}
}
return result;
}

original_code:
int cfg_init(void)
{
 int sfp, fi;
 for (sfp = 0; sfp < 2; sfp++) {
  do {int _ret; _ret = cfg_set_enable(sfp, 0); if (_ret < 0) { return _ret; }} while (0);
 }
 for (fi = 0; fi < 2; fi++) {
  int fault;
  do {int _ret; _ret = cfg_set_fault_injection_enable(fi, 0); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_dev_address(fi, 0x50 + fi); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_write_enable(fi, 1); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_read_enable(fi, 1); if (_ret < 0) { return _ret; }} while (0);
  for (fault = 0; fault < 5; fault++) {
   do {int _ret; _ret = cfg_set_fi_cust_fault_reg_addr(fi, fault, 0); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_read_enable(fi, fault, 1); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_write_enable(fi, fault, 1); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_forced_response(fi, fault, -1); if (_ret < 0) { return _ret; }} while (0);
  }
 }
 return 0;
}

canonical_original_code:
int cfg_init()
{
 int sfp; int fi;
 for (sfp = 0; sfp < 2; sfp++) {
  do {int _ret; _ret = cfg_set_enable(sfp, 0); if (_ret < 0) { return _ret; }} while (0);
 }
 for (fi = 0; fi < 2; fi++) {
  int fault;
  do {int _ret; _ret = cfg_set_fault_injection_enable(fi, 0); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_dev_address(fi, 0x50 + fi); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_write_enable(fi, 1); if (_ret < 0) { return _ret; }} while (0);
  do {int _ret; _ret = cfg_set_fault_injection_read_enable(fi, 1); if (_ret < 0) { return _ret; }} while (0);
  for (fault = 0; fault < 5; fault++) {
   do {int _ret; _ret = cfg_set_fi_cust_fault_reg_addr(fi, fault, 0); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_read_enable(fi, fault, 1); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_write_enable(fi, fault, 1); if (_ret < 0) { return _ret; }} while (0);
   do {int _ret; _ret = cfg_set_fi_cust_fault_forced_response(fi, fault, -1); if (_ret < 0) { return _ret; }} while (0);
  }
 }
 return 0;
}

variable_types: fi int

variable_types: fault int