decompiled_code:
__int64 __fastcall SCPI_SystemErrorCountQ(__int64 a1)
{
unsigned int v1; // eax

v1 = SCPI_ErrorCount();
SCPI_ResultInt32(a1, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // eax

v1 = SCPI_ErrorCount();
SCPI_ResultInt32(a1, v1);
return 1LL;
}

original_code:
scpi_result_t SCPI_SystemErrorCountQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_ErrorCount(context));
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_SystemErrorCountQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_ErrorCount(context));
    return SCPI_RES_OK;
}

user_defined_types: enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 }


decompiled_code:
__int64 __fastcall SCPI_StatusQuestionableConditionQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 9LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 9LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusQuestionableConditionQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUESC));
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusQuestionableConditionQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUESC));
    return SCPI_RES_OK;
}

variable_types: struct _scpi_t { struct _scpi_command_t { char *pattern; enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*callback)(struct _scpi_t *); int tag; } *cmdlist; struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; } buffer; struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t { char *buffer; char *pos; int len; } lex_state; struct _scpi_const_buffer_t { unsigned long length; unsigned long position; char *data; } cmd_raw; } param_list; struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 } ctrl, unsigned short val); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*flush)(struct _scpi_t *); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*reset)(struct _scpi_t *); } *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t { short error_code; char *device_dependent_info; } *data; } error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t { char *name; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; double mult; } *units; void *user_context; struct _scpi_parser_state_t { struct _scpi_token_t { enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 } type; char *ptr; int len; } programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 } termination; } parser_state; char *idn[4]; unsigned long arbitrary_remaining; } *

user_defined_types: struct _scpi_t { struct _scpi_command_t *cmdlist; struct _scpi_buffer_t buffer; struct _scpi_param_list_t param_list; struct _scpi_interface_t *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t *units; void *user_context; struct _scpi_parser_state_t parser_state; char *idn[4]; unsigned long arbitrary_remaining; }

user_defined_types: struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t lex_state; struct _scpi_const_buffer_t cmd_raw; }

user_defined_types: struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t *data; }

user_defined_types: struct _scpi_parser_state_t { struct _scpi_token_t programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t termination; }

user_defined_types: struct _scpi_command_t { char *pattern; enum _scpi_result_t (*callback)(struct _scpi_t *); int tag; }

user_defined_types: struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t ctrl, unsigned short val); enum _scpi_result_t (*flush)(struct _scpi_t *); enum _scpi_result_t (*reset)(struct _scpi_t *); }

user_defined_types: struct _scpi_unit_def_t { char *name; enum _scpi_unit_t unit; double mult; }

user_defined_types: struct _scpi_token_t { enum _scpi_token_type_t type; char *ptr; int len; }


decompiled_code:
__int64 __fastcall SCPI_StatusQuestionableEventQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 7LL);
SCPI_ResultInt32(a1, v1);
SCPI_RegSet(a1, 7LL, 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 7LL);
SCPI_ResultInt32(a1, v1);
SCPI_RegSet(a1, 7LL, 0LL);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusQuestionableEventQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUES));
    SCPI_RegSet(context, SCPI_REG_QUES, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusQuestionableEventQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUES));
    SCPI_RegSet(context, SCPI_REG_QUES, 0);
    return SCPI_RES_OK;
}

return_type: enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 }

user_defined_types: struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; }

user_defined_types: struct _lex_state_t { char *buffer; char *pos; int len; }

user_defined_types: struct _scpi_const_buffer_t { unsigned long length; unsigned long position; char *data; }

user_defined_types: struct _scpi_error_t { short error_code; char *device_dependent_info; }

user_defined_types: enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 }

user_defined_types: enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 }

user_defined_types: enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 }


decompiled_code:
__int64 __fastcall SCPI_StatusQuestionableEnableQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 8LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 8LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusQuestionableEnableQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUESE));
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusQuestionableEnableQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_QUESE));
    return SCPI_RES_OK;
}

user_defined_types: enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 }


decompiled_code:
__int64 __fastcall SCPI_StatusQuestionableEnable(__int64 a1)
{
unsigned __int16 v2[6]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned __int8)SCPI_ParamInt32(a1, v2, 1LL) )
SCPI_RegSet(a1, 8LL, v2[0]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
unsigned __int16 v2[6]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned __int8)SCPI_ParamInt32(a1, v2, 1LL) )
SCPI_RegSet(a1, 8LL, v2[0]);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusQuestionableEnable(scpi_t * context) {
    int32_t new_QUESE;
    if (SCPI_ParamInt32(context, &new_QUESE, (!0))) {
        SCPI_RegSet(context, SCPI_REG_QUESE, (scpi_reg_val_t) new_QUESE);
    }
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusQuestionableEnable(struct _scpi_t *context) {
    int new_QUESE;
    if (SCPI_ParamInt32(context, &new_QUESE, (!0))) {
        SCPI_RegSet(context, SCPI_REG_QUESE, (unsigned short) new_QUESE);
    }
    return SCPI_RES_OK;
}

user_defined_types: enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 }


decompiled_code:
__int64 __fastcall SCPI_StatusOperationConditionQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 6LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 6LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusOperationConditionQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPERC));
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusOperationConditionQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPERC));
    return SCPI_RES_OK;
}

user_defined_types: struct _scpi_t { struct _scpi_command_t *cmdlist; struct _scpi_buffer_t buffer; struct _scpi_param_list_t param_list; struct _scpi_interface_t *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t *units; void *user_context; struct _scpi_parser_state_t parser_state; char *idn[4]; unsigned long arbitrary_remaining; }


decompiled_code:
__int64 __fastcall SCPI_StatusOperationEventQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 4LL);
SCPI_ResultInt32(a1, v1);
SCPI_RegSet(a1, 4LL, 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 4LL);
SCPI_ResultInt32(a1, v1);
SCPI_RegSet(a1, 4LL, 0LL);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusOperationEventQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPER));
    SCPI_RegSet(context, SCPI_REG_OPER, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusOperationEventQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPER));
    SCPI_RegSet(context, SCPI_REG_OPER, 0);
    return SCPI_RES_OK;
}

user_defined_types: struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t lex_state; struct _scpi_const_buffer_t cmd_raw; }


decompiled_code:
__int64 __fastcall SCPI_StatusOperationEnableQ(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 5LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
unsigned __int16 v1; // ax

v1 = SCPI_RegGet(a1, 5LL);
SCPI_ResultInt32(a1, v1);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusOperationEnableQ(scpi_t * context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPERE));
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusOperationEnableQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, SCPI_RegGet(context, SCPI_REG_OPERE));
    return SCPI_RES_OK;
}

user_defined_types: struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t *data; }


