decompiled_code:
__int64 __fastcall SCPI_ExprNumericListEntry(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6)
{
int v10; // ebx
__int64 result; // rax
int v12; // edx
__int64 v13[2]; // [rsp+0h] [rbp-58h] BYREF
int v14; // [rsp+10h] [rbp-48h]

if ( a4 && a5 && a6 && a2 )
{
if ( *(_DWORD *)a2 == 16 )
{
v13[0] = *(_QWORD *)(a2 + 8) + 1LL;
v13[1] = v13[0];
v14 = *(_DWORD *)(a2 + 16) - 2;
if ( a3 < 0 )
{
LABEL_19:
result = 0LL;
}
else
{
v10 = 0;
while ( 1 )
{
result = numericRange((__int64)v13, a4, a5, a6);
if ( (_DWORD)result )
break;
if ( a3 != v10 && !(unsigned int)scpiLex_Comma(v13, a5) )
{
v12 = scpiLex_IsEos(v13);
result = 2LL;
if ( v12 )
return result;
goto LABEL_18;
}
if ( a3 < ++v10 )
goto LABEL_19;
}
if ( (_DWORD)result != 1 )
return result;
LABEL_18:
SCPI_ErrorPush(a1, 4294967126LL);
result = 1LL;
}
}
else
{
SCPI_ErrorPush(a1, 4294967192LL);
result = 1LL;
}
}
else
{
SCPI_ErrorPush(a1, 4294966986LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6)
{
int v10; // ebx
__int64 result; // rax
int v12; // edx
__int64 v13[2]; // [rsp+0h] [rbp-58h] BYREF
int v14; // [rsp+10h] [rbp-48h]

if ( a4 && a5 && a6 && a2 )
{
if ( *(_DWORD *)a2 == 16 )
{
v13[0] = *(_QWORD *)(a2 + 8) + 1LL;
v13[1] = v13[0];
v14 = *(_DWORD *)(a2 + 16) - 2;
if ( a3 < 0 )
{
LABEL_19:
result = 0LL;
}
else
{
v10 = 0;
while ( 1 )
{
result = func0((__int64)v13, a4, a5, a6);
if ( (_DWORD)result )
break;
if ( a3 != v10 && !(unsigned int)scpiLex_Comma(v13, a5) )
{
v12 = scpiLex_IsEos(v13);
result = 2LL;
if ( v12 )
return result;
goto LABEL_18;
}
if ( a3 < ++v10 )
goto LABEL_19;
}
if ( (_DWORD)result != 1 )
return result;
LABEL_18:
SCPI_ErrorPush(a1, 4294967126LL);
result = 1LL;
}
}
else
{
SCPI_ErrorPush(a1, 4294967192LL);
result = 1LL;
}
}
else
{
SCPI_ErrorPush(a1, 4294966986LL);
result = 1LL;
}
return result;
}

original_code:
scpi_expr_result_t SCPI_ExprNumericListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, scpi_parameter_t * valueFrom, scpi_parameter_t * valueTo) {
    lex_state_t lex;
    int i;
    scpi_expr_result_t res = SCPI_EXPR_OK;
    if (!isRange || !valueFrom || !valueTo || !param) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return SCPI_EXPR_ERROR;
    }
    if (param->type != SCPI_TOKEN_PROGRAM_EXPRESSION) {
        SCPI_ErrorPush(context, SCPI_ERROR_DATA_TYPE_ERROR);
        return SCPI_EXPR_ERROR;
    }
    lex.buffer = param->ptr + 1;
    lex.pos = lex.buffer;
    lex.len = param->len - 2;
    for (i = 0; i <= index; i++) {
        res = numericRange(&lex, isRange, valueFrom, valueTo);
        if (res != SCPI_EXPR_OK) {
            break;
        }
        if (i != index) {
            if (!scpiLex_Comma(&lex, valueFrom)) {
                res = scpiLex_IsEos(&lex) ? SCPI_EXPR_NO_MORE : SCPI_EXPR_ERROR;
                break;
            }
        }
    }
    if (res == SCPI_EXPR_ERROR) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
    }
    return res;
}

canonical_original_code:
enum _scpi_expr_result_t SCPI_ExprNumericListEntry(struct _scpi_t *context, struct _scpi_token_t *param, int index, _Bool *isRange, struct _scpi_token_t *valueFrom, struct _scpi_token_t *valueTo) {
    struct _lex_state_t lex;
    int i;
    enum _scpi_expr_result_t res = SCPI_EXPR_OK;
    if (!isRange || !valueFrom || !valueTo || !param) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return SCPI_EXPR_ERROR;
    }
    if (param->type != SCPI_TOKEN_PROGRAM_EXPRESSION) {
        SCPI_ErrorPush(context, SCPI_ERROR_DATA_TYPE_ERROR);
        return SCPI_EXPR_ERROR;
    }
    lex.buffer = param->ptr + 1;
    lex.pos = lex.buffer;
    lex.len = param->len - 2;
    for (i = 0; i <= index; i++) {
        res = numericRange(&lex, isRange, valueFrom, valueTo);
        if (res != SCPI_EXPR_OK) {
            break;
        }
        if (i != index) {
            if (!scpiLex_Comma(&lex, valueFrom)) {
                res = scpiLex_IsEos(&lex) ? SCPI_EXPR_NO_MORE : SCPI_EXPR_ERROR;
                break;
            }
        }
    }
    if (res == SCPI_EXPR_ERROR) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
    }
    return res;
}

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:
param
struct _scpi_token_t *

variable_types: index int

variable_types:
valueFrom
struct _scpi_token_t *

variable_types: i int

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


decompiled_code:
__int64 __fastcall SCPI_ExprNumericListEntryInt(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6)
{
unsigned int v9; // ebx
_BYTE v11[32]; // [rsp+0h] [rbp-68h] BYREF
char v12[31]; // [rsp+20h] [rbp-48h] BYREF
char v13[41]; // [rsp+3Fh] [rbp-29h] BYREF

v13[0] = 0;
v9 = SCPI_ExprNumericListEntry(a1, a2, a3, v13, (__int64)v12, (__int64)v11);
if ( !v9 )
{
*a4 = v13[0];
SCPI_ParamToInt32(a1, v12, a5);
if ( v13[0] )
SCPI_ParamToInt32(a1, v11, a6);
}
return v9;
}

original_code:
scpi_expr_result_t SCPI_ExprNumericListEntryInt(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valueFrom, int32_t * valueTo) {
    scpi_expr_result_t res;
    scpi_bool_t range = 0;
    scpi_parameter_t paramFrom;
    scpi_parameter_t paramTo;
    res = SCPI_ExprNumericListEntry(context, param, index, &range, &paramFrom, &paramTo);
    if (res == SCPI_EXPR_OK) {
        *isRange = range;
        SCPI_ParamToInt32(context, &paramFrom, valueFrom);
        if (range) {
            SCPI_ParamToInt32(context, &paramTo, valueTo);
        }
    }
    return res;
}

canonical_original_code:
enum _scpi_expr_result_t SCPI_ExprNumericListEntryInt(struct _scpi_t *context, struct _scpi_token_t *param, int index, _Bool *isRange, int *valueFrom, int *valueTo) {
    enum _scpi_expr_result_t res;
    _Bool range = 0;
    struct _scpi_token_t paramFrom;
    struct _scpi_token_t paramTo;
    res = SCPI_ExprNumericListEntry(context, param, index, &range, &paramFrom, &paramTo);
    if (res == SCPI_EXPR_OK) {
        *isRange = range;
        SCPI_ParamToInt32(context, &paramFrom, valueFrom);
        if (range) {
            SCPI_ParamToInt32(context, &paramTo, valueTo);
        }
    }
    return res;
}

variable_types:
isRange
_Bool *

variable_types:
valueFrom
int *

variable_types:
valueTo
int *

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

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

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

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_buffer_t { unsigned long length; unsigned long position; char *data; }

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 _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: enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 }

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


decompiled_code:
__int64 __fastcall SCPI_ExprNumericListEntryDouble(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6)
{
unsigned int v9; // ebx
_BYTE v11[32]; // [rsp+0h] [rbp-68h] BYREF
char v12[31]; // [rsp+20h] [rbp-48h] BYREF
char v13[41]; // [rsp+3Fh] [rbp-29h] BYREF

v13[0] = 0;
v9 = SCPI_ExprNumericListEntry(a1, a2, a3, v13, (__int64)v12, (__int64)v11);
if ( !v9 )
{
*a4 = v13[0];
SCPI_ParamToDouble(a1, v12, a5);
if ( v13[0] )
SCPI_ParamToDouble(a1, v11, a6);
}
return v9;
}

