program TestFeatures {
section module {
std
}
section data {
int rax = 0
int rbx = 0
int rcx = 0
int rdx = 0
int rsi = 0
int rdi = 0
int r8 = 0
int r9 = 0
int r10 = 0
int r11 = 0
ptr _tmpptr0 = null
ptr _tmpptr1 = null
string str_0 = "Packed record: x="
string str_1 = " y="
string str_2 = "Packed array: [1]="
string str_3 = " [2]="
string str_4 = "3 is in [1,2,3,4,5]"
string str_5 = "ERROR: 7 should not be in [1,2,3]"
string str_6 = "7 is NOT in [1,2,3] - correct"
string str_7 = "3 is in s - correct"
string str_8 = "ERROR: 4 should not be in s"
string str_9 = "4 is NOT in s - correct"
string str_10 = "After include(s,4): 4 is in s - correct"
string str_11 = "ERROR: 3 should not be in s after exclude"
string str_12 = "After exclude(s,3): 3 is NOT in s - correct"
string str_13 = "10 is in s2 after union - correct"
string str_14 = "1 is in s2 after union - correct"
string str_15 = "1 is in intersection - correct"
string str_16 = "4 is in intersection - correct"
string str_17 = "ERROR: 9 should not be in intersection"
string str_18 = "9 is NOT in intersection - correct"
string str_19 = "ERROR: 1 should not be in difference"
string str_20 = "1 is NOT in difference - correct"
string str_21 = "4 is in difference - correct"
string str_22 = "All set tests completed."
string fmt_int = "%lld "
string fmt_str = "%s "
string newline = "\n"
ptr s = null
ptr s2 = null
ptr pr = null
ptr pa = null
}
section code {
start:
alloc s, 8, 256
mov rbx, 0
SET_INIT_0:
cmp rbx, 256
jge SET_INIT_END_1
store 0, s, rbx, 8
add rbx, 1
jmp SET_INIT_0
SET_INIT_END_1:
alloc s2, 8, 256
mov rbx, 0
SET_INIT_2:
cmp rbx, 256
jge SET_INIT_END_3
store 0, s2, rbx, 8
add rbx, 1
jmp SET_INIT_2
SET_INIT_END_3:
alloc pr, 16, 1
alloc pa, 8, 5
store 10, pr, 0, 1
store 20, pr, 8, 1
print fmt_str, str_0
load rbx, pr, 0, 1
print fmt_int, rbx
print fmt_str, str_1
load rcx, pr, 8, 1
print fmt_int, rcx
print newline
cmp 1, 1
jl IDX_OOB_5
cmp 1, 5
jg IDX_OOB_5
jmp IDX_OK_4
IDX_OOB_5:
exit 1
IDX_OK_4:
mov rdx, 1
sub rdx, 1
store 100, pa, rdx, 8
cmp 2, 1
jl IDX_OOB_7
cmp 2, 5
jg IDX_OOB_7
jmp IDX_OK_6
IDX_OOB_7:
exit 1
IDX_OK_6:
mov rdx, 2
sub rdx, 1
store 200, pa, rdx, 8
print fmt_str, str_2
mov rdx, 1
sub rdx, 1
load rsi, pa, rdx, 8
print fmt_int, rsi
print fmt_str, str_3
mov rdx, 2
sub rdx, 1
load rdi, pa, rdx, 8
print fmt_int, rdi
print newline
cmp 3, 1
je IN_FOUND_10
cmp 3, 2
je IN_FOUND_10
cmp 3, 3
je IN_FOUND_10
cmp 3, 4
je IN_FOUND_10
cmp 3, 5
je IN_FOUND_10
mov rdx, 0
jmp IN_END_11
IN_FOUND_10:
mov rdx, 1
IN_END_11:
cmp rdx, 0
je ELSE_8
print fmt_str, str_4
print newline
ELSE_8:
cmp 7, 1
je IN_FOUND_14
cmp 7, 2
je IN_FOUND_14
cmp 7, 3
je IN_FOUND_14
mov r8, 0
jmp IN_END_15
IN_FOUND_14:
mov r8, 1
IN_END_15:
cmp r8, 0
je ELSE_12
print fmt_str, str_5
print newline
jmp ENDIF_13
ELSE_12:
print fmt_str, str_6
print newline
ENDIF_13:
alloc _tmpptr0, 8, 256
mov r9, 0
SET_LIT_INIT_16:
cmp r9, 256
jge SET_LIT_INIT_END_17
store 0, _tmpptr0, r9, 8
add r9, 1
jmp SET_LIT_INIT_16
SET_LIT_INIT_END_17:
store 1, _tmpptr0, 1, 8
store 1, _tmpptr0, 3, 8
store 1, _tmpptr0, 5, 8
store 1, _tmpptr0, 7, 8
store 1, _tmpptr0, 9, 8
mov r9, 0
set_copy_18:
cmp r9, 256
jge set_copy_end_19
load r10, _tmpptr0, r9, 8
store r10, s, r9, 8
add r9, 1
jmp set_copy_18
set_copy_end_19:
free _tmpptr0
load r9, s, 3, 8
cmp r9, 0
je IN_NOT_FOUND_22
mov r10, 1
jmp IN_END_23
IN_NOT_FOUND_22:
mov r10, 0
IN_END_23:
cmp r10, 0
je ELSE_20
print fmt_str, str_7
print newline
ELSE_20:
load r9, s, 4, 8
cmp r9, 0
je IN_NOT_FOUND_26
mov r10, 1
jmp IN_END_27
IN_NOT_FOUND_26:
mov r10, 0
IN_END_27:
cmp r10, 0
je ELSE_24
print fmt_str, str_8
print newline
jmp ENDIF_25
ELSE_24:
print fmt_str, str_9
print newline
ENDIF_25:
mov r9, 1
store r9, s, 4, 8
load r9, s, 4, 8
cmp r9, 0
je IN_NOT_FOUND_30
mov r10, 1
jmp IN_END_31
IN_NOT_FOUND_30:
mov r10, 0
IN_END_31:
cmp r10, 0
je ELSE_28
print fmt_str, str_10
print newline
ELSE_28:
mov r9, 0
store r9, s, 3, 8
load r9, s, 3, 8
cmp r9, 0
je IN_NOT_FOUND_34
mov r10, 1
jmp IN_END_35
IN_NOT_FOUND_34:
mov r10, 0
IN_END_35:
cmp r10, 0
je ELSE_32
print fmt_str, str_11
print newline
jmp ENDIF_33
ELSE_32:
print fmt_str, str_12
print newline
ENDIF_33:
alloc _tmpptr0, 8, 256
mov r9, 0
SET_LIT_INIT_36:
cmp r9, 256
jge SET_LIT_INIT_END_37
store 0, _tmpptr0, r9, 8
add r9, 1
jmp SET_LIT_INIT_36
SET_LIT_INIT_END_37:
store 1, _tmpptr0, 10, 8
store 1, _tmpptr0, 20, 8
store 1, _tmpptr0, 30, 8
alloc _tmpptr1, 8, 256
mov r9, 0
SET_OP_38:
cmp r9, 256
jge SET_OP_END_39
load r10, s, r9, 8
load r11, _tmpptr0, r9, 8
cmp r10, 0
jne SET_OP_STORE_40
cmp r11, 0
jne SET_OP_STORE_40
jmp SET_OP_ZERO_41
SET_OP_STORE_40:
store 1, _tmpptr1, r9, 8
jmp SET_OP_NEXT_42
SET_OP_ZERO_41:
store 0, _tmpptr1, r9, 8
SET_OP_NEXT_42:
add r9, 1
jmp SET_OP_38
SET_OP_END_39:
mov r9, 0
set_copy_43:
cmp r9, 256
jge set_copy_end_44
load r10, _tmpptr1, r9, 8
store r10, s2, r9, 8
add r9, 1
jmp set_copy_43
set_copy_end_44:
free _tmpptr0
free _tmpptr1
load r9, s2, 10, 8
cmp r9, 0
je IN_NOT_FOUND_47
mov r10, 1
jmp IN_END_48
IN_NOT_FOUND_47:
mov r10, 0
IN_END_48:
cmp r10, 0
je ELSE_45
print fmt_str, str_13
print newline
ELSE_45:
load r9, s2, 1, 8
cmp r9, 0
je IN_NOT_FOUND_51
mov r10, 1
jmp IN_END_52
IN_NOT_FOUND_51:
mov r10, 0
IN_END_52:
cmp r10, 0
je ELSE_49
print fmt_str, str_14
print newline
ELSE_49:
alloc _tmpptr0, 8, 256
mov r9, 0
SET_LIT_INIT_53:
cmp r9, 256
jge SET_LIT_INIT_END_54
store 0, _tmpptr0, r9, 8
add r9, 1
jmp SET_LIT_INIT_53
SET_LIT_INIT_END_54:
store 1, _tmpptr0, 1, 8
store 1, _tmpptr0, 4, 8
store 1, _tmpptr0, 5, 8
store 1, _tmpptr0, 100, 8
alloc _tmpptr1, 8, 256
mov r9, 0
SET_OP_55:
cmp r9, 256
jge SET_OP_END_56
load r10, s, r9, 8
load r11, _tmpptr0, r9, 8
cmp r10, 0
je SET_OP_ZERO_58
cmp r11, 0
je SET_OP_ZERO_58
jmp SET_OP_STORE_57
SET_OP_STORE_57:
store 1, _tmpptr1, r9, 8
jmp SET_OP_NEXT_59
SET_OP_ZERO_58:
store 0, _tmpptr1, r9, 8
SET_OP_NEXT_59:
add r9, 1
jmp SET_OP_55
SET_OP_END_56:
mov r9, 0
set_copy_60:
cmp r9, 256
jge set_copy_end_61
load r10, _tmpptr1, r9, 8
store r10, s2, r9, 8
add r9, 1
jmp set_copy_60
set_copy_end_61:
free _tmpptr0
free _tmpptr1
load r9, s2, 1, 8
cmp r9, 0
je IN_NOT_FOUND_64
mov r10, 1
jmp IN_END_65
IN_NOT_FOUND_64:
mov r10, 0
IN_END_65:
cmp r10, 0
je ELSE_62
print fmt_str, str_15
print newline
ELSE_62:
load r9, s2, 4, 8
cmp r9, 0
je IN_NOT_FOUND_68
mov r10, 1
jmp IN_END_69
IN_NOT_FOUND_68:
mov r10, 0
IN_END_69:
cmp r10, 0
je ELSE_66
print fmt_str, str_16
print newline
ELSE_66:
load r9, s2, 9, 8
cmp r9, 0
je IN_NOT_FOUND_72
mov r10, 1
jmp IN_END_73
IN_NOT_FOUND_72:
mov r10, 0
IN_END_73:
cmp r10, 0
je ELSE_70
print fmt_str, str_17
print newline
jmp ENDIF_71
ELSE_70:
print fmt_str, str_18
print newline
ENDIF_71:
alloc _tmpptr0, 8, 256
mov r9, 0
SET_LIT_INIT_74:
cmp r9, 256
jge SET_LIT_INIT_END_75
store 0, _tmpptr0, r9, 8
add r9, 1
jmp SET_LIT_INIT_74
SET_LIT_INIT_END_75:
store 1, _tmpptr0, 1, 8
store 1, _tmpptr0, 5, 8
alloc _tmpptr1, 8, 256
mov r9, 0
SET_OP_76:
cmp r9, 256
jge SET_OP_END_77
load r10, s, r9, 8
load r11, _tmpptr0, r9, 8
cmp r10, 0
je SET_OP_ZERO_79
cmp r11, 0
jne SET_OP_ZERO_79
jmp SET_OP_STORE_78
SET_OP_STORE_78:
store 1, _tmpptr1, r9, 8
jmp SET_OP_NEXT_80
SET_OP_ZERO_79:
store 0, _tmpptr1, r9, 8
SET_OP_NEXT_80:
add r9, 1
jmp SET_OP_76
SET_OP_END_77:
mov r9, 0
set_copy_81:
cmp r9, 256
jge set_copy_end_82
load r10, _tmpptr1, r9, 8
store r10, s2, r9, 8
add r9, 1
jmp set_copy_81
set_copy_end_82:
free _tmpptr0
free _tmpptr1
load r9, s2, 1, 8
cmp r9, 0
je IN_NOT_FOUND_85
mov r10, 1
jmp IN_END_86
IN_NOT_FOUND_85:
mov r10, 0
IN_END_86:
cmp r10, 0
je ELSE_83
print fmt_str, str_19
print newline
jmp ENDIF_84
ELSE_83:
print fmt_str, str_20
print newline
ENDIF_84:
load r9, s2, 4, 8
cmp r9, 0
je IN_NOT_FOUND_89
mov r10, 1
jmp IN_END_90
IN_NOT_FOUND_89:
mov r10, 0
IN_END_90:
cmp r10, 0
je ELSE_87
print fmt_str, str_21
print newline
ELSE_87:
print fmt_str, str_22
print newline
free s
free s2
free pa
free pr
done
}
}