decompiled_code:
__int64 __fastcall SCPI_StatusOperationEnable(__int64 a1)
{
unsigned __int16 v2[6]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned __int8)SCPI_ParamInt32(a1, v2, 1LL) )
SCPI_RegSet(a1, 5LL, v2[0]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
unsigned __int16 v2[6]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned __int8)SCPI_ParamInt32(a1, v2, 1LL) )
SCPI_RegSet(a1, 5LL, v2[0]);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusOperationEnable(scpi_t * context) {
    int32_t new_OPERE;
    if (SCPI_ParamInt32(context, &new_OPERE, (!0))) {
        SCPI_RegSet(context, SCPI_REG_OPERE, (scpi_reg_val_t) new_OPERE);
    }
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusOperationEnable(struct _scpi_t *context) {
    int new_OPERE;
    if (SCPI_ParamInt32(context, &new_OPERE, (!0))) {
        SCPI_RegSet(context, SCPI_REG_OPERE, (unsigned short) new_OPERE);
    }
    return SCPI_RES_OK;
}

user_defined_types: struct _scpi_parser_state_t { struct _scpi_token_t programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t termination; }


decompiled_code:
__int64 __fastcall SCPI_StatusPreset(__int64 a1)
{
SCPI_RegSet(a1, 7LL, 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
SCPI_RegSet(a1, 7LL, 0LL);
return 1LL;
}

original_code:
scpi_result_t SCPI_StatusPreset(scpi_t * context) {
    SCPI_RegSet(context, SCPI_REG_QUES, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_StatusPreset(struct _scpi_t *context) {
    SCPI_RegSet(context, SCPI_REG_QUES, 0);
    return SCPI_RES_OK;
}

user_defined_types: struct _scpi_command_t { char *pattern; enum _scpi_result_t (*callback)(struct _scpi_t *); int tag; }


decompiled_code:
__int64 __fastcall SCPI_ErrorAddInternal(__int64 a1, __int16 a2, char *a3, size_t a4)
{
__int64 v4; // rbp
unsigned int v5; // ebx
__int16 v7; // [rsp+0h] [rbp-28h] BYREF
void *ptr; // [rsp+8h] [rbp-20h]

if ( a3 )
a3 = strndup(a3, a4);
v7 = a2;
ptr = a3;
v4 = a1 + 120;
v5 = fifo_add(a1 + 120, &v7);
if ( !(_BYTE)v5 )
{
free(ptr);
fifo_remove_last(v4, &v7);
free(ptr);
v7 = -350;
ptr = 0LL;
fifo_add(v4, &v7);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int16 a2, char *a3, size_t a4)
{
__int64 v4; // rbp
unsigned int v5; // ebx
__int16 v7; // [rsp+0h] [rbp-28h] BYREF
void *ptr; // [rsp+8h] [rbp-20h]

if ( a3 )
a3 = strndup(a3, a4);
v7 = a2;
ptr = a3;
v4 = a1 + 120;
v5 = fifo_add(a1 + 120, &v7);
if ( !(_BYTE)v5 )
{
free(ptr);
fifo_remove_last(v4, &v7);
free(ptr);
v7 = -350;
ptr = 0LL;
fifo_add(v4, &v7);
}
return v5;
}

original_code:
static scpi_bool_t SCPI_ErrorAddInternal(scpi_t * context, int16_t err, char * info, size_t info_len) {
    scpi_error_t error_value;
    (void) info_len;
    char * info_ptr = ((void *)0);
    if (info) {
        info_ptr = strndup((info), (info_len));
    }
    do { (&error_value)->error_code = (err); (&error_value)->device_dependent_info = (info_ptr); } while(0);
    if (!fifo_add(&context->error_queue, &error_value)) {
        free((error_value.device_dependent_info));
        fifo_remove_last(&context->error_queue, &error_value);
        free((error_value.device_dependent_info));
        do { (&error_value)->error_code = (SCPI_ERROR_QUEUE_OVERFLOW); (&error_value)->device_dependent_info = (((void *)0)); } while(0);
        fifo_add(&context->error_queue, &error_value);
        return 0;
    }
    return (!0);
}

canonical_original_code:
static _Bool SCPI_ErrorAddInternal(struct _scpi_t *context, short err, char *info, unsigned long info_len) {
    struct _scpi_error_t error_value;
    (void) info_len;
    char *info_ptr = ((void *)0);
    if (info) {
        info_ptr = strndup((info), (info_len));
    }
    do { (&error_value)->error_code = (err); (&error_value)->device_dependent_info = (info_ptr); } while(0);
    if (!fifo_add(&context->error_queue, &error_value)) {
        free((error_value.device_dependent_info));
        fifo_remove_last(&context->error_queue, &error_value);
        free((error_value.device_dependent_info));
        do { (&error_value)->error_code = (SCPI_ERROR_QUEUE_OVERFLOW); (&error_value)->device_dependent_info = (((void *)0)); } while(0);
        fifo_add(&context->error_queue, &error_value);
        return 0;
    }
    return (!0);
}

variable_types: err short

variable_types:
info
char *

variable_types: struct _scpi_error_t { short error_code; char *device_dependent_info; }

user_defined_types: struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t ctrl, unsigned short val); enum _scpi_result_t (*flush)(struct _scpi_t *); enum _scpi_result_t (*reset)(struct _scpi_t *); }


decompiled_code:
__int64 __fastcall SCPI_ErrorInit(__int64 a1, __int64 a2, __int16 a3)
{
return fifo_init(a1 + 120, a2, (unsigned int)a3);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int16 a3)
{
return fifo_init(a1 + 120, a2, (unsigned int)a3);
}

original_code:
void SCPI_ErrorInit(scpi_t * context, scpi_error_t * data, int16_t size) {
    fifo_init(&context->error_queue, data, size);
}

canonical_original_code:
void SCPI_ErrorInit(struct _scpi_t *context, struct _scpi_error_t *data, short size) {
    fifo_init(&context->error_queue, data, size);
}

variable_types:
data
struct _scpi_error_t *

variable_types: size short

return_type: void

user_defined_types: struct _scpi_unit_def_t { char *name; enum _scpi_unit_t unit; double mult; }


decompiled_code:
__int64 __fastcall SCPI_ErrorCount(__int64 a1)
{
__int16 v2[5]; // [rsp+Eh] [rbp-Ah] BYREF

v2[0] = 0;
fifo_count(a1 + 120, v2);
return (unsigned int)v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int16 v2[5]; // [rsp+Eh] [rbp-Ah] BYREF

v2[0] = 0;
fifo_count(a1 + 120, v2);
return (unsigned int)v2[0];
}

original_code:
int32_t SCPI_ErrorCount(scpi_t * context) {
    int16_t result = 0;
    fifo_count(&context->error_queue, &result);
    return result;
}

canonical_original_code:
int SCPI_ErrorCount(struct _scpi_t *context) {
    short result = 0;
    fifo_count(&context->error_queue, &result);
    return result;
}

variable_types: result short

return_type: int

user_defined_types: struct _scpi_token_t { enum _scpi_token_type_t type; char *ptr; int len; }


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

result = SCPI_ErrorCount(a1);
if ( !(_DWORD)result )
{
result = SCPI_RegGet(a1, 0LL);
if ( (result & 4) != 0 )
{
SCPI_RegClearBits(a1, 0LL, 4LL);
result = *(_QWORD *)(a1 + 88);
if ( result )
{
result = *(_QWORD *)result;
if ( result )
result = ((__int64 (__fastcall *)(__int64, _QWORD))result)(a1, 0LL);
}
}
}
return result;
}

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

result = func2(a1);
if ( !(_DWORD)result )
{
result = SCPI_RegGet(a1, 0LL);
if ( (result & 4) != 0 )
{
SCPI_RegClearBits(a1, 0LL, 4LL);
result = *(_QWORD *)(a1 + 88);
if ( result )
{
result = *(_QWORD *)result;
if ( result )
result = ((__int64 (__fastcall *)(__int64, _QWORD))result)(a1, 0LL);
}
}
}
return result;
}

original_code:
static void SCPI_ErrorEmitEmpty(scpi_t * context) {
    if ((SCPI_ErrorCount(context) == 0) && (SCPI_RegGet(context, SCPI_REG_STB) & 0x04)) {
        SCPI_RegClearBits(context, SCPI_REG_STB, 0x04);
        if (context->interface && context->interface->error) {
            context->interface->error(context, 0);
        }
    }
}

canonical_original_code:
static void SCPI_ErrorEmitEmpty(struct _scpi_t *context) {
    if ((SCPI_ErrorCount(context) == 0) && (SCPI_RegGet(context, SCPI_REG_STB) & 0x04)) {
        SCPI_RegClearBits(context, SCPI_REG_STB, 0x04);
        if (context->interface && context->interface->error) {
            context->interface->error(context, 0);
        }
    }
}

user_defined_types: struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; }