original_code:
scpi_expr_result_t SCPI_ExprNumericListEntryDouble(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, double * valueFrom, double * valueTo) {
    scpi_expr_result_t res;
    scpi_bool_t range = 0;
    scpi_parameter_t paramFrom;
    scpi_parameter_t paramTo;
    res = SCPI_ExprNumericListEntry(context, param, index, &range, &paramFrom, &paramTo);
    if (res == SCPI_EXPR_OK) {
        *isRange = range;
        SCPI_ParamToDouble(context, &paramFrom, valueFrom);
        if (range) {
            SCPI_ParamToDouble(context, &paramTo, valueTo);
        }
    }
    return res;
}

canonical_original_code:
enum _scpi_expr_result_t SCPI_ExprNumericListEntryDouble(struct _scpi_t *context, struct _scpi_token_t *param, int index, _Bool *isRange, double *valueFrom, double *valueTo) {
    enum _scpi_expr_result_t res;
    _Bool range = 0;
    struct _scpi_token_t paramFrom;
    struct _scpi_token_t paramTo;
    res = SCPI_ExprNumericListEntry(context, param, index, &range, &paramFrom, &paramTo);
    if (res == SCPI_EXPR_OK) {
        *isRange = range;
        SCPI_ParamToDouble(context, &paramFrom, valueFrom);
        if (range) {
            SCPI_ParamToDouble(context, &paramTo, valueTo);
        }
    }
    return res;
}

variable_types:
valueFrom
double *

variable_types:
valueTo
double *

return_type: 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 }


decompiled_code:
__int64 __fastcall SCPI_ExprChannelListEntry(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6, unsigned __int64 a7, _QWORD *a8)
{
__int64 result; // rax
int v12; // ebx
int v13; // edx
char v15[32]; // [rsp+10h] [rbp-78h] BYREF
__int64 v16[2]; // [rsp+30h] [rbp-58h] BYREF
int v17; // [rsp+40h] [rbp-48h]

if ( a8 == 0LL || a2 == 0 || !a4 || a7 && (!a5 || !a6) )
{
SCPI_ErrorPush(a1, 4294966986LL);
return 1LL;
}
if ( *(_DWORD *)a2 != 16 )
{
SCPI_ErrorPush(a1, 4294967192LL);
return 1LL;
}
v16[0] = *(_QWORD *)(a2 + 8) + 1LL;
v16[1] = v16[0];
v17 = *(_DWORD *)(a2 + 16) - 2;
if ( !(unsigned int)scpiLex_SpecificCharacter(v16, v15, 64LL) )
goto LABEL_25;
v12 = 0;
if ( a3 < 0 )
return 0LL;
while ( a3 == v12 )
{
result = channelRange(a1, (__int64)v16, a4, a5, a6, a7, a8);
if ( (_DWORD)result )
goto LABEL_14;
LABEL_19:
if ( a3 < ++v12 )
return 0LL;
}
result = channelRange(a1, (__int64)v16, a4, a5, a6, 0LL, a8);
if ( !(_DWORD)result )
{
if ( !(unsigned int)scpiLex_Comma(v16, v15) )
{
if ( !(unsigned int)scpiLex_IsEos(v16) )
goto LABEL_25;
goto LABEL_24;
}
goto LABEL_19;
}
LABEL_14:
if ( (_DWORD)result == 1 )
goto LABEL_25;
if ( (_DWORD)result != 2 )
return result;
LABEL_24:
v13 = scpiLex_IsEos(v16);
result = 2LL;
if ( v13 )
return result;
LABEL_25:
SCPI_ErrorPush(a1, 4294967126LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, int a3, _BYTE *a4, __int64 a5, __int64 a6, unsigned __int64 a7, _QWORD *a8)
{
__int64 result; // rax
int v12; // ebx
int v13; // edx
char v15[32]; // [rsp+10h] [rbp-78h] BYREF
__int64 v16[2]; // [rsp+30h] [rbp-58h] BYREF
int v17; // [rsp+40h] [rbp-48h]

if ( a8 == 0LL || a2 == 0 || !a4 || a7 && (!a5 || !a6) )
{
SCPI_ErrorPush(a1, 4294966986LL);
return 1LL;
}
if ( *(_DWORD *)a2 != 16 )
{
SCPI_ErrorPush(a1, 4294967192LL);
return 1LL;
}
v16[0] = *(_QWORD *)(a2 + 8) + 1LL;
v16[1] = v16[0];
v17 = *(_DWORD *)(a2 + 16) - 2;
if ( !(unsigned int)scpiLex_SpecificCharacter(v16, v15, 64LL) )
goto LABEL_25;
v12 = 0;
if ( a3 < 0 )
return 0LL;
while ( a3 == v12 )
{
result = func2(a1, (__int64)v16, a4, a5, a6, a7, a8);
if ( (_DWORD)result )
goto LABEL_14;
LABEL_19:
if ( a3 < ++v12 )
return 0LL;
}
result = func2(a1, (__int64)v16, a4, a5, a6, 0LL, a8);
if ( !(_DWORD)result )
{
if ( !(unsigned int)scpiLex_Comma(v16, v15) )
{
if ( !(unsigned int)scpiLex_IsEos(v16) )
goto LABEL_25;
goto LABEL_24;
}
goto LABEL_19;
}
LABEL_14:
if ( (_DWORD)result == 1 )
goto LABEL_25;
if ( (_DWORD)result != 2 )
return result;
LABEL_24:
v13 = scpiLex_IsEos(v16);
result = 2LL;
if ( v13 )
return result;
LABEL_25:
SCPI_ErrorPush(a1, 4294967126LL);
return 1LL;
}

original_code:
scpi_expr_result_t SCPI_ExprChannelListEntry(scpi_t * context, scpi_parameter_t * param, int index, scpi_bool_t * isRange, int32_t * valuesFrom, int32_t * valuesTo, size_t length, size_t * dimensions) {
    lex_state_t lex;
    int i;
    scpi_expr_result_t res = SCPI_EXPR_OK;
    scpi_token_t token;
    if (!isRange || !param || !dimensions || (length && (!valuesFrom || !valuesTo))) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return SCPI_EXPR_ERROR;
    }
    if (param->type != SCPI_TOKEN_PROGRAM_EXPRESSION) {
        SCPI_ErrorPush(context, SCPI_ERROR_DATA_TYPE_ERROR);
        return SCPI_EXPR_ERROR;
    }
    lex.buffer = param->ptr + 1;
    lex.pos = lex.buffer;
    lex.len = param->len - 2;
    if (!scpiLex_SpecificCharacter(&lex, &token, '@')) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
        return SCPI_EXPR_ERROR;
    }
    for (i = 0; i <= index; i++) {
        res = channelRange(context, &lex, isRange, valuesFrom, valuesTo, (i == index) ? length : 0, dimensions);
        if (res != SCPI_EXPR_OK) {
            break;
        }
        if (i != index) {
            if (!scpiLex_Comma(&lex, &token)) {
                res = scpiLex_IsEos(&lex) ? SCPI_EXPR_NO_MORE : SCPI_EXPR_ERROR;
                break;
            }
        }
    }
    if (res == SCPI_EXPR_ERROR) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
    }
    if (res == SCPI_EXPR_NO_MORE) {
        if (!scpiLex_IsEos(&lex)) {
            res = SCPI_EXPR_ERROR;
            SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
        }
    }
    return res;
}

canonical_original_code:
enum _scpi_expr_result_t SCPI_ExprChannelListEntry(struct _scpi_t *context, struct _scpi_token_t *param, int index, _Bool *isRange, int *valuesFrom, int *valuesTo, unsigned long length, unsigned long *dimensions) {
    struct _lex_state_t lex;
    int i;
    enum _scpi_expr_result_t res = SCPI_EXPR_OK;
    struct _scpi_token_t token;
    if (!isRange || !param || !dimensions || (length && (!valuesFrom || !valuesTo))) {
        SCPI_ErrorPush(context, SCPI_ERROR_SYSTEM_ERROR);
        return SCPI_EXPR_ERROR;
    }
    if (param->type != SCPI_TOKEN_PROGRAM_EXPRESSION) {
        SCPI_ErrorPush(context, SCPI_ERROR_DATA_TYPE_ERROR);
        return SCPI_EXPR_ERROR;
    }
    lex.buffer = param->ptr + 1;
    lex.pos = lex.buffer;
    lex.len = param->len - 2;
    if (!scpiLex_SpecificCharacter(&lex, &token, '@')) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
        return SCPI_EXPR_ERROR;
    }
    for (i = 0; i <= index; i++) {
        res = channelRange(context, &lex, isRange, valuesFrom, valuesTo, (i == index) ? length : 0, dimensions);
        if (res != SCPI_EXPR_OK) {
            break;
        }
        if (i != index) {
            if (!scpiLex_Comma(&lex, &token)) {
                res = scpiLex_IsEos(&lex) ? SCPI_EXPR_NO_MORE : SCPI_EXPR_ERROR;
                break;
            }
        }
    }
    if (res == SCPI_EXPR_ERROR) {
        SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
    }
    if (res == SCPI_EXPR_NO_MORE) {
        if (!scpiLex_IsEos(&lex)) {
            res = SCPI_EXPR_ERROR;
            SCPI_ErrorPush(context, SCPI_ERROR_EXPRESSION_PARSING_ERROR);
        }
    }
    return res;
}

variable_types:
valuesFrom
int *

variable_types:
valuesTo
int *

variable_types:
length
unsigned long

variable_types:
dimensions
unsigned long *

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

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

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


createServer

decompiled_code:
__int64 __fastcall createServer(__int16 a1)
{
int v1; // eax
unsigned int v2; // ebx
struct sockaddr v4; // [rsp+0h] [rbp-28h] BYREF
int optval[3]; // [rsp+1Ch] [rbp-Ch] BYREF

optval[0] = 1;
*(_DWORD *)&v4.sa_data[10] = 0;
v4.sa_family = 2;
*(_QWORD *)&v4.sa_data[2] = (unsigned int)_bswap_32(0);
*(_WORD *)v4.sa_data = _bswap_16(a1);
v1 = socket(2, 1, 0);
if ( v1 < 0 )
{
perror("socket() failed");
exit(-1);
}
v2 = v1;
if ( setsockopt(v1, 1, 2, optval, 4u) < 0 )
{
perror("setsockopt() failed");
close(v2);
exit(-1);
}
if ( ioctl(v2, 0x5421uLL, optval) < 0 )
{
perror("ioctl() failed");
close(v2);
exit(-1);
}
if ( bind(v2, &v4, 0x10u) < 0 )
{
perror("bind() failed");
close(v2);
exit(-1);
}
listen(v2, 1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int16 a1)
{
int v1; // eax
unsigned int v2; // ebx
struct sockaddr v4; // [rsp+0h] [rbp-28h] BYREF
int optval[3]; // [rsp+1Ch] [rbp-Ch] BYREF

optval[0] = 1;
*(_DWORD *)&v4.sa_data[10] = 0;
v4.sa_family = 2;
*(_QWORD *)&v4.sa_data[2] = (unsigned int)func1(0);
*(_WORD *)v4.sa_data = func2(a1);
v1 = socket(2, 1, 0);
if ( v1 < 0 )
{
perror("socket() failed");
exit(-1);
}
v2 = v1;
if ( setsockopt(v1, 1, 2, optval, 4u) < 0 )
{
perror("setsockopt() failed");
close(v2);
exit(-1);
}
if ( ioctl(v2, 0x5421uLL, optval) < 0 )
{
perror("ioctl() failed");
close(v2);
exit(-1);
}
if ( bind(v2, &v4, 0x10u) < 0 )
{
perror("bind() failed");
close(v2);
exit(-1);
}
listen(v2, 1);
return v2;
}

original_code:
static int createServer(int port) {
    int fd;
    int rc;
    int on = 1;
    struct sockaddr_in servaddr;
    memset(&servaddr, 0, sizeof (servaddr));
    servaddr.sin_family = 2;
    servaddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    servaddr.sin_port = htons(port);
    fd = socket(2, SOCK_STREAM, 0);
    if (fd < 0) {
        perror("socket() failed");
        exit(-1);
    }
    rc = setsockopt(fd, 1, 2, (char *) &on, sizeof (on));
    if (rc < 0) {
        perror("setsockopt() failed");
        close(fd);
        exit(-1);
    }
    rc = ioctl(fd, 0x5421, (char *) &on);
    if (rc < 0) {
        perror("ioctl() failed");
        close(fd);
        exit(-1);
    }
    rc = bind(fd, (struct sockaddr *) &servaddr, sizeof (servaddr));
    if (rc < 0) {
        perror("bind() failed");
        close(fd);
        exit(-1);
    }
    listen(fd, 1);
    if (rc < 0) {
        perror("listen() failed");
        close(fd);
        exit(-1);
    }
    return fd;
}

canonical_original_code:
static int createServer(int port) {
    int fd;
    int rc;
    int on = 1;
    struct sockaddr_in servaddr;
    memset(&servaddr, 0, sizeof (servaddr));
    servaddr.sin_family = 2;
    servaddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    servaddr.sin_port = htons(port);
    fd = socket(2, SOCK_STREAM, 0);
    if (fd < 0) {
        perror("socket() failed");
        exit(-1);
    }
    rc = setsockopt(fd, 1, 2, (char *) &on, sizeof (on));
    if (rc < 0) {
        perror("setsockopt() failed");
        close(fd);
        exit(-1);
    }
    rc = ioctl(fd, 0x5421, (char *) &on);
    if (rc < 0) {
        perror("ioctl() failed");
        close(fd);
        exit(-1);
    }
    rc = bind(fd, (struct sockaddr *) &servaddr, sizeof (servaddr));
    if (rc < 0) {
        perror("bind() failed");
        close(fd);
        exit(-1);
    }
    listen(fd, 1);
    if (rc < 0) {
        perror("listen() failed");
        close(fd);
        exit(-1);
    }
    return fd;
}

variable_types: port int

variable_types: fd int

variable_types: rc int

variable_types: on int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

return_type: int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


waitServer

original_code:
static int waitServer(int fd) {
    fd_set fds;
    struct timeval timeout;
    int rc;
    int max_fd;
    do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fds)->__fds_bits)[0]) : "memory"); } while (0);
    max_fd = fd;
    ((void) (((&fds)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
    timeout.tv_sec = 5;
    timeout.tv_usec = 0;
    rc = select(max_fd + 1, &fds, ((void *)0), ((void *)0), &timeout);
    return rc;
}

canonical_original_code:
static int waitServer(int fd) {
    struct fd_set fds;
    struct timeval timeout;
    int rc;
    int max_fd;
    do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fds)->__fds_bits)[0]) : "memory"); } while (0);
    max_fd = fd;
    ((void) (((&fds)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
    timeout.tv_sec = 5;
    timeout.tv_usec = 0;
    rc = select(max_fd + 1, &fds, ((void *)0), ((void *)0), &timeout);
    return rc;
}

variable_types:
fds
struct fd_set { long __fds_bits[-1]; }

variable_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall SCPI_Error(__int64 a1, __int16 a2)
{
const char *v2; // rax

v2 = (const char *)SCPI_ErrorTranslate((unsigned int)a2);
fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (unsigned int)a2, v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int16 a2)
{
const char *v2; // rax

v2 = (const char *)SCPI_ErrorTranslate((unsigned int)a2);
fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (unsigned int)a2, v2);
return 0LL;
}

original_code:
int SCPI_Error(scpi_t * context, int_fast16_t err) {
    (void) context;
    fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err));
    return 0;
}