decompiled_code:
__int64 __fastcall SCPI_ErrorClear(__int64 a1)
{
__int64 v1; // rbx
__int64 v3; // [rsp+0h] [rbp-28h] BYREF
void *ptr; // [rsp+8h] [rbp-20h]

v1 = a1 + 120;
while ( (unsigned __int8)fifo_remove(v1, &v3) )
free(ptr);
fifo_clear(v1);
return SCPI_ErrorEmitEmpty(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // rbx
__int64 v3; // [rsp+0h] [rbp-28h] BYREF
void *ptr; // [rsp+8h] [rbp-20h]

v1 = a1 + 120;
while ( (unsigned __int8)fifo_remove(v1, &v3) )
free(ptr);
fifo_clear(v1);
return func3(a1);
}

original_code:
void SCPI_ErrorClear(scpi_t * context) {
    scpi_error_t error;
    while (fifo_remove(&context->error_queue, &error)) {
        free((error.device_dependent_info));
    }
    fifo_clear(&context->error_queue);
    SCPI_ErrorEmitEmpty(context);
}

canonical_original_code:
void SCPI_ErrorClear(struct _scpi_t *context) {
    struct _scpi_error_t error;
    while (fifo_remove(&context->error_queue, &error)) {
        free((error.device_dependent_info));
    }
    fifo_clear(&context->error_queue);
    SCPI_ErrorEmitEmpty(context);
}

user_defined_types: struct _lex_state_t { char *buffer; char *pos; int len; }


decompiled_code:
__int64 __fastcall SCPI_ErrorPop(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( !a2 )
return 0LL;
result = 0LL;
if ( a1 )
{
*(_WORD *)a2 = 0;
*(_QWORD *)(a2 + 8) = 0LL;
fifo_remove(a1 + 120, a2);
SCPI_ErrorEmitEmpty(a1);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( !a2 )
return 0LL;
result = 0LL;
if ( a1 )
{
*(_WORD *)a2 = 0;
*(_QWORD *)(a2 + 8) = 0LL;
fifo_remove(a1 + 120, a2);
func3(a1);
result = 1LL;
}
return result;
}

original_code:
scpi_bool_t SCPI_ErrorPop(scpi_t * context, scpi_error_t * error) {
    if (!error || !context) return 0;
    do { (error)->error_code = (0); (error)->device_dependent_info = (((void *)0)); } while(0);
    fifo_remove(&context->error_queue, error);
    SCPI_ErrorEmitEmpty(context);
    return (!0);
}

canonical_original_code:
_Bool SCPI_ErrorPop(struct _scpi_t *context, struct _scpi_error_t *error) {
    if (!error || !context) return 0;
    do { (error)->error_code = (0); (error)->device_dependent_info = (((void *)0)); } while(0);
    fifo_remove(&context->error_queue, error);
    SCPI_ErrorEmitEmpty(context);
    return (!0);
}

variable_types:
error
struct _scpi_error_t *

user_defined_types: struct _scpi_const_buffer_t { unsigned long length; unsigned long position; char *data; }


decompiled_code:
const char *__fastcall SCPI_ErrorTranslate(__int16 a1)
{
const char *result; // rax

switch ( a1 )
{
case -800:
result = "Operation complete";
break;
case -700:
result = "Request control";
break;
case -600:
result = "User request";
break;
case -500:
result = "Power on";
break;
case -440:
result = "Query UNTERMINATED after indefinite response";
break;
case -430:
result = "Query DEADLOCKED";
break;
case -420:
result = "Query UNTERMINATED";
break;
case -410:
result = "Query INTERRUPTED";
break;
case -400:
result = "Query error";
break;
case -365:
result = "Time out error";
break;
case -363:
result = "Input buffer overrun";
break;
case -362:
result = "Framing error in program message";
break;
case -361:
result = "Parity error in program message";
break;
case -360:
result = "Communication error";
break;
case -350:
result = "Queue overflow";
break;
case -340:
result = "Calibration failed";
break;
case -330:
result = "Self-test failed";
break;
case -321:
result = "Out of memory";
break;
case -320:
result = "Storage fault";
break;
case -315:
result = "Configuration memory lost";
break;
case -314:
result = "Save/recall memory lost";
break;
case -313:
result = "Calibration memory lost";
break;
case -312:
result = "PUD memory lost";
break;
case -311:
result = "Memory error";
break;
case -310:
result = "System error";
break;
case -300:
result = "Device specific error";
break;
case -294:
result = "Incompatible type";
break;
case -293:
result = "Referenced name already exists";
break;
case -292:
result = "Referenced name does not exist";
break;
case -291:
result = "Out of memory";
break;
case -290:
result = "Memory use error";
break;
case -286:
result = "Program runtime error";
break;
case -285:
result = "Program syntax error";
break;
case -284:
result = "Program currently running";
break;
case -283:
result = "Illegal variable name";
break;
case -282:
result = "Illegal program name";
break;
case -281:
result = "Cannot create program";
break;
case -280:
result = "Program error";
break;
case -278:
result = "Macro header not found";
break;
case -277:
result = "Macro redefinition not allowed";
break;
case -276:
result = "Macro recursion error";
break;
case -275:
result = "Macro definition too long";
break;
case -274:
result = "Macro parameter error";
break;
case -273:
result = "Illegal macro label";
break;
case -272:
result = "Macro execution error";
break;
case -271:
result = "Macro syntax error";
break;
case -270:
result = "Macro error";
break;
case -261:
result = "Math error in expression";
break;
case -260:
result = "Expression error";
break;
case -258:
result = "Media protected";
break;
case -257:
result = "File name error";
break;
case -256:
result = "File name not found";
break;
case -255:
result = "Directory full";
break;
case -254:
result = "Media full";
break;
case -253:
result = "Corrupt media";
break;
case -252:
result = "Missing media";
break;
case -251:
result = "Missing mass storage";
break;
case -250:
result = "Mass storage error";
break;
case -241:
result = "Hardware missing";
break;
case -240:
result = "Hardware error";
break;
case -233:
result = "Invalid version";
break;
case -231:
result = "Data questionable";
break;
case -230:
result = "Data corrupt or stale";
break;
case -226:
result = "Lists not same length";
break;
case -225:
result = "Out of memory";
break;
case -224:
result = "Illegal parameter value";
break;
case -223:
result = "Too much data";
break;
case -222:
result = "Data out of range";
break;
case -221:
result = "Settings conflict";
break;
case -220:
result = "Parameter error";
break;
case -215:
result = "Arm deadlock";
break;
case -214:
result = "Trigger deadlock";
break;
case -213:
result = "Init ignored";
break;
case -212:
result = "Arm ignored";
break;
case -211:
result = "Trigger ignored";
break;
case -210:
result = "Trigger error";
break;
case -203:
result = "Command protected";
break;
case -202:
result = "Settings lost due to rtl";
break;
case -201:
result = "Invalid while in local";
break;
case -200:
result = "Execution error";
break;
case -184:
result = "Macro parameter error";
break;
case -183:
result = "Invalid inside macro definition";
break;
case -181:
result = "Invalid outside macro definition";
break;
case -180:
result = "Macro error";
break;
case -178:
result = "Expression data not allowed";
break;
case -171:
result = "Invalid expression";
break;
case -170:
result = "Expression error";
break;
case -168:
result = "Block data not allowed";
break;
case -161:
result = "Invalid block data";
break;
case -160:
result = "Block data error";
break;
case -158:
result = "String data not allowed";
break;
case -151:
result = "Invalid string data";
break;
case -150:
result = "String data error";
break;
case -148:
result = "Character data not allowed";
break;
case -144:
result = "Character data too long";
break;
case -141:
result = "Invalid character data";
break;
case -140:
result = "Character data error";
break;
case -138:
result = "Suffix not allowed";
break;
case -134:
result = "Suffix too long";
break;
case -131:
result = "Invalid suffix";
break;
case -130:
result = "Suffix error";
break;
case -128:
result = "Numeric data not allowed";
break;
case -124:
result = "Too many digits";
break;
case -123:
result = "Exponent too large";
break;
case -121:
result = "Invalid character in number";
break;
case -120:
result = "Numeric data error";
break;
case -115:
result = "Unexpected number of parameters";
break;
case -114:
result = "Header suffix out of range";
break;
case -113:
result = "Undefined header";
break;
case -112:
result = "Program mnemonic too long";
break;
case -111:
result = "Header separator error";
break;
case -110:
result = "Command header error";
break;
case -109:
result = "Missing parameter";
break;
case -108:
result = "Parameter not allowed";
break;
case -105:
result = "GET not allowed";
break;
case -104:
result = "Data type error";
break;
case -103:
result = "Invalid separator";
break;
case -102:
result = "Syntax error";
break;
case -101:
result = "Invalid character";
break;
case -100:
result = "Command error";
break;
case 0:
result = "No error";
break;
default:
result = "Unknown error";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func6(__int16 a1)
{
const char *result; // rax

switch ( a1 )
{
case -800:
result = "Operation complete";
break;
case -700:
result = "Request control";
break;
case -600:
result = "User request";
break;
case -500:
result = "Power on";
break;
case -440:
result = "Query UNTERMINATED after indefinite response";
break;
case -430:
result = "Query DEADLOCKED";
break;
case -420:
result = "Query UNTERMINATED";
break;
case -410:
result = "Query INTERRUPTED";
break;
case -400:
result = "Query error";
break;
case -365:
result = "Time out error";
break;
case -363:
result = "Input buffer overrun";
break;
case -362:
result = "Framing error in program message";
break;
case -361:
result = "Parity error in program message";
break;
case -360:
result = "Communication error";
break;
case -350:
result = "Queue overflow";
break;
case -340:
result = "Calibration failed";
break;
case -330:
result = "Self-test failed";
break;
case -321:
result = "Out of memory";
break;
case -320:
result = "Storage fault";
break;
case -315:
result = "Configuration memory lost";
break;
case -314:
result = "Save/recall memory lost";
break;
case -313:
result = "Calibration memory lost";
break;
case -312:
result = "PUD memory lost";
break;
case -311:
result = "Memory error";
break;
case -310:
result = "System error";
break;
case -300:
result = "Device specific error";
break;
case -294:
result = "Incompatible type";
break;
case -293:
result = "Referenced name already exists";
break;
case -292:
result = "Referenced name does not exist";
break;
case -291:
result = "Out of memory";
break;
case -290:
result = "Memory use error";
break;
case -286:
result = "Program runtime error";
break;
case -285:
result = "Program syntax error";
break;
case -284:
result = "Program currently running";
break;
case -283:
result = "Illegal variable name";
break;
case -282:
result = "Illegal program name";
break;
case -281:
result = "Cannot create program";
break;
case -280:
result = "Program error";
break;
case -278:
result = "Macro header not found";
break;
case -277:
result = "Macro redefinition not allowed";
break;
case -276:
result = "Macro recursion error";
break;
case -275:
result = "Macro definition too long";
break;
case -274:
result = "Macro parameter error";
break;
case -273:
result = "Illegal macro label";
break;
case -272:
result = "Macro execution error";
break;
case -271:
result = "Macro syntax error";
break;
case -270:
result = "Macro error";
break;
case -261:
result = "Math error in expression";
break;
case -260:
result = "Expression error";
break;
case -258:
result = "Media protected";
break;
case -257:
result = "File name error";
break;
case -256:
result = "File name not found";
break;
case -255:
result = "Directory full";
break;
case -254:
result = "Media full";
break;
case -253:
result = "Corrupt media";
break;
case -252:
result = "Missing media";
break;
case -251:
result = "Missing mass storage";
break;
case -250:
result = "Mass storage error";
break;
case -241:
result = "Hardware missing";
break;
case -240:
result = "Hardware error";
break;
case -233:
result = "Invalid version";
break;
case -231:
result = "Data questionable";
break;
case -230:
result = "Data corrupt or stale";
break;
case -226:
result = "Lists not same length";
break;
case -225:
result = "Out of memory";
break;
case -224:
result = "Illegal parameter value";
break;
case -223:
result = "Too much data";
break;
case -222:
result = "Data out of range";
break;
case -221:
result = "Settings conflict";
break;
case -220:
result = "Parameter error";
break;
case -215:
result = "Arm deadlock";
break;
case -214:
result = "Trigger deadlock";
break;
case -213:
result = "Init ignored";
break;
case -212:
result = "Arm ignored";
break;
case -211:
result = "Trigger ignored";
break;
case -210:
result = "Trigger error";
break;
case -203:
result = "Command protected";
break;
case -202:
result = "Settings lost due to rtl";
break;
case -201:
result = "Invalid while in local";
break;
case -200:
result = "Execution error";
break;
case -184:
result = "Macro parameter error";
break;
case -183:
result = "Invalid inside macro definition";
break;
case -181:
result = "Invalid outside macro definition";
break;
case -180:
result = "Macro error";
break;
case -178:
result = "Expression data not allowed";
break;
case -171:
result = "Invalid expression";
break;
case -170:
result = "Expression error";
break;
case -168:
result = "Block data not allowed";
break;
case -161:
result = "Invalid block data";
break;
case -160:
result = "Block data error";
break;
case -158:
result = "String data not allowed";
break;
case -151:
result = "Invalid string data";
break;
case -150:
result = "String data error";
break;
case -148:
result = "Character data not allowed";
break;
case -144:
result = "Character data too long";
break;
case -141:
result = "Invalid character data";
break;
case -140:
result = "Character data error";
break;
case -138:
result = "Suffix not allowed";
break;
case -134:
result = "Suffix too long";
break;
case -131:
result = "Invalid suffix";
break;
case -130:
result = "Suffix error";
break;
case -128:
result = "Numeric data not allowed";
break;
case -124:
result = "Too many digits";
break;
case -123:
result = "Exponent too large";
break;
case -121:
result = "Invalid character in number";
break;
case -120:
result = "Numeric data error";
break;
case -115:
result = "Unexpected number of parameters";
break;
case -114:
result = "Header suffix out of range";
break;
case -113:
result = "Undefined header";
break;
case -112:
result = "Program mnemonic too long";
break;
case -111:
result = "Header separator error";
break;
case -110:
result = "Command header error";
break;
case -109:
result = "Missing parameter";
break;
case -108:
result = "Parameter not allowed";
break;
case -105:
result = "GET not allowed";
break;
case -104:
result = "Data type error";
break;
case -103:
result = "Invalid separator";
break;
case -102:
result = "Syntax error";
break;
case -101:
result = "Invalid character";
break;
case -100:
result = "Command error";
break;
case 0:
result = "No error";
break;
default:
result = "Unknown error";
break;
}
return result;
}

original_code:
const char * SCPI_ErrorTranslate(int16_t err) {
    switch (err) {
        case SCPI_ERROR_NO_ERROR: return "No error"; case SCPI_ERROR_COMMAND: return "Command error"; case SCPI_ERROR_INVALID_CHARACTER: return "Invalid character"; case SCPI_ERROR_SYNTAX: return "Syntax error"; case SCPI_ERROR_INVALID_SEPARATOR: return "Invalid separator"; case SCPI_ERROR_DATA_TYPE_ERROR: return "Data type error"; case SCPI_ERROR_GET_NOT_ALLOWED: return "GET not allowed"; case SCPI_ERROR_PARAMETER_NOT_ALLOWED: return "Parameter not allowed"; case SCPI_ERROR_MISSING_PARAMETER: return "Missing parameter"; case SCPI_ERROR_COMMAND_HEADER: return "Command header error"; case SCPI_ERROR_HEADER_SEPARATOR: return "Header separator error"; case SCPI_ERROR_PRG_MNEMONIC_TOO_LONG: return "Program mnemonic too long"; case SCPI_ERROR_UNDEFINED_HEADER: return "Undefined header"; case SCPI_ERROR_HEADER_SUFFIX_OUTOFRANGE: return "Header suffix out of range"; case SCPI_ERROR_UNEXP_NUM_OF_PARAMETER: return "Unexpected number of parameters"; case SCPI_ERROR_NUMERIC_DATA_ERROR: return "Numeric data error"; case SCPI_ERROR_INVAL_CHAR_IN_NUMBER: return "Invalid character in number"; case SCPI_ERROR_EXPONENT_TOO_LONG: return "Exponent too large"; case SCPI_ERROR_TOO_MANY_DIGITS: return "Too many digits"; case SCPI_ERROR_NUMERIC_DATA_NOT_ALLOWED: return "Numeric data not allowed"; case SCPI_ERROR_SUFFIX_ERROR: return "Suffix error"; case SCPI_ERROR_INVALID_SUFFIX: return "Invalid suffix"; case SCPI_ERROR_SUFFIX_TOO_LONG: return "Suffix too long"; case SCPI_ERROR_SUFFIX_NOT_ALLOWED: return "Suffix not allowed"; case SCPI_ERROR_CHARACTER_DATA_ERROR: return "Character data error"; case SCPI_ERROR_INVAL_CHARACTER_DATA: return "Invalid character data"; case SCPI_ERROR_CHARACTER_DATA_TOO_LONG: return "Character data too long"; case SCPI_ERROR_CHARACTER_DATA_NOT_ALLOWED: return "Character data not allowed"; case SCPI_ERROR_STRING_DATA_ERROR: return "String data error"; case SCPI_ERROR_INVALID_STRING_DATA: return "Invalid string data"; case SCPI_ERROR_STRING_DATA_NOT_ALLOWED: return "String data not allowed"; case SCPI_ERROR_BLOCK_DATA_ERROR: return "Block data error"; case SCPI_ERROR_INVALID_BLOCK_DATA: return "Invalid block data"; case SCPI_ERROR_BLOCK_DATA_NOT_ALLOWED: return "Block data not allowed"; case SCPI_ERROR_EXPRESSION_PARSING_ERROR: return "Expression error"; case SCPI_ERROR_INVAL_EXPRESSION: return "Invalid expression"; case SCPI_ERROR_EXPRESSION_DATA_NOT_ALLOWED: return "Expression data not allowed"; case SCPI_ERROR_MACRO_DEFINITION_ERROR: return "Macro error"; case SCPI_ERROR_INVAL_OUTSIDE_MACRO_DEF: return "Invalid outside macro definition"; case SCPI_ERROR_INVAL_INSIDE_MACRO_DEF: return "Invalid inside macro definition"; case SCPI_ERROR_MACRO_PARAMETER_ERROR: return "Macro parameter error"; case SCPI_ERROR_EXECUTION_ERROR: return "Execution error"; case SCPI_ERROR_INVAL_WHILE_IN_LOCAL: return "Invalid while in local"; case SCPI_ERROR_SETTINGS_LOST_DUE_TO_RTL: return "Settings lost due to rtl"; case SCPI_ERROR_COMMAND_PROTECTED: return "Command protected"; case SCPI_ERROR_TRIGGER_ERROR: return "Trigger error"; case SCPI_ERROR_TRIGGER_IGNORED: return "Trigger ignored"; case SCPI_ERROR_ARM_IGNORED: return "Arm ignored"; case SCPI_ERROR_INIT_IGNORED: return "Init ignored"; case SCPI_ERROR_TRIGGER_DEADLOCK: return "Trigger deadlock"; case SCPI_ERROR_ARM_DEADLOCK: return "Arm deadlock"; case SCPI_ERROR_PARAMETER_ERROR: return "Parameter error"; case SCPI_ERROR_SETTINGS_CONFLICT: return "Settings conflict"; case SCPI_ERROR_DATA_OUT_OF_RANGE: return "Data out of range"; case SCPI_ERROR_TOO_MUCH_DATA: return "Too much data"; case SCPI_ERROR_ILLEGAL_PARAMETER_VALUE: return "Illegal parameter value"; case SCPI_ERROR_OUT_OF_MEMORY_FOR_REQ_OP: return "Out of memory"; case SCPI_ERROR_LISTS_NOT_SAME_LENGTH: return "Lists not same length"; case SCPI_ERROR_DATA_CORRUPT: return "Data corrupt or stale"; case SCPI_ERROR_DATA_QUESTIONABLE: return "Data questionable"; case SCPI_ERROR_INVAL_VERSION: return "Invalid version"; case SCPI_ERROR_HARDWARE_ERROR: return "Hardware error"; case SCPI_ERROR_HARDWARE_MISSING: return "Hardware missing"; case SCPI_ERROR_MASS_STORAGE_ERROR: return "Mass storage error"; case SCPI_ERROR_MISSING_MASS_STORAGE: return "Missing mass storage"; case SCPI_ERROR_MISSING_MASS_MEDIA: return "Missing media"; case SCPI_ERROR_CORRUPT_MEDIA: return "Corrupt media"; case SCPI_ERROR_MEDIA_FULL: return "Media full"; case SCPI_ERROR_DIRECTORY_FULL: return "Directory full"; case SCPI_ERROR_FILE_NAME_NOT_FOUND: return "File name not found"; case SCPI_ERROR_FILE_NAME_ERROR: return "File name error"; case SCPI_ERROR_MEDIA_PROTECTED: return "Media protected"; case SCPI_ERROR_EXPRESSION_EXECUTING_ERROR: return "Expression error"; case SCPI_ERROR_MATH_ERROR_IN_EXPRESSION: return "Math error in expression"; case SCPI_ERROR_MACRO_UNDEF_EXEC_ERROR: return "Macro error"; case SCPI_ERROR_MACRO_SYNTAX_ERROR: return "Macro syntax error"; case SCPI_ERROR_MACRO_EXECUTION_ERROR: return "Macro execution error"; case SCPI_ERROR_ILLEGAL_MACRO_LABEL: return "Illegal macro label"; case SCPI_ERROR_IMPROPER_USED_MACRO_PARAM: return "Macro parameter error"; case SCPI_ERROR_MACRO_DEFINITION_TOO_LONG: return "Macro definition too long"; case SCPI_ERROR_MACRO_RECURSION_ERROR: return "Macro recursion error"; case SCPI_ERROR_MACRO_REDEF_NOT_ALLOWED: return "Macro redefinition not allowed"; case SCPI_ERROR_MACRO_HEADER_NOT_FOUND: return "Macro header not found"; case SCPI_ERROR_PROGRAM_ERROR: return "Program error"; case SCPI_ERROR_CANNOT_CREATE_PROGRAM: return "Cannot create program"; case SCPI_ERROR_ILLEGAL_PROGRAM_NAME: return "Illegal program name"; case SCPI_ERROR_ILLEGAL_VARIABLE_NAME: return "Illegal variable name"; case SCPI_ERROR_PROGRAM_CURRENTLY_RUNNING: return "Program currently running"; case SCPI_ERROR_PROGRAM_SYNTAX_ERROR: return "Program syntax error"; case SCPI_ERROR_PROGRAM_RUNTIME_ERROR: return "Program runtime error"; case SCPI_ERROR_MEMORY_USE_ERROR: return "Memory use error"; case SCPI_ERROR_OUT_OF_MEMORY: return "Out of memory"; case SCPI_ERROR_REF_NAME_DOES_NOT_EXIST: return "Referenced name does not exist"; case SCPI_ERROR_REF_NAME_ALREADY_EXISTS: return "Referenced name already exists"; case SCPI_ERROR_INCOMPATIBLE_TYPE: return "Incompatible type"; case SCPI_ERROR_DEVICE_ERROR: return "Device specific error"; case SCPI_ERROR_SYSTEM_ERROR: return "System error"; case SCPI_ERROR_MEMORY_ERROR: return "Memory error"; case SCPI_ERROR_PUD_MEMORY_LOST: return "PUD memory lost"; case SCPI_ERROR_CALIBRATION_MEMORY_LOST: return "Calibration memory lost"; case SCPI_ERROR_SAVE_RECALL_MEMORY_LOST: return "Save/recall memory lost"; case SCPI_ERROR_CONFIGURATION_MEMORY_LOST: return "Configuration memory lost"; case SCPI_ERROR_STORAGE_FAULT: return "Storage fault"; case SCPI_ERROR_OUT_OF_DEVICE_MEMORY: return "Out of memory"; case SCPI_ERROR_SELF_TEST_FAILED: return "Self-test failed"; case SCPI_ERROR_CALIBRATION_FAILED: return "Calibration failed"; case SCPI_ERROR_QUEUE_OVERFLOW: return "Queue overflow"; case SCPI_ERROR_COMMUNICATION_ERROR: return "Communication error"; case SCPI_ERROR_PARITY_ERROR_IN_CMD_MSG: return "Parity error in program message"; case SCPI_ERROR_FRAMING_ERROR_IN_CMD_MSG: return "Framing error in program message"; case SCPI_ERROR_INPUT_BUFFER_OVERRUN: return "Input buffer overrun"; case SCPI_ERROR_TIME_OUT: return "Time out error"; case SCPI_ERROR_QUERY_ERROR: return "Query error"; case SCPI_ERROR_QUERY_INTERRUPTED: return "Query INTERRUPTED"; case SCPI_ERROR_QUERY_UNTERMINATED: return "Query UNTERMINATED"; case SCPI_ERROR_QUERY_DEADLOCKED: return "Query DEADLOCKED"; case SCPI_ERROR_QUERY_UNTERM_INDEF_RESP: return "Query UNTERMINATED after indefinite response"; case SCPI_ERROR_POWER_ON: return "Power on"; case SCPI_ERROR_USER_REQUEST: return "User request"; case SCPI_ERROR_REQUEST_CONTROL: return "Request control"; case SCPI_ERROR_OPERATION_COMPLETE: return "Operation complete";
        default: return "Unknown error";
    }
}

canonical_original_code:
char *SCPI_ErrorTranslate(short err) {
    switch (err) {
        case SCPI_ERROR_NO_ERROR: return "No error"; case SCPI_ERROR_COMMAND: return "Command error"; case SCPI_ERROR_INVALID_CHARACTER: return "Invalid character"; case SCPI_ERROR_SYNTAX: return "Syntax error"; case SCPI_ERROR_INVALID_SEPARATOR: return "Invalid separator"; case SCPI_ERROR_DATA_TYPE_ERROR: return "Data type error"; case SCPI_ERROR_GET_NOT_ALLOWED: return "GET not allowed"; case SCPI_ERROR_PARAMETER_NOT_ALLOWED: return "Parameter not allowed"; case SCPI_ERROR_MISSING_PARAMETER: return "Missing parameter"; case SCPI_ERROR_COMMAND_HEADER: return "Command header error"; case SCPI_ERROR_HEADER_SEPARATOR: return "Header separator error"; case SCPI_ERROR_PRG_MNEMONIC_TOO_LONG: return "Program mnemonic too long"; case SCPI_ERROR_UNDEFINED_HEADER: return "Undefined header"; case SCPI_ERROR_HEADER_SUFFIX_OUTOFRANGE: return "Header suffix out of range"; case SCPI_ERROR_UNEXP_NUM_OF_PARAMETER: return "Unexpected number of parameters"; case SCPI_ERROR_NUMERIC_DATA_ERROR: return "Numeric data error"; case SCPI_ERROR_INVAL_CHAR_IN_NUMBER: return "Invalid character in number"; case SCPI_ERROR_EXPONENT_TOO_LONG: return "Exponent too large"; case SCPI_ERROR_TOO_MANY_DIGITS: return "Too many digits"; case SCPI_ERROR_NUMERIC_DATA_NOT_ALLOWED: return "Numeric data not allowed"; case SCPI_ERROR_SUFFIX_ERROR: return "Suffix error"; case SCPI_ERROR_INVALID_SUFFIX: return "Invalid suffix"; case SCPI_ERROR_SUFFIX_TOO_LONG: return "Suffix too long"; case SCPI_ERROR_SUFFIX_NOT_ALLOWED: return "Suffix not allowed"; case SCPI_ERROR_CHARACTER_DATA_ERROR: return "Character data error"; case SCPI_ERROR_INVAL_CHARACTER_DATA: return "Invalid character data"; case SCPI_ERROR_CHARACTER_DATA_TOO_LONG: return "Character data too long"; case SCPI_ERROR_CHARACTER_DATA_NOT_ALLOWED: return "Character data not allowed"; case SCPI_ERROR_STRING_DATA_ERROR: return "String data error"; case SCPI_ERROR_INVALID_STRING_DATA: return "Invalid string data"; case SCPI_ERROR_STRING_DATA_NOT_ALLOWED: return "String data not allowed"; case SCPI_ERROR_BLOCK_DATA_ERROR: return "Block data error"; case SCPI_ERROR_INVALID_BLOCK_DATA: return "Invalid block data"; case SCPI_ERROR_BLOCK_DATA_NOT_ALLOWED: return "Block data not allowed"; case SCPI_ERROR_EXPRESSION_PARSING_ERROR: return "Expression error"; case SCPI_ERROR_INVAL_EXPRESSION: return "Invalid expression"; case SCPI_ERROR_EXPRESSION_DATA_NOT_ALLOWED: return "Expression data not allowed"; case SCPI_ERROR_MACRO_DEFINITION_ERROR: return "Macro error"; case SCPI_ERROR_INVAL_OUTSIDE_MACRO_DEF: return "Invalid outside macro definition"; case SCPI_ERROR_INVAL_INSIDE_MACRO_DEF: return "Invalid inside macro definition"; case SCPI_ERROR_MACRO_PARAMETER_ERROR: return "Macro parameter error"; case SCPI_ERROR_EXECUTION_ERROR: return "Execution error"; case SCPI_ERROR_INVAL_WHILE_IN_LOCAL: return "Invalid while in local"; case SCPI_ERROR_SETTINGS_LOST_DUE_TO_RTL: return "Settings lost due to rtl"; case SCPI_ERROR_COMMAND_PROTECTED: return "Command protected"; case SCPI_ERROR_TRIGGER_ERROR: return "Trigger error"; case SCPI_ERROR_TRIGGER_IGNORED: return "Trigger ignored"; case SCPI_ERROR_ARM_IGNORED: return "Arm ignored"; case SCPI_ERROR_INIT_IGNORED: return "Init ignored"; case SCPI_ERROR_TRIGGER_DEADLOCK: return "Trigger deadlock"; case SCPI_ERROR_ARM_DEADLOCK: return "Arm deadlock"; case SCPI_ERROR_PARAMETER_ERROR: return "Parameter error"; case SCPI_ERROR_SETTINGS_CONFLICT: return "Settings conflict"; case SCPI_ERROR_DATA_OUT_OF_RANGE: return "Data out of range"; case SCPI_ERROR_TOO_MUCH_DATA: return "Too much data"; case SCPI_ERROR_ILLEGAL_PARAMETER_VALUE: return "Illegal parameter value"; case SCPI_ERROR_OUT_OF_MEMORY_FOR_REQ_OP: return "Out of memory"; case SCPI_ERROR_LISTS_NOT_SAME_LENGTH: return "Lists not same length"; case SCPI_ERROR_DATA_CORRUPT: return "Data corrupt or stale"; case SCPI_ERROR_DATA_QUESTIONABLE: return "Data questionable"; case SCPI_ERROR_INVAL_VERSION: return "Invalid version"; case SCPI_ERROR_HARDWARE_ERROR: return "Hardware error"; case SCPI_ERROR_HARDWARE_MISSING: return "Hardware missing"; case SCPI_ERROR_MASS_STORAGE_ERROR: return "Mass storage error"; case SCPI_ERROR_MISSING_MASS_STORAGE: return "Missing mass storage"; case SCPI_ERROR_MISSING_MASS_MEDIA: return "Missing media"; case SCPI_ERROR_CORRUPT_MEDIA: return "Corrupt media"; case SCPI_ERROR_MEDIA_FULL: return "Media full"; case SCPI_ERROR_DIRECTORY_FULL: return "Directory full"; case SCPI_ERROR_FILE_NAME_NOT_FOUND: return "File name not found"; case SCPI_ERROR_FILE_NAME_ERROR: return "File name error"; case SCPI_ERROR_MEDIA_PROTECTED: return "Media protected"; case SCPI_ERROR_EXPRESSION_EXECUTING_ERROR: return "Expression error"; case SCPI_ERROR_MATH_ERROR_IN_EXPRESSION: return "Math error in expression"; case SCPI_ERROR_MACRO_UNDEF_EXEC_ERROR: return "Macro error"; case SCPI_ERROR_MACRO_SYNTAX_ERROR: return "Macro syntax error"; case SCPI_ERROR_MACRO_EXECUTION_ERROR: return "Macro execution error"; case SCPI_ERROR_ILLEGAL_MACRO_LABEL: return "Illegal macro label"; case SCPI_ERROR_IMPROPER_USED_MACRO_PARAM: return "Macro parameter error"; case SCPI_ERROR_MACRO_DEFINITION_TOO_LONG: return "Macro definition too long"; case SCPI_ERROR_MACRO_RECURSION_ERROR: return "Macro recursion error"; case SCPI_ERROR_MACRO_REDEF_NOT_ALLOWED: return "Macro redefinition not allowed"; case SCPI_ERROR_MACRO_HEADER_NOT_FOUND: return "Macro header not found"; case SCPI_ERROR_PROGRAM_ERROR: return "Program error"; case SCPI_ERROR_CANNOT_CREATE_PROGRAM: return "Cannot create program"; case SCPI_ERROR_ILLEGAL_PROGRAM_NAME: return "Illegal program name"; case SCPI_ERROR_ILLEGAL_VARIABLE_NAME: return "Illegal variable name"; case SCPI_ERROR_PROGRAM_CURRENTLY_RUNNING: return "Program currently running"; case SCPI_ERROR_PROGRAM_SYNTAX_ERROR: return "Program syntax error"; case SCPI_ERROR_PROGRAM_RUNTIME_ERROR: return "Program runtime error"; case SCPI_ERROR_MEMORY_USE_ERROR: return "Memory use error"; case SCPI_ERROR_OUT_OF_MEMORY: return "Out of memory"; case SCPI_ERROR_REF_NAME_DOES_NOT_EXIST: return "Referenced name does not exist"; case SCPI_ERROR_REF_NAME_ALREADY_EXISTS: return "Referenced name already exists"; case SCPI_ERROR_INCOMPATIBLE_TYPE: return "Incompatible type"; case SCPI_ERROR_DEVICE_ERROR: return "Device specific error"; case SCPI_ERROR_SYSTEM_ERROR: return "System error"; case SCPI_ERROR_MEMORY_ERROR: return "Memory error"; case SCPI_ERROR_PUD_MEMORY_LOST: return "PUD memory lost"; case SCPI_ERROR_CALIBRATION_MEMORY_LOST: return "Calibration memory lost"; case SCPI_ERROR_SAVE_RECALL_MEMORY_LOST: return "Save/recall memory lost"; case SCPI_ERROR_CONFIGURATION_MEMORY_LOST: return "Configuration memory lost"; case SCPI_ERROR_STORAGE_FAULT: return "Storage fault"; case SCPI_ERROR_OUT_OF_DEVICE_MEMORY: return "Out of memory"; case SCPI_ERROR_SELF_TEST_FAILED: return "Self-test failed"; case SCPI_ERROR_CALIBRATION_FAILED: return "Calibration failed"; case SCPI_ERROR_QUEUE_OVERFLOW: return "Queue overflow"; case SCPI_ERROR_COMMUNICATION_ERROR: return "Communication error"; case SCPI_ERROR_PARITY_ERROR_IN_CMD_MSG: return "Parity error in program message"; case SCPI_ERROR_FRAMING_ERROR_IN_CMD_MSG: return "Framing error in program message"; case SCPI_ERROR_INPUT_BUFFER_OVERRUN: return "Input buffer overrun"; case SCPI_ERROR_TIME_OUT: return "Time out error"; case SCPI_ERROR_QUERY_ERROR: return "Query error"; case SCPI_ERROR_QUERY_INTERRUPTED: return "Query INTERRUPTED"; case SCPI_ERROR_QUERY_UNTERMINATED: return "Query UNTERMINATED"; case SCPI_ERROR_QUERY_DEADLOCKED: return "Query DEADLOCKED"; case SCPI_ERROR_QUERY_UNTERM_INDEF_RESP: return "Query UNTERMINATED after indefinite response"; case SCPI_ERROR_POWER_ON: return "Power on"; case SCPI_ERROR_USER_REQUEST: return "User request"; case SCPI_ERROR_REQUEST_CONTROL: return "Request control"; case SCPI_ERROR_OPERATION_COMPLETE: return "Operation complete";
        default: return "Unknown error";
    }
}

return_type: char *


translateUnitInverse

decompiled_code:
__int64 __fastcall translateUnitInverse(__int64 *a1, int a2)
{
__int64 result; // rax
_QWORD *v3; // rdi

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
v3 = a1 + 3;
do
{
if ( *((_DWORD *)v3 - 4) == a2 && 1.0 == *((double *)v3 - 1) )
break;
v3 += 3;
result = *(v3 - 3);
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, int a2)
{
__int64 result; // rax
_QWORD *v3; // rdi

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
v3 = a1 + 3;
do
{
if ( *((_DWORD *)v3 - 4) == a2 && 1.0 == *((double *)v3 - 1) )
break;
v3 += 3;
result = *(v3 - 3);
}
while ( result );
}
return result;
}

original_code:
static const char * translateUnitInverse(const scpi_unit_def_t * units, const scpi_unit_t unit) {
    int i;
    if (units == ((void *)0)) {
        return ((void *)0);
    }
    for (i = 0; units[i].name != ((void *)0); i++) {
        if ((units[i].unit == unit) && (units[i].mult == 1)) {
            return units[i].name;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static char *translateUnitInverse(struct _scpi_unit_def_t *units, enum _scpi_unit_t unit) {
    int i;
    if (units == ((void *)0)) {
        return ((void *)0);
    }
    for (i = 0; units[i].name != ((void *)0); i++) {
        if ((units[i].unit == unit) && (units[i].mult == 1)) {
            return units[i].name;
        }
    }
    return ((void *)0);
}

variable_types: struct _scpi_unit_def_t { char *name; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; double mult; } *

variable_types: i int


translateUnit

decompiled_code:
const char *__fastcall translateUnit(const char **a1, __int64 a2, __int64 a3)
{
const char **v3; // rbp
const char *v5; // rbx
size_t v6; // rax

v3 = a1;
if ( !a1 )
return 0LL;
v5 = *a1;
if ( *a1 )
{
while ( 1 )
{
v6 = strlen(v5);
if ( (unsigned __int8)compareStr(a2, a3, v5, v6) )
break;
v3 += 3;
v5 = *v3;
if ( !*v3 )
return v5;
}
v5 = (const char *)v3;
}
return v5;
}

canonical_decompiled_code:
const char *__fastcall func1(const char **a1, __int64 a2, __int64 a3)
{
const char **v3; // rbp
const char *v5; // rbx
size_t v6; // rax

v3 = a1;
if ( !a1 )
return 0LL;
v5 = *a1;
if ( *a1 )
{
while ( 1 )
{
v6 = strlen(v5);
if ( (unsigned __int8)compareStr(a2, a3, v5, v6) )
break;
v3 += 3;
v5 = *v3;
if ( !*v3 )
return v5;
}
v5 = (const char *)v3;
}
return v5;
}

original_code:
static const scpi_unit_def_t * translateUnit(const scpi_unit_def_t * units, const char * unit, size_t len) {
    int i;
    if (units == ((void *)0)) {
        return ((void *)0);
    }
    for (i = 0; units[i].name != ((void *)0); i++) {
        if (compareStr(unit, len, units[i].name, strlen(units[i].name))) {
            return &units[i];
        }
    }
    return ((void *)0);
}

canonical_original_code:
static struct _scpi_unit_def_t *translateUnit(struct _scpi_unit_def_t *units, char *unit, unsigned long len) {
    int i;
    if (units == ((void *)0)) {
        return ((void *)0);
    }
    for (i = 0; units[i].name != ((void *)0); i++) {
        if (compareStr(unit, len, units[i].name, strlen(units[i].name))) {
            return &units[i];
        }
    }
    return ((void *)0);
}

variable_types:
units
struct _scpi_unit_def_t *

variable_types:
unit
char *

variable_types:
len
unsigned long

return_type: struct _scpi_unit_def_t { char *name; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; double mult; } *


transformNumber

decompiled_code:
__int64 __fastcall transformNumber(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // rax
const char *v7; // rax
__int64 result; // rax

v6 = skipWhitespace(a2, a3);
if ( a3 == v6 )
{
*(_DWORD *)(a4 + 16) = 0;
result = 1LL;
}
else
{
v7 = translateUnit(*(const char ***)(a1 + 160), a2 + v6, a3 - v6);
if ( v7 )
{
*(double *)(a4 + 8) = *(double *)(a4 + 8) * *((double *)v7 + 2);
*(_DWORD *)(a4 + 16) = *((_DWORD *)v7 + 2);
result = 1LL;
}
else
{
SCPI_ErrorPush(a1, 4294967165LL);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // rax
const char *v7; // rax
__int64 result; // rax

v6 = skipWhitespace(a2, a3);
if ( a3 == v6 )
{
*(_DWORD *)(a4 + 16) = 0;
result = 1LL;
}
else
{
v7 = func1(*(const char ***)(a1 + 160), a2 + v6, a3 - v6);
if ( v7 )
{
*(double *)(a4 + 8) = *(double *)(a4 + 8) * *((double *)v7 + 2);
*(_DWORD *)(a4 + 16) = *((_DWORD *)v7 + 2);
result = 1LL;
}
else
{
SCPI_ErrorPush(a1, 4294967165LL);
result = 0LL;
}
}
return result;
}

original_code:
static scpi_bool_t transformNumber(scpi_t * context, const char * unit, size_t len, scpi_number_t * value) {
    size_t s;
    const scpi_unit_def_t * unitDef;
    s = skipWhitespace(unit, len);
    if (s == len) {
        value->unit = SCPI_UNIT_NONE;
        return (!0);
    }
    unitDef = translateUnit(context->units, unit + s, len - s);
    if (unitDef == ((void *)0)) {
        SCPI_ErrorPush(context, SCPI_ERROR_INVALID_SUFFIX);
        return 0;
    }
    value->content.value *= unitDef->mult;
    value->unit = unitDef->unit;
    return (!0);
}

canonical_original_code:
static _Bool transformNumber(struct _scpi_t *context, char *unit, unsigned long len, struct _scpi_number_parameter_t *value) {
    unsigned long s;
    struct _scpi_unit_def_t *unitDef;
    s = skipWhitespace(unit, len);
    if (s == len) {
        value->unit = SCPI_UNIT_NONE;
        return (!0);
    }
    unitDef = translateUnit(context->units, unit + s, len - s);
    if (unitDef == ((void *)0)) {
        SCPI_ErrorPush(context, SCPI_ERROR_INVALID_SUFFIX);
        return 0;
    }
    value->content.value *= unitDef->mult;
    value->unit = unitDef->unit;
    return (!0);
}

variable_types: struct _scpi_number_parameter_t { _Bool special; union { double value; int tag; } content; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; char base; } *

variable_types:
s
unsigned long

user_defined_types: struct _scpi_number_parameter_t { _Bool special; union { double value; int tag; } content; enum _scpi_unit_t unit; char base; }

user_defined_types: struct _scpi_error_t { short error_code; char *device_dependent_info; }


decompiled_code:
__int64 __fastcall SCPI_ParamNumber(__int64 a1, __int64 a2, __int64 a3, unsigned __int8 a4)
{
unsigned int v5; // ebp
unsigned int v6; // eax
int v8; // [rsp+Ch] [rbp-8Ch] BYREF
unsigned int v9; // [rsp+10h] [rbp-88h] BYREF
__int64 v10; // [rsp+18h] [rbp-80h]
int v11; // [rsp+20h] [rbp-78h]
__int64 v12[2]; // [rsp+30h] [rbp-68h] BYREF
int v13; // [rsp+40h] [rbp-58h]
char v14[8]; // [rsp+50h] [rbp-48h] BYREF
__int64 v15; // [rsp+58h] [rbp-40h]
int v16; // [rsp+60h] [rbp-38h]

if ( a3 )
{
v5 = SCPI_Parameter(a1, &v9, a4);
if ( (_BYTE)v5 )
{
v12[0] = v10;
v12[1] = v10;
v13 = v11;
v6 = v9;
if ( v9 - 6 <= 5 )
{
*(_DWORD *)(a3 + 16) = 0;
*(_BYTE *)a3 = 0;
}
if ( v6 == 8 )
{
*(_BYTE *)(a3 + 20) = 2;
goto LABEL_17;
}
if ( v6 > 8 )
{
if ( v6 - 9 <= 2 )
*(_BYTE *)(a3 + 20) = 10;
}
else
{
if ( v6 == 6 )
{
*(_BYTE *)(a3 + 20) = 16;
goto LABEL_17;
}
if ( v6 == 7 )
{
*(_BYTE *)(a3 + 20) = 8;
LABEL_17:
SCPI_ParamToDouble(a1, &v9, a3 + 8);
return v5;
}
}
switch ( v6 )
{
case 6u:
case 7u:
case 8u:
case 0xAu:
goto LABEL_17;
case 9u:
scpiLex_WhiteSpace(v12, v14);
scpiLex_CharacterProgramData(v12, v14);
v5 = SCPI_ParamToChoice(a1, v14, a2, &v8);
*(_BYTE *)a3 = 1;
*(_DWORD *)(a3 + 8) = v8;
break;
case 0xBu:
scpiLex_DecimalNumericProgramData(v12, v14);
scpiLex_WhiteSpace(v12, v14);
scpiLex_SuffixProgramData(v12, v14);
SCPI_ParamToDouble(a1, &v9, a3 + 8);
v5 = transformNumber(a1, v15, v16, a3);
break;
default:
v5 = 0;
break;
}
}
}
else
{
SCPI_ErrorPush(a1, 4294966986LL);
v5 = 0;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, unsigned __int8 a4)
{
unsigned int v5; // ebp
unsigned int v6; // eax
int v8; // [rsp+Ch] [rbp-8Ch] BYREF
unsigned int v9; // [rsp+10h] [rbp-88h] BYREF
__int64 v10; // [rsp+18h] [rbp-80h]
int v11; // [rsp+20h] [rbp-78h]
__int64 v12[2]; // [rsp+30h] [rbp-68h] BYREF
int v13; // [rsp+40h] [rbp-58h]
char v14[8]; // [rsp+50h] [rbp-48h] BYREF
__int64 v15; // [rsp+58h] [rbp-40h]
int v16; // [rsp+60h] [rbp-38h]

if ( a3 )
{
v5 = SCPI_Parameter(a1, &v9, a4);
if ( (_BYTE)v5 )
{
v12[0] = v10;
v12[1] = v10;
v13 = v11;
v6 = v9;
if ( v9 - 6 <= 5 )
{
*(_DWORD *)(a3 + 16) = 0;
*(_BYTE *)a3 = 0;
}
if ( v6 == 8 )
{
*(_BYTE *)(a3 + 20) = 2;
goto LABEL_17;
}
if ( v6 > 8 )
{
if ( v6 - 9 <= 2 )
*(_BYTE *)(a3 + 20) = 10;
}
else
{
if ( v6 == 6 )
{
*(_BYTE *)(a3 + 20) = 16;
goto LABEL_17;
}
if ( v6 == 7 )
{
*(_BYTE *)(a3 + 20) = 8;
LABEL_17:
SCPI_ParamToDouble(a1, &v9, a3 + 8);
return v5;
}
}
switch ( v6 )
{
case 6u:
case 7u:
case 8u:
case 0xAu:
goto LABEL_17;
case 9u:
scpiLex_WhiteSpace(v12, v14);
scpiLex_CharacterProgramData(v12, v14);
v5 = SCPI_ParamToChoice(a1, v14, a2, &v8);
*(_BYTE *)a3 = 1;
*(_DWORD *)(a3 + 8) = v8;
break;
case 0xBu:
scpiLex_DecimalNumericProgramData(v12, v14);
scpiLex_WhiteSpace(v12, v14);
scpiLex_SuffixProgramData(v12, v14);
SCPI_ParamToDouble(a1, &v9, a3 + 8);
v5 = func2(a1, v15, v16, a3);
break;
default:
v5 = 0;
break;
}
}
}
else
{
SCPI_ErrorPush(a1, 4294966986LL);
v5 = 0;
}
return v5;
}

original_code:
scpi_bool_t SCPI_ParamNumber(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, scpi_bool_t mandatory) {
    scpi_token_t token;
    lex_state_t state;
    scpi_parameter_t param;
    scpi_bool_t result;
    int32_t tag;
    if (!value) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return 0;
    }
    result = SCPI_Parameter(context, &param, mandatory);
    if (!result) {
        return result;
    }
    state.buffer = param.ptr;
    state.pos = state.buffer;
    state.len = param.len;
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
        case SCPI_TOKEN_HEXNUM:
        case SCPI_TOKEN_OCTNUM:
        case SCPI_TOKEN_BINNUM:
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            value->unit = SCPI_UNIT_NONE;
            value->special = 0;
            result = (!0);
            break;
        default:
            break;
    }
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            value->base = 10;
            break;
        case SCPI_TOKEN_BINNUM:
            value->base = 2;
            break;
        case SCPI_TOKEN_HEXNUM:
            value->base = 16;
            break;
        case SCPI_TOKEN_OCTNUM:
            value->base = 8;
            break;
        default:
            break;
    }
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_HEXNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_OCTNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_BINNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
            scpiLex_DecimalNumericProgramData(&state, &token);
            scpiLex_WhiteSpace(&state, &token);
            scpiLex_SuffixProgramData(&state, &token);
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            result = transformNumber(context, token.ptr, token.len, value);
            break;
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            scpiLex_WhiteSpace(&state, &token);
            scpiLex_CharacterProgramData(&state, &token);
            result = SCPI_ParamToChoice(context, &token, special, &tag);
            value->special = (!0);
            value->content.tag = tag;
            break;
        default:
            result = 0;
    }
    return result;
}

canonical_original_code:
_Bool SCPI_ParamNumber(struct _scpi_t *context, struct _scpi_choice_def_t *special, struct _scpi_number_parameter_t *value, _Bool mandatory) {
    struct _scpi_token_t token;
    struct _lex_state_t state;
    struct _scpi_token_t param;
    _Bool result;
    int tag;
    if (!value) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return 0;
    }
    result = SCPI_Parameter(context, &param, mandatory);
    if (!result) {
        return result;
    }
    state.buffer = param.ptr;
    state.pos = state.buffer;
    state.len = param.len;
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
        case SCPI_TOKEN_HEXNUM:
        case SCPI_TOKEN_OCTNUM:
        case SCPI_TOKEN_BINNUM:
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            value->unit = SCPI_UNIT_NONE;
            value->special = 0;
            result = (!0);
            break;
        default:
            break;
    }
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            value->base = 10;
            break;
        case SCPI_TOKEN_BINNUM:
            value->base = 2;
            break;
        case SCPI_TOKEN_HEXNUM:
            value->base = 16;
            break;
        case SCPI_TOKEN_OCTNUM:
            value->base = 8;
            break;
        default:
            break;
    }
    switch (param.type) {
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_HEXNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_OCTNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_BINNUM:
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            break;
        case SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX:
            scpiLex_DecimalNumericProgramData(&state, &token);
            scpiLex_WhiteSpace(&state, &token);
            scpiLex_SuffixProgramData(&state, &token);
            SCPI_ParamToDouble(context, &param, &(value->content.value));
            result = transformNumber(context, token.ptr, token.len, value);
            break;
        case SCPI_TOKEN_PROGRAM_MNEMONIC:
            scpiLex_WhiteSpace(&state, &token);
            scpiLex_CharacterProgramData(&state, &token);
            result = SCPI_ParamToChoice(context, &token, special, &tag);
            value->special = (!0);
            value->content.tag = tag;
            break;
        default:
            result = 0;
    }
    return result;
}

variable_types: struct _scpi_choice_def_t { char *name; int tag; } *

variable_types: struct _scpi_token_t { enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 } type; char *ptr; int len; }

variable_types: struct _lex_state_t { char *buffer; char *pos; int len; }

variable_types: tag int

user_defined_types: enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 }


decompiled_code:
size_t __fastcall SCPI_NumberToStr(__int64 a1, __int64 a2, __int64 a3, char *a4, size_t a5)
{
size_t v8; // r14
const char *v9; // r12
char *src; // [rsp+8h] [rbp-30h] BYREF

if ( a5 == 0 || a4 == 0LL || !a3 )
return 0LL;
if ( *(_BYTE *)a3 )
{
if ( (unsigned __int8)SCPI_ChoiceToName(a2, *(unsigned int *)(a3 + 8), &src) )
{
strncpy(a4, src, a5);
v8 = strnlen(a4, a5 - 1);
a4[v8] = 0;
}
else
{
*a4 = 0;
v8 = 0LL;
}
}
else
{
v8 = SCPI_DoubleToStr(a4, a5, *(double *)(a3 + 8));
if ( v8 + 1 < a5 )
{
v9 = (const char *)translateUnitInverse(*(__int64 **)(a1 + 160), *(_DWORD *)(a3 + 16));
if ( v9 )
{
strncat(a4, " ", a5 - v8);
if ( v8 + 2 < a5 )
strncat(a4, v9, a5 - v8 - 1);
v8 = strlen(a4);
}
}
}
return v8;
}

canonical_decompiled_code:
size_t __fastcall func4(__int64 a1, __int64 a2, __int64 a3, char *a4, size_t a5)
{
size_t v8; // r14
const char *v9; // r12
char *src; // [rsp+8h] [rbp-30h] BYREF

if ( a5 == 0 || a4 == 0LL || !a3 )
return 0LL;
if ( *(_BYTE *)a3 )
{
if ( (unsigned __int8)SCPI_ChoiceToName(a2, *(unsigned int *)(a3 + 8), &src) )
{
strncpy(a4, src, a5);
v8 = strnlen(a4, a5 - 1);
a4[v8] = 0;
}
else
{
*a4 = 0;
v8 = 0LL;
}
}
else
{
v8 = SCPI_DoubleToStr(a4, a5, *(double *)(a3 + 8));
if ( v8 + 1 < a5 )
{
v9 = (const char *)func0(*(__int64 **)(a1 + 160), *(_DWORD *)(a3 + 16));
if ( v9 )
{
strncat(a4, " ", a5 - v8);
if ( v8 + 2 < a5 )
strncat(a4, v9, a5 - v8 - 1);
v8 = strlen(a4);
}
}
}
return v8;
}

original_code:
size_t SCPI_NumberToStr(scpi_t * context, const scpi_choice_def_t * special, scpi_number_t * value, char * str, size_t len) {
    const char * type;
    const char * unit;
    size_t result;
    if (!value || !str || len==0) {
        return 0;
    }
    if (value->special) {
        if (SCPI_ChoiceToName(special, value->content.tag, &type)) {
            strncpy(str, type, len);
            result = strnlen((str), (len - 1));
            str[result] = '\0';
            return result;
        } else {
            str[0] = '\0';
            return 0;
        }
    }
    result = SCPI_DoubleToStr(value->content.value, str, len);
    if (result + 1 < len) {
        unit = translateUnitInverse(context->units, value->unit);
        if (unit) {
            strncat(str, " ", len - result);
            if (result + 2 < len) {
                strncat(str, unit, len - result - 1);
            }
            result = strlen(str);
        }
    }
    return result;
}

canonical_original_code:
unsigned long SCPI_NumberToStr(struct _scpi_t *context, struct _scpi_choice_def_t *special, struct _scpi_number_parameter_t *value, char *str, unsigned long len) {
    char *type;
    char *unit;
    unsigned long result;
    if (!value || !str || len==0) {
        return 0;
    }
    if (value->special) {
        if (SCPI_ChoiceToName(special, value->content.tag, &type)) {
            strncpy(str, type, len);
            result = strnlen((str), (len - 1));
            str[result] = '\0';
            return result;
        } else {
            str[0] = '\0';
            return 0;
        }
    }
    result = SCPI_DoubleToStr(value->content.value, str, len);
    if (result + 1 < len) {
        unit = translateUnitInverse(context->units, value->unit);
        if (unit) {
            strncat(str, " ", len - result);
            if (result + 2 < len) {
                strncat(str, unit, len - result - 1);
            }
            result = strlen(str);
        }
    }
    return result;
}

variable_types: struct _scpi_t { struct _scpi_command_t { char *pattern; enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*callback)(struct _scpi_t *); int tag; } *cmdlist; struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; } buffer; struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t { char *buffer; char *pos; int len; } lex_state; struct _scpi_const_buffer_t { unsigned long length; unsigned long position; char *data; } cmd_raw; } param_list; struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 } ctrl, unsigned short val); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*flush)(struct _scpi_t *); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*reset)(struct _scpi_t *); } *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t { short error_code; char *device_dependent_info; } *data; } error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t { char *name; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; double mult; } *units; void *user_context; struct _scpi_parser_state_t { struct _scpi_token_t { enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 } type; char *ptr; int len; } programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 } termination; } parser_state; char *idn[4]; unsigned long arbitrary_remaining; } *