canonical_original_code:
int SCPI_Error(struct _scpi_t *context, long err) {
    (void) context;
    fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (short) err, SCPI_ErrorTranslate(err));
    return 0;
}

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: err long

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_Control(__int64 a1, unsigned int a2, unsigned __int16 a3)
{
__int64 v4; // rbp
__int64 result; // rax
size_t v6; // rax
char v7[40]; // [rsp+0h] [rbp-28h] BYREF

if ( a2 == 1 )
fprintf(stderr, "**SRQ: 0x%X (%d)\r\n", a3, a3);
else
fprintf(stderr, "**CTRL %02x: 0x%X (%d)\r\n", a2, a3, a3);
v4 = *(_QWORD *)(a1 + 168);
result = 1LL;
if ( v4 )
{
if ( *(int *)(v4 + 8) >= 0 )
{
sprintf(v7, "SRQ%d\r\n", a3);
v6 = strlen(v7);
result = 2 * (unsigned int)(write(*(_DWORD *)(v4 + 8), v7, v6) > 0) - 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, unsigned int a2, unsigned __int16 a3)
{
__int64 v4; // rbp
__int64 result; // rax
size_t v6; // rax
char v7[40]; // [rsp+0h] [rbp-28h] BYREF

if ( a2 == 1 )
fprintf(stderr, "**SRQ: 0x%X (%d)\r\n", a3, a3);
else
fprintf(stderr, "**CTRL %02x: 0x%X (%d)\r\n", a2, a3, a3);
v4 = *(_QWORD *)(a1 + 168);
result = 1LL;
if ( v4 )
{
if ( *(int *)(v4 + 8) >= 0 )
{
sprintf(v7, "SRQ%d\r\n", a3);
v6 = strlen(v7);
result = 2 * (unsigned int)(write(*(_DWORD *)(v4 + 8), v7, v6) > 0) - 1;
}
}
return result;
}

original_code:
scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
    (void) context;
    if (SCPI_CTRL_SRQ == ctrl) {
        fprintf(stderr, "**SRQ: 0x%X (%d)\r\n", val, val);
    } else {
        fprintf(stderr, "**CTRL %02x: 0x%X (%d)\r\n", ctrl, val, val);
    }
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_Control(struct _scpi_t *context, enum _scpi_ctrl_name_t ctrl, unsigned short val) {
    (void) context;
    if (SCPI_CTRL_SRQ == ctrl) {
        fprintf(stderr, "**SRQ: 0x%X (%d)\r\n", val, val);
    } else {
        fprintf(stderr, "**CTRL %02x: 0x%X (%d)\r\n", ctrl, val, val);
    }
    return SCPI_RES_OK;
}

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

variable_types:
val
unsigned short

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

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_buffer_t { unsigned long length; unsigned long position; char *data; }

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


decompiled_code:
__int64 SCPI_Reset()
{
fwrite("**Reset\r\n", 1uLL, 9uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 func14()
{
fwrite("**Reset\r\n", 1uLL, 9uLL, stderr);
return 1LL;
}

original_code:
scpi_result_t SCPI_Reset(scpi_t * context) {
    (void) context;
    fprintf(stderr, "**Reset\r\n");
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_Reset(struct _scpi_t *context) {
    (void) context;
    fprintf(stderr, "**Reset\r\n");
    return SCPI_RES_OK;
}

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: enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 }

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


decompiled_code:
__int64 __fastcall DMM_MeasureVoltageDcQ(__int64 a1)
{
char v2[15]; // [rsp+11h] [rbp-4Fh] BYREF
char v3[32]; // [rsp+20h] [rbp-40h] BYREF
char v4[32]; // [rsp+40h] [rbp-20h] BYREF

fwrite("meas:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
char v2[15]; // [rsp+11h] [rbp-4Fh] BYREF
char v3[32]; // [rsp+20h] [rbp-40h] BYREF
char v4[32]; // [rsp+40h] [rbp-20h] BYREF

fwrite("meas:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

original_code:
static scpi_result_t DMM_MeasureVoltageDcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    char bf[15];
    fprintf(stderr, "meas:volt:dc\r\n");
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, 0)) {
    }
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, 0)) {
    }
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);
    SCPI_ResultDouble(context, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t DMM_MeasureVoltageDcQ(struct _scpi_t *context) {
    struct _scpi_number_parameter_t param1; struct _scpi_number_parameter_t param2;
    char bf[15];
    fprintf(stderr, "meas:volt:dc\r\n");
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, 0)) {
    }
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, 0)) {
    }
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);
    SCPI_ResultDouble(context, 0);
    return SCPI_RES_OK;
}

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:
bf
char [15]

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: enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 }

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 DMM_MeasureVoltageAcQ(__int64 a1)
{
char v2[15]; // [rsp+11h] [rbp-4Fh] BYREF
char v3[32]; // [rsp+20h] [rbp-40h] BYREF
char v4[32]; // [rsp+40h] [rbp-20h] BYREF

fwrite("meas:volt:ac\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
char v2[15]; // [rsp+11h] [rbp-4Fh] BYREF
char v3[32]; // [rsp+20h] [rbp-40h] BYREF
char v4[32]; // [rsp+40h] [rbp-20h] BYREF

fwrite("meas:volt:ac\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

original_code:
static scpi_result_t DMM_MeasureVoltageAcQ(scpi_t * context) {
    scpi_number_t param1, param2;
    char bf[15];
    fprintf(stderr, "meas:volt:ac\r\n");
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, 0)) {
    }
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, 0)) {
    }
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);
    SCPI_ResultDouble(context, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t DMM_MeasureVoltageAcQ(struct _scpi_t *context) {
    struct _scpi_number_parameter_t param1; struct _scpi_number_parameter_t param2;
    char bf[15];
    fprintf(stderr, "meas:volt:ac\r\n");
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param1, 0)) {
    }
    if (!SCPI_ParamNumber(context, scpi_special_numbers_def, &param2, 0)) {
    }
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param1, bf, 15);
    fprintf(stderr, "\tP1=%s\r\n", bf);
    SCPI_NumberToStr(context, scpi_special_numbers_def, &param2, bf, 15);
    fprintf(stderr, "\tP2=%s\r\n", bf);
    SCPI_ResultDouble(context, 0);
    return SCPI_RES_OK;
}

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: 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 DMM_ConfigureVoltageDc(__int64 a1)
{
double v2; // [rsp+10h] [rbp-10h] BYREF
double v3; // [rsp+18h] [rbp-8h] BYREF

fwrite("conf:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
if ( (unsigned __int8)SCPI_ParamDouble(a1, &v3, 1LL) != 1 )
return 0xFFFFFFFFLL;
SCPI_ParamDouble(a1, &v2, 0LL);
fprintf(stderr, "\tP1=%lf\r\n", v3);
fprintf(stderr, "\tP2=%lf\r\n", v2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
double v2; // [rsp+10h] [rbp-10h] BYREF
double v3; // [rsp+18h] [rbp-8h] BYREF

fwrite("conf:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
if ( (unsigned __int8)SCPI_ParamDouble(a1, &v3, 1LL) != 1 )
return 0xFFFFFFFFLL;
SCPI_ParamDouble(a1, &v2, 0LL);
fprintf(stderr, "\tP1=%lf\r\n", v3);
fprintf(stderr, "\tP2=%lf\r\n", v2);
return 1LL;
}

original_code:
static scpi_result_t DMM_ConfigureVoltageDc(scpi_t * context) {
    double param1, param2;
    fprintf(stderr, "conf:volt:dc\r\n");
    if (!SCPI_ParamDouble(context, &param1, (!0))) {
        return SCPI_RES_ERR;
    }
    if (!SCPI_ParamDouble(context, &param2, 0)) {
    }
    fprintf(stderr, "\tP1=%lf\r\n", param1);
    fprintf(stderr, "\tP2=%lf\r\n", param2);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t DMM_ConfigureVoltageDc(struct _scpi_t *context) {
    double param1; double param2;
    fprintf(stderr, "conf:volt:dc\r\n");
    if (!SCPI_ParamDouble(context, &param1, (!0))) {
        return SCPI_RES_ERR;
    }
    if (!SCPI_ParamDouble(context, &param2, 0)) {
    }
    fprintf(stderr, "\tP1=%lf\r\n", param1);
    fprintf(stderr, "\tP2=%lf\r\n", param2);
    return SCPI_RES_OK;
}

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


decompiled_code:
__int64 __fastcall TEST_Bool(__int64 a1)
{
unsigned __int8 v2; // [rsp+1Fh] [rbp-1h] BYREF

fwrite("TEST:BOOL\r\n", 1uLL, 0xBuLL, stderr);
if ( (unsigned __int8)SCPI_ParamBool(a1, &v2, 1LL) != 1 )
return 0xFFFFFFFFLL;
fprintf(stderr, "\tP1=%d\r\n", v2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned __int8 v2; // [rsp+1Fh] [rbp-1h] BYREF

fwrite("TEST:BOOL\r\n", 1uLL, 0xBuLL, stderr);
if ( (unsigned __int8)SCPI_ParamBool(a1, &v2, 1LL) != 1 )
return 0xFFFFFFFFLL;
fprintf(stderr, "\tP1=%d\r\n", v2);
return 1LL;
}

original_code:
static scpi_result_t TEST_Bool(scpi_t * context) {
    scpi_bool_t param1;
    fprintf(stderr, "TEST:BOOL\r\n");
    if (!SCPI_ParamBool(context, &param1, (!0))) {
        return SCPI_RES_ERR;
    }
    fprintf(stderr, "\tP1=%d\r\n", param1);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_Bool(struct _scpi_t *context) {
    _Bool param1;
    fprintf(stderr, "TEST:BOOL\r\n");
    if (!SCPI_ParamBool(context, &param1, (!0))) {
        return SCPI_RES_ERR;
    }
    fprintf(stderr, "\tP1=%d\r\n", param1);
    return SCPI_RES_OK;
}

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 TEST_ChoiceQ(__int64 a1)
{
const char *v2; // [rsp+10h] [rbp-10h] BYREF
unsigned int v3; // [rsp+1Ch] [rbp-4h] BYREF

if ( (unsigned __int8)SCPI_ParamChoice(a1, &trigger_source, &v3, 1LL) != 1 )
return 0xFFFFFFFFLL;
SCPI_ChoiceToName(&trigger_source, v3, &v2);
fprintf(stderr, "\tP1=%s (%ld)\r\n", v2, (int)v3);
SCPI_ResultInt32(a1, v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
const char *v2; // [rsp+10h] [rbp-10h] BYREF
unsigned int v3; // [rsp+1Ch] [rbp-4h] BYREF

if ( (unsigned __int8)SCPI_ParamChoice(a1, &trigger_source, &v3, 1LL) != 1 )
return 0xFFFFFFFFLL;
SCPI_ChoiceToName(&trigger_source, v3, &v2);
fprintf(stderr, "\tP1=%s (%ld)\r\n", v2, (int)v3);
SCPI_ResultInt32(a1, v3);
return 1LL;
}

original_code:
static scpi_result_t TEST_ChoiceQ(scpi_t * context) {
    int32_t param;
    const char * name;
    if (!SCPI_ParamChoice(context, trigger_source, &param, (!0))) {
        return SCPI_RES_ERR;
    }
    SCPI_ChoiceToName(trigger_source, param, &name);
    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long int) param);
    SCPI_ResultInt32(context, param);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_ChoiceQ(struct _scpi_t *context) {
    int param;
    char *name;
    if (!SCPI_ParamChoice(context, trigger_source, &param, (!0))) {
        return SCPI_RES_ERR;
    }
    SCPI_ChoiceToName(trigger_source, param, &name);
    fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (long) param);
    SCPI_ResultInt32(context, param);
    return SCPI_RES_OK;
}

variable_types: param int

variable_types:
name
char *

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_buffer_t { unsigned long length; unsigned long position; char *data; }


decompiled_code:
__int64 __fastcall TEST_Numbers(__int64 a1)
{
int v2[2]; // [rsp+18h] [rbp-8h] BYREF

SCPI_CommandNumbers(a1, v2, 2LL, 1LL);
fprintf(stderr, "TEST numbers %d %d\r\n", (unsigned int)v2[0], (unsigned int)v2[1]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v2[2]; // [rsp+18h] [rbp-8h] BYREF

SCPI_CommandNumbers(a1, v2, 2LL, 1LL);
fprintf(stderr, "TEST numbers %d %d\r\n", (unsigned int)v2[0], (unsigned int)v2[1]);
return 1LL;
}

original_code:
static scpi_result_t TEST_Numbers(scpi_t * context) {
    int32_t numbers[2];
    SCPI_CommandNumbers(context, numbers, 2, 1);
    fprintf(stderr, "TEST numbers %d %d\r\n", numbers[0], numbers[1]);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_Numbers(struct _scpi_t *context) {
    int numbers[2];
    SCPI_CommandNumbers(context, numbers, 2, 1);
    fprintf(stderr, "TEST numbers %d %d\r\n", numbers[0], numbers[1]);
    return SCPI_RES_OK;
}

variable_types:
numbers
int [2]

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


decompiled_code:
__int64 __fastcall TEST_Text(__int64 a1)
{
char v2[8]; // [rsp+18h] [rbp-78h] BYREF
char v3[112]; // [rsp+20h] [rbp-70h] BYREF

if ( (unsigned __int8)SCPI_ParamCopyText(a1, v3, 100LL, v2, 0LL) != 1 )
v3[0] = 0;
fprintf(stderr, "TEXT: ***%s***\r\n", v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
char v2[8]; // [rsp+18h] [rbp-78h] BYREF
char v3[112]; // [rsp+20h] [rbp-70h] BYREF

if ( (unsigned __int8)SCPI_ParamCopyText(a1, v3, 100LL, v2, 0LL) != 1 )
v3[0] = 0;
fprintf(stderr, "TEXT: ***%s***\r\n", v3);
return 1LL;
}

original_code:
static scpi_result_t TEST_Text(scpi_t * context) {
    char buffer[100];
    size_t copy_len;
    if (!SCPI_ParamCopyText(context, buffer, sizeof (buffer), &copy_len, 0)) {
        buffer[0] = '\0';
    }
    fprintf(stderr, "TEXT: ***%s***\r\n", buffer);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_Text(struct _scpi_t *context) {
    char buffer[100];
    unsigned long copy_len;
    if (!SCPI_ParamCopyText(context, buffer, sizeof (buffer), &copy_len, 0)) {
        buffer[0] = '\0';
    }
    fprintf(stderr, "TEXT: ***%s***\r\n", buffer);
    return SCPI_RES_OK;
}

variable_types:
buffer
char [100]

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


decompiled_code:
__int64 __fastcall TEST_ArbQ(__int64 a1)
{
__int64 v2; // [rsp+10h] [rbp-10h] BYREF
__int64 v3; // [rsp+18h] [rbp-8h] BYREF

if ( (unsigned __int8)SCPI_ParamArbitraryBlock(a1, &v3, &v2, 0LL) )
SCPI_ResultArbitraryBlock(a1, v3, v2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v2; // [rsp+10h] [rbp-10h] BYREF
__int64 v3; // [rsp+18h] [rbp-8h] BYREF

if ( (unsigned __int8)SCPI_ParamArbitraryBlock(a1, &v3, &v2, 0LL) )
SCPI_ResultArbitraryBlock(a1, v3, v2);
return 1LL;
}

original_code:
static scpi_result_t TEST_ArbQ(scpi_t * context) {
    const char * data;
    size_t len;
    if (SCPI_ParamArbitraryBlock(context, &data, &len, 0)) {
        SCPI_ResultArbitraryBlock(context, data, len);
    }
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_ArbQ(struct _scpi_t *context) {
    char *data;
    unsigned long len;
    if (SCPI_ParamArbitraryBlock(context, &data, &len, 0)) {
        SCPI_ResultArbitraryBlock(context, data, len);
    }
    return SCPI_RES_OK;
}

variable_types:
data
char *

variable_types:
len
unsigned long

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

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


decompiled_code:
__int64 __fastcall TEST_Chanlst(__int64 a1)
{
__int64 v2; // [rsp+10h] [rbp-E0h] BYREF
int v3; // [rsp+1Ch] [rbp-D4h] BYREF
int v4; // [rsp+20h] [rbp-D0h]
int v5; // [rsp+24h] [rbp-CCh] BYREF
int v6; // [rsp+28h] [rbp-C8h]
char v7[97]; // [rsp+2Fh] [rbp-C1h] BYREF
char v8[36]; // [rsp+90h] [rbp-60h] BYREF
int v9; // [rsp+B4h] [rbp-3Ch]
unsigned __int64 i; // [rsp+B8h] [rbp-38h]
int v11; // [rsp+C4h] [rbp-2Ch]
int v12; // [rsp+C8h] [rbp-28h]
char v13; // [rsp+CEh] [rbp-22h]
char v14; // [rsp+CFh] [rbp-21h]
__int64 v15; // [rsp+D0h] [rbp-20h]
__int64 v16; // [rsp+D8h] [rbp-18h]
unsigned __int64 v17; // [rsp+E0h] [rbp-10h]
__int64 v18; // [rsp+E8h] [rbp-8h]

v17 = 0LL;
v15 = 1LL;
if ( (unsigned __int8)SCPI_Parameter(a1, v8, 1LL) )
{
v14 = 0;
v13 = 0;
v12 = 1;
v11 = 1;
if ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v8, 0LL, v7, 0LL, 0LL, 0LL, &v2) )
{
v18 = 0LL;
v17 = 0LL;
do
{
v9 = SCPI_ExprChannelListEntry(a1, v8, (unsigned int)v18, v7, &v5, &v3, 4LL, &v2);
if ( v7[0] )
{
if ( v7[0] != 1 )
return 0xFFFFFFFFLL;
if ( v5 <= v3 )
v12 = 1;
else
v12 = -1;
v14 = 0;
v16 = v5;
while ( !v14 )
{
if ( v2 == 2 )
{
if ( v6 <= v4 )
{
if ( v6 < v4 )
v11 = 1;
}
else
{
v11 = -1;
}
v13 = 0;
v15 = v6;
while ( !v13 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v16;
*(_DWORD *)&v7[8 * v17++ + 5] = v15;
if ( v17 > 0xB )
return 0xFFFFFFFFLL;
if ( v15 == v4 )
v13 = 1;
v15 += v11;
}
}
else if ( v2 == 1 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v16;
*(_DWORD *)&v7[8 * v17++ + 5] = 0;
if ( v17 > 0xB )
return 0xFFFFFFFFLL;
}
if ( v16 == v3 )
v14 = 1;
v16 += v12;
}
}
else
{
if ( v2 == 1 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v5;
*(_DWORD *)&v7[8 * v17 + 5] = 0;
}
else
{
if ( v2 != 2 )
return 0xFFFFFFFFLL;
*(_DWORD *)&v7[8 * v17 + 1] = v5;
*(_DWORD *)&v7[8 * v17 + 5] = v6;
}
if ( ++v17 > 0xB )
return 0xFFFFFFFFLL;
}
++v18;
}
while ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v8, (unsigned int)v18, v7, &v5, &v3, 4LL, &v2) );
}
}
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
for ( i = 0LL; i < v17; ++i )
fprintf(stderr, "%d!%d, ", *(unsigned int *)&v7[8 * i + 1], *(unsigned int *)&v7[8 * i + 5]);
fwrite("\r\n", 1uLL, 2uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 v2; // [rsp+10h] [rbp-E0h] BYREF
int v3; // [rsp+1Ch] [rbp-D4h] BYREF
int v4; // [rsp+20h] [rbp-D0h]
int v5; // [rsp+24h] [rbp-CCh] BYREF
int v6; // [rsp+28h] [rbp-C8h]
char v7[97]; // [rsp+2Fh] [rbp-C1h] BYREF
char v8[36]; // [rsp+90h] [rbp-60h] BYREF
int v9; // [rsp+B4h] [rbp-3Ch]
unsigned __int64 i; // [rsp+B8h] [rbp-38h]
int v11; // [rsp+C4h] [rbp-2Ch]
int v12; // [rsp+C8h] [rbp-28h]
char v13; // [rsp+CEh] [rbp-22h]
char v14; // [rsp+CFh] [rbp-21h]
__int64 v15; // [rsp+D0h] [rbp-20h]
__int64 v16; // [rsp+D8h] [rbp-18h]
unsigned __int64 v17; // [rsp+E0h] [rbp-10h]
__int64 v18; // [rsp+E8h] [rbp-8h]

v17 = 0LL;
v15 = 1LL;
if ( (unsigned __int8)SCPI_Parameter(a1, v8, 1LL) )
{
v14 = 0;
v13 = 0;
v12 = 1;
v11 = 1;
if ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v8, 0LL, v7, 0LL, 0LL, 0LL, &v2) )
{
v18 = 0LL;
v17 = 0LL;
do
{
v9 = SCPI_ExprChannelListEntry(a1, v8, (unsigned int)v18, v7, &v5, &v3, 4LL, &v2);
if ( v7[0] )
{
if ( v7[0] != 1 )
return 0xFFFFFFFFLL;
if ( v5 <= v3 )
v12 = 1;
else
v12 = -1;
v14 = 0;
v16 = v5;
while ( !v14 )
{
if ( v2 == 2 )
{
if ( v6 <= v4 )
{
if ( v6 < v4 )
v11 = 1;
}
else
{
v11 = -1;
}
v13 = 0;
v15 = v6;
while ( !v13 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v16;
*(_DWORD *)&v7[8 * v17++ + 5] = v15;
if ( v17 > 0xB )
return 0xFFFFFFFFLL;
if ( v15 == v4 )
v13 = 1;
v15 += v11;
}
}
else if ( v2 == 1 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v16;
*(_DWORD *)&v7[8 * v17++ + 5] = 0;
if ( v17 > 0xB )
return 0xFFFFFFFFLL;
}
if ( v16 == v3 )
v14 = 1;
v16 += v12;
}
}
else
{
if ( v2 == 1 )
{
*(_DWORD *)&v7[8 * v17 + 1] = v5;
*(_DWORD *)&v7[8 * v17 + 5] = 0;
}
else
{
if ( v2 != 2 )
return 0xFFFFFFFFLL;
*(_DWORD *)&v7[8 * v17 + 1] = v5;
*(_DWORD *)&v7[8 * v17 + 5] = v6;
}
if ( ++v17 > 0xB )
return 0xFFFFFFFFLL;
}
++v18;
}
while ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v8, (unsigned int)v18, v7, &v5, &v3, 4LL, &v2) );
}
}
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
for ( i = 0LL; i < v17; ++i )
fprintf(stderr, "%d!%d, ", *(unsigned int *)&v7[8 * i + 1], *(unsigned int *)&v7[8 * i + 5]);
fwrite("\r\n", 1uLL, 2uLL, stderr);
return 1LL;
}

original_code:
static scpi_result_t TEST_Chanlst(scpi_t *context) {
    scpi_parameter_t channel_list_param;
    scpi_channel_value_t array[2 * 6];
    size_t chanlst_idx;
    size_t arr_idx = 0;
    size_t n, m = 1;
    if (SCPI_Parameter(context, &channel_list_param, (!0))) {
        scpi_expr_result_t res;
        scpi_bool_t is_range;
        int32_t values_from[2];
        int32_t values_to[2];
        size_t dimensions;
        _Bool for_stop_row = 0;
        _Bool for_stop_col = 0;
        int32_t dir_row = 1;
        int32_t dir_col = 1;
        if (!SCPI_ExprChannelListEntry(context, &channel_list_param, 0, &is_range, ((void *)0), ((void *)0), 0, &dimensions)) {
            chanlst_idx = 0;
            arr_idx = 0;
            do {
                res = SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions);
                if (is_range == 0) {
                    if (dimensions == 1) {
                        array[arr_idx].row = values_from[0];
                        array[arr_idx].col = 0;
                    } else if (dimensions == 2) {
                        array[arr_idx].row = values_from[0];
                        array[arr_idx].col = values_from[1];
                    } else {
                        return SCPI_RES_ERR;
                    }
                    arr_idx++;
                    if (arr_idx >= 2 * 6) {
                        return SCPI_RES_ERR;
                    }
                } else if (is_range == (!0)) {
                    if (values_from[0] > values_to[0]) {
                        dir_row = -1;
                    } else {
                        dir_row = +1;
                    }
                    for_stop_row = 0;
                    for (n = values_from[0]; for_stop_row == 0; n += dir_row) {
                        if (dimensions == 2) {
                            if (values_from[1] > values_to[1]) {
                                dir_col = -1;
                            } else if (values_from[1] < values_to[1]) {
                                dir_col = +1;
                            }
                            for_stop_col = 0;
                            for (m = values_from[1]; for_stop_col == 0; m += dir_col) {
                                array[arr_idx].row = n;
                                array[arr_idx].col = m;
                                arr_idx++;
                                if (arr_idx >= 2 * 6) {
                                    return SCPI_RES_ERR;
                                }
                                if (m == (size_t)values_to[1]) {
                                    for_stop_col = (!0);
                                }
                            }
                        } else if (dimensions == 1) {
                            array[arr_idx].row = n;
                            array[arr_idx].col = 0;
                            arr_idx++;
                            if (arr_idx >= 2 * 6) {
                                return SCPI_RES_ERR;
                            }
                        }
                        if (n == (size_t)values_to[0]) {
                            for_stop_row = (!0);
                        }
                    }
                } else {
                    return SCPI_RES_ERR;
                }
                chanlst_idx++;
            } while (SCPI_EXPR_OK == SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions));
        }
    }
    {
        size_t i;
        fprintf(stderr, "TEST_Chanlst: ");
        for (i = 0; i< arr_idx; i++) {
            fprintf(stderr, "%d!%d, ", array[i].row, array[i].col);
        }
        fprintf(stderr, "\r\n");
    }
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t TEST_Chanlst(struct _scpi_t *context) {
    struct _scpi_token_t channel_list_param;
    struct _scpi_channel_value_t array[-1];
    unsigned long chanlst_idx;
    unsigned long arr_idx = 0;
    unsigned long n; unsigned long m = 1;
    if (SCPI_Parameter(context, &channel_list_param, (!0))) {
        enum _scpi_expr_result_t res;
        _Bool is_range;
        int values_from[2];
        int values_to[2];
        unsigned long dimensions;
        _Bool for_stop_row = 0;
        _Bool for_stop_col = 0;
        int dir_row = 1;
        int dir_col = 1;
        if (!SCPI_ExprChannelListEntry(context, &channel_list_param, 0, &is_range, ((void *)0), ((void *)0), 0, &dimensions)) {
            chanlst_idx = 0;
            arr_idx = 0;
            do {
                res = SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions);
                if (is_range == 0) {
                    if (dimensions == 1) {
                        array[arr_idx].row = values_from[0];
                        array[arr_idx].col = 0;
                    } else if (dimensions == 2) {
                        array[arr_idx].row = values_from[0];
                        array[arr_idx].col = values_from[1];
                    } else {
                        return SCPI_RES_ERR;
                    }
                    arr_idx++;
                    if (arr_idx >= 2 * 6) {
                        return SCPI_RES_ERR;
                    }
                } else if (is_range == (!0)) {
                    if (values_from[0] > values_to[0]) {
                        dir_row = -1;
                    } else {
                        dir_row = +1;
                    }
                    for_stop_row = 0;
                    for (n = values_from[0]; for_stop_row == 0; n += dir_row) {
                        if (dimensions == 2) {
                            if (values_from[1] > values_to[1]) {
                                dir_col = -1;
                            } else if (values_from[1] < values_to[1]) {
                                dir_col = +1;
                            }
                            for_stop_col = 0;
                            for (m = values_from[1]; for_stop_col == 0; m += dir_col) {
                                array[arr_idx].row = n;
                                array[arr_idx].col = m;
                                arr_idx++;
                                if (arr_idx >= 2 * 6) {
                                    return SCPI_RES_ERR;
                                }
                                if (m == (unsigned long)values_to[1]) {
                                    for_stop_col = (!0);
                                }
                            }
                        } else if (dimensions == 1) {
                            array[arr_idx].row = n;
                            array[arr_idx].col = 0;
                            arr_idx++;
                            if (arr_idx >= 2 * 6) {
                                return SCPI_RES_ERR;
                            }
                        }
                        if (n == (unsigned long)values_to[0]) {
                            for_stop_row = (!0);
                        }
                    }
                } else {
                    return SCPI_RES_ERR;
                }
                chanlst_idx++;
            } while (SCPI_EXPR_OK == SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions));
        }
    }
    {
        unsigned long i;
        fprintf(stderr, "TEST_Chanlst: ");
        for (i = 0; i< arr_idx; i++) {
            fprintf(stderr, "%d!%d, ", array[i].row, array[i].col);
        }
        fprintf(stderr, "\r\n");
    }
    return SCPI_RES_OK;
}

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 _scpi_channel_value_t { int row; int col; } [-1]

variable_types:
n
unsigned long

variable_types:
m
unsigned long

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

variable_types:
dimensions
unsigned long

variable_types:
i
unsigned long

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


decompiled_code:
__int64 __fastcall My_CoreTstQ(__int64 a1)
{
SCPI_ResultInt32(a1, 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
SCPI_ResultInt32(a1, 0LL);
return 1LL;
}

original_code:
static scpi_result_t My_CoreTstQ(scpi_t * context) {
    SCPI_ResultInt32(context, 0);
    return SCPI_RES_OK;
}

canonical_original_code:
static enum _scpi_result_t My_CoreTstQ(struct _scpi_t *context) {
    SCPI_ResultInt32(context, 0);
    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; } *


decompiled_code:
__int64 __fastcall TEST_Chanlst(__int64 a1)
{
int v2; // er15
unsigned __int64 v3; // rbx
unsigned int v4; // er12
int v5; // ecx
__int64 v6; // rsi
__int64 v7; // rdi
int v8; // er14
int v9; // er13
__int64 v10; // r8
__int64 v11; // r10
int v12; // edx
__int64 v13; // rax
__int64 i; // rbp
int v16; // [rsp+Ch] [rbp-ECh]
__int64 v17; // [rsp+18h] [rbp-E0h]
char v18; // [rsp+27h] [rbp-D1h] BYREF
__int64 v19; // [rsp+28h] [rbp-D0h] BYREF
int v20; // [rsp+30h] [rbp-C8h] BYREF
int v21; // [rsp+34h] [rbp-C4h]
int v22; // [rsp+38h] [rbp-C0h] BYREF
int v23; // [rsp+3Ch] [rbp-BCh]
int v24[24]; // [rsp+40h] [rbp-B8h]
char v25[88]; // [rsp+A0h] [rbp-58h] BYREF

if ( (unsigned __int8)SCPI_Parameter(a1, v25, 1LL) )
{
if ( (unsigned int)SCPI_ExprChannelListEntry(a1, v25, 0LL, &v18, 0LL, 0LL, 0LL, &v19) )
{
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
}
else
{
v2 = 1;
v3 = 0LL;
v4 = 0;
do
{
SCPI_ExprChannelListEntry(a1, v25, v4, &v18, &v20, &v22, 4LL, &v19);
if ( v18 )
{
v5 = v20;
v6 = v20;
v7 = v19;
v8 = v21;
v9 = v23;
v17 = v21;
v16 = 2 * (v20 <= v22) - 1;
v10 = v23;
v11 = v22;
while ( 1 )
{
if ( v7 == 2 )
{
if ( v8 > v9 )
{
v2 = -1;
}
else if ( v8 < v9 )
{
v2 = 1;
}
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = v8;
if ( v3 > 0xB )
return 0xFFFFFFFFLL;
v12 = v8 + v2;
v13 = v17;
while ( v10 != v13 )
{
v13 += v2;
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = v12;
v12 += v2;
if ( v3 == 12 )
return 0xFFFFFFFFLL;
}
}
else if ( v7 == 1 )
{
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = 0;
if ( v3 > 0xB )
return 0xFFFFFFFFLL;
}
v5 += v16;
if ( v11 == v6 )
goto LABEL_6;
v6 += v16;
}
}
if ( v19 == 1 )
{
v24[2 * v3] = v20;
v24[2 * v3 + 1] = 0;
}
else
{
if ( v19 != 2 )
return 0xFFFFFFFFLL;
v24[2 * v3] = v20;
v24[2 * v3 + 1] = v21;
}
if ( ++v3 > 0xB )
return 0xFFFFFFFFLL;
LABEL_6:
++v4;
}
while ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v25, v4, &v18, &v20, &v22, 4LL, &v19) );
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
if ( v3 )
{
for ( i = 0LL; i != v3; ++i )
fprintf(stderr, "%d!%d, ", (unsigned int)v24[2 * i], (unsigned int)v24[2 * i + 1]);
}
}
}
else
{
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
}
fwrite("\r\n", 1uLL, 2uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v2; // er15
unsigned __int64 v3; // rbx
unsigned int v4; // er12
int v5; // ecx
__int64 v6; // rsi
__int64 v7; // rdi
int v8; // er14
int v9; // er13
__int64 v10; // r8
__int64 v11; // r10
int v12; // edx
__int64 v13; // rax
__int64 i; // rbp
int v16; // [rsp+Ch] [rbp-ECh]
__int64 v17; // [rsp+18h] [rbp-E0h]
char v18; // [rsp+27h] [rbp-D1h] BYREF
__int64 v19; // [rsp+28h] [rbp-D0h] BYREF
int v20; // [rsp+30h] [rbp-C8h] BYREF
int v21; // [rsp+34h] [rbp-C4h]
int v22; // [rsp+38h] [rbp-C0h] BYREF
int v23; // [rsp+3Ch] [rbp-BCh]
int v24[24]; // [rsp+40h] [rbp-B8h]
char v25[88]; // [rsp+A0h] [rbp-58h] BYREF

if ( (unsigned __int8)SCPI_Parameter(a1, v25, 1LL) )
{
if ( (unsigned int)SCPI_ExprChannelListEntry(a1, v25, 0LL, &v18, 0LL, 0LL, 0LL, &v19) )
{
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
}
else
{
v2 = 1;
v3 = 0LL;
v4 = 0;
do
{
SCPI_ExprChannelListEntry(a1, v25, v4, &v18, &v20, &v22, 4LL, &v19);
if ( v18 )
{
v5 = v20;
v6 = v20;
v7 = v19;
v8 = v21;
v9 = v23;
v17 = v21;
v16 = 2 * (v20 <= v22) - 1;
v10 = v23;
v11 = v22;
while ( 1 )
{
if ( v7 == 2 )
{
if ( v8 > v9 )
{
v2 = -1;
}
else if ( v8 < v9 )
{
v2 = 1;
}
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = v8;
if ( v3 > 0xB )
return 0xFFFFFFFFLL;
v12 = v8 + v2;
v13 = v17;
while ( v10 != v13 )
{
v13 += v2;
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = v12;
v12 += v2;
if ( v3 == 12 )
return 0xFFFFFFFFLL;
}
}
else if ( v7 == 1 )
{
v24[2 * v3] = v5;
v24[2 * v3++ + 1] = 0;
if ( v3 > 0xB )
return 0xFFFFFFFFLL;
}
v5 += v16;
if ( v11 == v6 )
goto LABEL_6;
v6 += v16;
}
}
if ( v19 == 1 )
{
v24[2 * v3] = v20;
v24[2 * v3 + 1] = 0;
}
else
{
if ( v19 != 2 )
return 0xFFFFFFFFLL;
v24[2 * v3] = v20;
v24[2 * v3 + 1] = v21;
}
if ( ++v3 > 0xB )
return 0xFFFFFFFFLL;
LABEL_6:
++v4;
}
while ( !(unsigned int)SCPI_ExprChannelListEntry(a1, v25, v4, &v18, &v20, &v22, 4LL, &v19) );
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
if ( v3 )
{
for ( i = 0LL; i != v3; ++i )
fprintf(stderr, "%d!%d, ", (unsigned int)v24[2 * i], (unsigned int)v24[2 * i + 1]);
}
}
}
else
{
fwrite("TEST_Chanlst: ", 1uLL, 0xEuLL, stderr);
}
fwrite("\r\n", 1uLL, 2uLL, stderr);
return 1LL;
}

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: struct _scpi_channel_value_t { int row; int col; }


decompiled_code:
__int64 __fastcall TEST_ArbQ(__int64 a1)
{
__int64 v2; // [rsp+0h] [rbp-18h] BYREF
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

if ( (unsigned __int8)SCPI_ParamArbitraryBlock(a1, &v3, &v2, 0LL) )
SCPI_ResultArbitraryBlock(a1, v3, v2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v2; // [rsp+0h] [rbp-18h] BYREF
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

if ( (unsigned __int8)SCPI_ParamArbitraryBlock(a1, &v3, &v2, 0LL) )
SCPI_ResultArbitraryBlock(a1, v3, v2);
return 1LL;
}

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: 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_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 TEST_Text(__int64 a1)
{
char v2[8]; // [rsp+8h] [rbp-80h] BYREF
char v3[120]; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned __int8)SCPI_ParamCopyText(a1, v3, 100LL, v2, 0LL) )
v3[0] = 0;
fprintf(stderr, "TEXT: ***%s***\r\n", v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
char v2[8]; // [rsp+8h] [rbp-80h] BYREF
char v3[120]; // [rsp+10h] [rbp-78h] BYREF

if ( !(unsigned __int8)SCPI_ParamCopyText(a1, v3, 100LL, v2, 0LL) )
v3[0] = 0;
fprintf(stderr, "TEXT: ***%s***\r\n", v3);
return 1LL;
}

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


decompiled_code:
__int64 __fastcall TEST_Numbers(__int64 a1)
{
int v2[4]; // [rsp+8h] [rbp-10h] BYREF

SCPI_CommandNumbers(a1, v2, 2LL, 1LL);
fprintf(stderr, "TEST numbers %d %d\r\n", (unsigned int)v2[0], (unsigned int)v2[1]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v2[4]; // [rsp+8h] [rbp-10h] BYREF

SCPI_CommandNumbers(a1, v2, 2LL, 1LL);
fprintf(stderr, "TEST numbers %d %d\r\n", (unsigned int)v2[0], (unsigned int)v2[1]);
return 1LL;
}

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_buffer_t { unsigned long length; unsigned long position; char *data; }

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


decompiled_code:
__int64 __fastcall TEST_ChoiceQ(__int64 a1)
{
char v1; // dl
__int64 result; // rax
const char *v3; // [rsp+0h] [rbp-18h] BYREF
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1 = SCPI_ParamChoice(a1, &trigger_source, v4, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
SCPI_ChoiceToName(&trigger_source, v4[0], &v3);
fprintf(stderr, "\tP1=%s (%ld)\r\n", v3, (int)v4[0]);
SCPI_ResultInt32(a1, v4[0]);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
char v1; // dl
__int64 result; // rax
const char *v3; // [rsp+0h] [rbp-18h] BYREF
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1 = SCPI_ParamChoice(a1, &trigger_source, v4, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
SCPI_ChoiceToName(&trigger_source, v4[0], &v3);
fprintf(stderr, "\tP1=%s (%ld)\r\n", v3, (int)v4[0]);
SCPI_ResultInt32(a1, v4[0]);
result = 1LL;
}
return result;
}

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 _lex_state_t { char *buffer; char *pos; int len; }


canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
SCPI_ResultInt32(a1, 0LL);
return 1LL;
}

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

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

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


decompiled_code:
__int64 __fastcall TEST_Bool(__int64 a1)
{
char v1; // dl
__int64 result; // rax
char v3[9]; // [rsp+Fh] [rbp-9h] BYREF

fwrite("TEST:BOOL\r\n", 1uLL, 0xBuLL, stderr);
v1 = SCPI_ParamBool(a1, v3, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
fprintf(stderr, "\tP1=%d\r\n", (unsigned __int8)v3[0]);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
char v1; // dl
__int64 result; // rax
char v3[9]; // [rsp+Fh] [rbp-9h] BYREF

fwrite("TEST:BOOL\r\n", 1uLL, 0xBuLL, stderr);
v1 = SCPI_ParamBool(a1, v3, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
fprintf(stderr, "\tP1=%d\r\n", (unsigned __int8)v3[0]);
result = 1LL;
}
return result;
}

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

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 }


decompiled_code:
__int64 __fastcall DMM_MeasureVoltageAcQ(__int64 a1)
{
char v2[15]; // [rsp+1h] [rbp-57h] BYREF
char v3[32]; // [rsp+10h] [rbp-48h] BYREF
char v4[40]; // [rsp+30h] [rbp-28h] BYREF

fwrite("meas:volt:ac\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
char v2[15]; // [rsp+1h] [rbp-57h] BYREF
char v3[32]; // [rsp+10h] [rbp-48h] BYREF
char v4[40]; // [rsp+30h] [rbp-28h] BYREF

fwrite("meas:volt:ac\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

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_parser_state_t { struct _scpi_token_t programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t termination; }


decompiled_code:
__int64 __fastcall DMM_MeasureVoltageDcQ(__int64 a1)
{
char v2[15]; // [rsp+1h] [rbp-57h] BYREF
char v3[32]; // [rsp+10h] [rbp-48h] BYREF
char v4[40]; // [rsp+30h] [rbp-28h] BYREF

fwrite("meas:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
char v2[15]; // [rsp+1h] [rbp-57h] BYREF
char v3[32]; // [rsp+10h] [rbp-48h] BYREF
char v4[40]; // [rsp+30h] [rbp-28h] BYREF

fwrite("meas:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v4, 0LL);
SCPI_ParamNumber(a1, &scpi_special_numbers_def, v3, 0LL);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v4, v2, 15LL);
fprintf(stderr, "\tP1=%s\r\n", v2);
SCPI_NumberToStr(a1, &scpi_special_numbers_def, v3, v2, 15LL);
fprintf(stderr, "\tP2=%s\r\n", v2);
SCPI_ResultDouble(a1, 0.0);
return 1LL;
}

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_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 DMM_ConfigureVoltageDc(__int64 a1)
{
char v1; // dl
__int64 result; // rax
double v3; // [rsp+0h] [rbp-18h] BYREF
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

fwrite("conf:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
v1 = SCPI_ParamDouble(a1, v4, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
SCPI_ParamDouble(a1, &v3, 0LL);
fprintf(stderr, "\tP1=%lf\r\n", v4[0]);
fprintf(stderr, "\tP2=%lf\r\n", v3);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
char v1; // dl
__int64 result; // rax
double v3; // [rsp+0h] [rbp-18h] BYREF
double v4[2]; // [rsp+8h] [rbp-10h] BYREF

fwrite("conf:volt:dc\r\n", 1uLL, 0xEuLL, stderr);
v1 = SCPI_ParamDouble(a1, v4, 1LL);
result = 0xFFFFFFFFLL;
if ( v1 )
{
SCPI_ParamDouble(a1, &v3, 0LL);
fprintf(stderr, "\tP1=%lf\r\n", v4[0]);
fprintf(stderr, "\tP2=%lf\r\n", v3);
result = 1LL;
}
return result;
}

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


decompiled_code:
__int64 __fastcall SCPI_Error(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v2 = std::operator<<<std::char_traits<char>>(&std::cerr, "**ERROR: ");
v3 = std::ostream::operator<<(v2, a2);
v4 = std::operator<<<std::char_traits<char>>(v3, ", \"");
v5 = SCPI_ErrorTranslate((unsigned int)(__int16)a2);
v6 = std::operator<<<std::char_traits<char>>(v4, v5);
v7 = std::operator<<<std::char_traits<char>>(v6, "\"");
std::ostream::operator<<(v7, &std::endl<char,std::char_traits<char>>);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v2 = std::operator<<<std::char_traits<char>>(&std::cerr, "**ERROR: ");
v3 = std::ostream::operator<<(v2, a2);
v4 = std::operator<<<std::char_traits<char>>(v3, ", \"");
v5 = SCPI_ErrorTranslate((unsigned int)(__int16)a2);
v6 = std::operator<<<std::char_traits<char>>(v4, v5);
v7 = std::operator<<<std::char_traits<char>>(v6, "\"");
std::ostream::operator<<(v7, &std::endl<char,std::char_traits<char>>);
return 0LL;
}

variable_types: err 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_unit_def_t { char *name; enum _scpi_unit_t unit; double mult; }