variable_types:
str
char *

variable_types:
type
char *

variable_types:
result
unsigned long

return_type: unsigned long

user_defined_types: struct _scpi_choice_def_t { char *name; int tag; }


numericRange

decompiled_code:
__int64 __fastcall numericRange(__int64 a1, _BYTE *a2, __int64 a3, __int64 a4)
{
int v5; // edx
__int64 result; // rax

v5 = scpiLex_DecimalNumericProgramData(a1, a3);
result = 2LL;
if ( v5 )
{
if ( (unsigned int)scpiLex_Colon(a1, a4) )
{
*a2 = 1;
result = (unsigned int)scpiLex_DecimalNumericProgramData(a1, a4) == 0;
}
else
{
*a2 = 0;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _BYTE *a2, __int64 a3, __int64 a4)
{
int v5; // edx
__int64 result; // rax

v5 = scpiLex_DecimalNumericProgramData(a1, a3);
result = 2LL;
if ( v5 )
{
if ( (unsigned int)scpiLex_Colon(a1, a4) )
{
*a2 = 1;
result = (unsigned int)scpiLex_DecimalNumericProgramData(a1, a4) == 0;
}
else
{
*a2 = 0;
result = 0LL;
}
}
return result;
}

original_code:
static scpi_expr_result_t numericRange(lex_state_t * state, scpi_bool_t * isRange, scpi_token_t * valueFrom, scpi_token_t * valueTo) {
    if (scpiLex_DecimalNumericProgramData(state, valueFrom)) {
        if (scpiLex_Colon(state, valueTo)) {
            *isRange = (!0);
            if (scpiLex_DecimalNumericProgramData(state, valueTo)) {
                return SCPI_EXPR_OK;
            } else {
                return SCPI_EXPR_ERROR;
            }
        } else {
            *isRange = 0;
            return SCPI_EXPR_OK;
        }
    }
    return SCPI_EXPR_NO_MORE;
}

canonical_original_code:
static enum _scpi_expr_result_t numericRange(struct _lex_state_t *state, _Bool *isRange, struct _scpi_token_t *valueFrom, struct _scpi_token_t *valueTo) {
    if (scpiLex_DecimalNumericProgramData(state, valueFrom)) {
        if (scpiLex_Colon(state, valueTo)) {
            *isRange = (!0);
            if (scpiLex_DecimalNumericProgramData(state, valueTo)) {
                return SCPI_EXPR_OK;
            } else {
                return SCPI_EXPR_ERROR;
            }
        } else {
            *isRange = 0;
            return SCPI_EXPR_OK;
        }
    }
    return SCPI_EXPR_NO_MORE;
}

variable_types: struct _lex_state_t { char *buffer; char *pos; int len; } *

variable_types:
isRange
_Bool *

variable_types: struct _scpi_token_t { enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 } type; char *ptr; int len; } *

variable_types:
valueTo
struct _scpi_token_t *

return_type: enum _scpi_expr_result_t { SCPI_EXPR_OK=0, SCPI_EXPR_ERROR=1, SCPI_EXPR_NO_MORE=2 }


channelSpec

decompiled_code:
__int64 __fastcall channelSpec(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4, _QWORD *a5)
{
unsigned __int64 v8; // rbx
_BYTE v10[88]; // [rsp+0h] [rbp-58h] BYREF

v8 = 0LL;
while ( (unsigned int)scpiLex_DecimalNumericProgramData(a2, v10) )
{
if ( v8 < a4 )
SCPI_ParamToInt32(a1, v10, a3);
a3 += 4LL;
if ( !(unsigned int)scpiLex_SpecificCharacter(a2, v10, 33LL) )
{
*a5 = v8 + 1;
return 0LL;
}
++v8;
}
return (unsigned int)(v8 == 0) + 1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4, _QWORD *a5)
{
unsigned __int64 v8; // rbx
_BYTE v10[88]; // [rsp+0h] [rbp-58h] BYREF

v8 = 0LL;
while ( (unsigned int)scpiLex_DecimalNumericProgramData(a2, v10) )
{
if ( v8 < a4 )
SCPI_ParamToInt32(a1, v10, a3);
a3 += 4LL;
if ( !(unsigned int)scpiLex_SpecificCharacter(a2, v10, 33LL) )
{
*a5 = v8 + 1;
return 0LL;
}
++v8;
}
return (unsigned int)(v8 == 0) + 1;
}

original_code:
static scpi_expr_result_t channelSpec(scpi_t * context, lex_state_t * state, int32_t * values, size_t length, size_t * dimensions) {
    scpi_parameter_t param;
    size_t i = 0;
    while (scpiLex_DecimalNumericProgramData(state, &param)) {
        if (i < length) {
            SCPI_ParamToInt32(context, &param, &values[i]);
        }
        if (scpiLex_SpecificCharacter(state, &param, '!')) {
            i++;
        } else {
            *dimensions = i + 1;
            return SCPI_EXPR_OK;
        }
    }
    if (i == 0) {
        return SCPI_EXPR_NO_MORE;
    } else {
        return SCPI_EXPR_ERROR;
    }
}

canonical_original_code:
static enum _scpi_expr_result_t channelSpec(struct _scpi_t *context, struct _lex_state_t *state, int *values, unsigned long length, unsigned long *dimensions) {
    struct _scpi_token_t param;
    unsigned long i = 0;
    while (scpiLex_DecimalNumericProgramData(state, &param)) {
        if (i < length) {
            SCPI_ParamToInt32(context, &param, &values[i]);
        }
        if (scpiLex_SpecificCharacter(state, &param, '!')) {
            i++;
        } else {
            *dimensions = i + 1;
            return SCPI_EXPR_OK;
        }
    }
    if (i == 0) {
        return SCPI_EXPR_NO_MORE;
    } else {
        return SCPI_EXPR_ERROR;
    }
}

variable_types:
state
struct _lex_state_t *

variable_types:
values
int *

variable_types:
length
unsigned long

variable_types:
dimensions
unsigned long *

variable_types:
i
unsigned long

user_defined_types: enum _scpi_expr_result_t { SCPI_EXPR_OK=0, SCPI_EXPR_ERROR=1, SCPI_EXPR_NO_MORE=2 }

user_defined_types: enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 }

user_defined_types: enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 }

user_defined_types: enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 }


channelRange

decompiled_code:
__int64 __fastcall channelRange(__int64 a1, __int64 a2, _BYTE *a3, __int64 a4, __int64 a5, unsigned __int64 a6, _QWORD *a7)
{
unsigned int v10; // eax
unsigned int v11; // ebx
__int64 v13; // [rsp+0h] [rbp-68h] BYREF
__int64 v14; // [rsp+8h] [rbp-60h] BYREF
char v15[88]; // [rsp+10h] [rbp-58h] BYREF

v10 = channelSpec(a1, a2, a4, a6, &v14);
v11 = v10;
if ( v10 )
{
if ( v10 == 2 )
v11 = 1;
}
else if ( (unsigned int)scpiLex_Colon(a2, v15) )
{
*a3 = 1;
v11 = channelSpec(a1, a2, a5, a6, &v13);
if ( v11 )
{
v11 = 1;
}
else if ( v14 == v13 )
{
*a7 = v14;
}
else
{
v11 = 1;
}
}
else
{
*a3 = 0;
*a7 = v14;
}
return v11;
}

original_code:
static scpi_expr_result_t channelRange(scpi_t * context, lex_state_t * state, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) {
    scpi_token_t token;
    scpi_expr_result_t err;
    size_t fromDimensions;
    size_t toDimensions;
    err = channelSpec(context, state, valuesFrom, length, &fromDimensions);
    if (err == SCPI_EXPR_OK) {
        if (scpiLex_Colon(state, &token)) {
            *isRange = (!0);
            err = channelSpec(context, state, valuesTo, length, &toDimensions);
            if (err != SCPI_EXPR_OK) {
                return SCPI_EXPR_ERROR;
            }
            if (fromDimensions != toDimensions) {
                return SCPI_EXPR_ERROR;
            }
            *dimensions = fromDimensions;
        } else {
            *isRange = 0;
            *dimensions = fromDimensions;
            return SCPI_EXPR_OK;
        }
    } else if (err == SCPI_EXPR_NO_MORE) {
        err = SCPI_EXPR_ERROR;
    }
    return err;
}

canonical_original_code:
static enum _scpi_expr_result_t channelRange(struct _scpi_t *context, struct _lex_state_t *state, _Bool *isRange, int *valuesFrom, int *valuesTo, unsigned long length, unsigned long *dimensions) {
    struct _scpi_token_t token;
    enum _scpi_expr_result_t err;
    unsigned long fromDimensions;
    unsigned long toDimensions;
    err = channelSpec(context, state, valuesFrom, length, &fromDimensions);
    if (err == SCPI_EXPR_OK) {
        if (scpiLex_Colon(state, &token)) {
            *isRange = (!0);
            err = channelSpec(context, state, valuesTo, length, &toDimensions);
            if (err != SCPI_EXPR_OK) {
                return SCPI_EXPR_ERROR;
            }
            if (fromDimensions != toDimensions) {
                return SCPI_EXPR_ERROR;
            }
            *dimensions = fromDimensions;
        } else {
            *isRange = 0;
            *dimensions = fromDimensions;
            return SCPI_EXPR_OK;
        }
    } else if (err == SCPI_EXPR_NO_MORE) {
        err = SCPI_EXPR_ERROR;
    }
    return err;
}

variable_types:
valuesFrom
int *

variable_types:
valuesTo
int *

variable_types: enum _scpi_expr_result_t { SCPI_EXPR_OK=0, SCPI_EXPR_ERROR=1, SCPI_EXPR_NO_MORE=2 }

variable_types:
fromDimensions
unsigned long

variable_types:
toDimensions
unsigned long

user_defined_types: struct _scpi_t { struct _scpi_command_t *cmdlist; struct _scpi_buffer_t buffer; struct _scpi_param_list_t param_list; struct _scpi_interface_t *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t *units; void *user_context; struct _scpi_parser_state_t parser_state; char *idn[4]; unsigned long arbitrary_remaining; }

user_defined_types: struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t lex_state; struct _scpi_const_buffer_t cmd_raw; }

user_defined_types: struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t *data; }

user_defined_types: enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 }